当前位置:首页 > linux > 正文

linux安装nginx离线安装(linux离线部署nginx)

  • linux
  • 2024-04-08 06:39:47
  • 2043

壹、linux怎么快速安装nginx和php,不用安装数据库

Linux下如果要搭建nginx和php环境,需要安装三个软件包:

nginx,php,php-fpm

比如说如果是centos的话:

yum install nginx php php-fpm

可能软件包名有差别,这个查查就知道了。

然后配置nginx,修改nginx.conf,如果用sock就这样写,如果是端口就些端口:

    location ~ \.php$ {                                                                                                
        fastcgi_pass   unix:/var/run/php-fpm/php-fpm.sock;                                                             
        fastcgi_index  index.php;                                                                                      
        include        fastcgi.conf;                                                                                   
    }

然后启动服务,以centos7为例:

systemctl start nginx
systemctl start php-fpm

贰、linux下nginx模块的安装
安装
第一步下载并解压Nginx压缩包
从Nginx官网下载Nginx,或者在Linux上执行wgethttp://nginx.org/download/nginx-1.10.1.tar.gz命令直接下载
解压nginx-1.10.1.tar.gz文件:
tarzxvfnginx-1.10.1.tar.gz
1
1
第二步配置
cdnginx-1.10.1
./configure--pre fix=/usr/local/nginx
1
2
1
2
注意:
①如果之前没有安装Ccompiler(C编译器),这一步将报如下错误信息:
xueliang@dev:~/download/nginx-1.10.1$./configure–pre fix=/usr/local/nginx
checkingforOS
+Linux4.2.0-27-genericx86_64
checkingforCcompiler…notfound
./configure:error:Ccompilerccisnotfound
xueliang@dev:~/download/nginx-1.10.1$
可以参考这篇文章安装Ccompiler,然后继续下面的操作
②如果之前没有安装PCRE,这一步将报如下错误信息:
checkingforPCRElibrary…notfound
checkingforPCRElibraryin/usr/local/…notfound
checkingforPCRElibraryin/usr/include/pcre/…notfound
checkingforPCRElibraryin/usr/pkg/…notfound
checkingforPCRElibraryin/opt/local/…notfound
./configure:error:theHTTPrewritemodulerequiresthePCRElibrary.
Youcaneitherdisablethemodulebyusing–without-http_rewrite_module
option,orinstallthePCRElibraryintothesystem,orbuildthePCRElibrary
staticallyfromthesourcewithnginxbyusing–with-pcre=option.
xueliang@dev:~/download/nginx-1.10.1$
③如果之前没有安装zlib,这一步将报如下错误信息:
checkingformd5insystemmdlibrary…notfound
checkingformd5insystemmd5library…notfound
checkingformd5insystemOpenSSLcryptolibrary…notfound
checkingforsha1insystemmdlibrary…notfound
checkingforsha1insystemOpenSSLcryptolibrary…notfound
checkingforzliblibrary…notfound
./configure:error:theHTTPgzipmodulerequiresthezliblibrary.
Youcaneitherdisablethemodulebyusing–without-http_gzip_module
option,orinstallthezliblibraryintothesystem,orbuildthezliblibrary
staticallyfromthesourcewithnginxbyusing–with-zlib=option.
xueliang@dev:~/download/nginx-1.10.1$
也可以跳过此步,执行默认安装,--pre fix的默认值为/usr/local/nginx,Nginx官网对此有说明:BuildingnginxfromSources