欢迎访问linux宝典,请记住本站唯一域名:www.linuxbaodian.com

Nginx编译安装

来源:原创    更新时间:2018-08-25 21:39:55    编辑:管理员    浏览:2676

报错1:编译安装提示the HTTP rewrite module requires the PCRE library.

./configure: error: the HTTP rewrite module requires the PCRE library.
You can either disable the module by using --without-http_rewrite_module
option, or install the PCRE library into the system, or build the PCRE library
statically from the source with nginx by using --with-pcre=<path> option.

剖析:这是因为--without-http_rewrite_module是伪静态的模块,使用这个模块我们就需要安装pcre这个软件包,我们在这里面安装一下即可。

解决办法:

       安装 yum -y install pcre pcre-devel


报错2:编译安装提示HTTP SSL module requires the OpenSSL library.

./configure: error: the HTTP SSL module requires the OpenSSL library.
You can either do not enable the module, or install the OpenSSL library
into the system, or build the OpenSSL library statically from the source
with nginx by using --with-openssl=<path> option.
/configure:错误:HTTP SSL模块需要OpenSSL库。
您可以不启用该模块,也可以安装OpenSSL库
进入系统,或从源静态构建OpenSSL库
使用--with-openssl = <path>选项使用nginx。

剖析:因为我们安装了httpd-openssl模块,但是我们却没有安装openssl这个软件,他找不到openssl的依赖库,所以提示这个,

解决办法:

    yum -y install openssl openssl-devel.x86_64 即可


报错3: ./configure 完成之后,我们ll查看的编译后的权限,属主和属组位全是数字,

[root@WNginx01_7 nginx-0.5.38]# ./configure --prefix=/opt/nginx-0.5.38 --user=web --group=web --with-http_stub_status_module  --with-http_ssl_module
[root@WNginx01_7 nginx-0.5.38]# ll
total 252
drwxr-xr-x 6 1000 1000   4096 Aug 20 13:24 auto
-rw-r--r-- 1 1000 1000 106030 Sep 14  2009 CHANGES
-rw-r--r-- 1 1000 1000 108488 Sep 14  2009 CHANGES.ru
drwxr-xr-x 2 1000 1000   4096 Aug 20 13:24 conf
-rwxr-xr-x 1 1000 1000   1904 Dec 23  2006 configure
drwxr-xr-x 3 1000 1000   4096 Aug 20 13:24 contrib
drwxr-xr-x 2 1000 1000   4096 Aug 20 13:24 html
-rw-r--r-- 1 1000 1000   1329 Jan  8  2008 LICENSE
-rw-r--r-- 1 root root    715 Aug 20 13:30 Makefile
drwxr-xr-x 3 root root   4096 Aug 20 13:30 objs
-rw-r--r-- 1 1000 1000    127 Oct 12  2006 README
drwxr-xr-x 7 1000 1000   4096 Aug 20 13:24 src

剖析:因为我们指定的用户是web用户为普通用户,你会发现他对编译后所在的目录没有写权限,所以才会造成这种情况。

解决办法:

       1,给他要把软件编译到的目录w权限,使他能创建文件或目录

       2,编译安装完成之后使用root把编译后的文件和目录更改一下属主和属组成web(chown -R web:web /opt/nginx-0.5.38)


错误4: Nginx编译安装的时候提示:cp: `conf/koi-win' and `/usr/local/nginx/conf/koi-win' are the same file

提示conf/koi-win' 和 /usr/local/nginx/conf/koi-win 是同一个文件,

解决办法:

       1,有人说是防火墙没关,关闭完成之后还是不好使

       2,我把编译软件的位置给换了,我刚开始的时候是把编译后的软件位置又放到源码包的位置了。


错误5: nginx启动失败提示Address already in use

安装完成之后测试nginx是否能正常启动的时候发现启动失败提示如下:

nginx: [emerg] bind() to 0.0.0.0:80 failed(98: Address already in use)

剖析:

       这句话翻译过来的意思就是  绑定这个地址的80端口失败,因为这个端口正在被占用。

解决办法:

       1,通过netstat -ntalp | grep 80      通过这个指令来确定是那个进程正在占用80端口,我们找到这个进程,查看这个进程是干什么用的,如果杀死他对你的服务没有任何影响就可以通过kill -15 进程PID来杀死这个进程

       2,进到nginx配置文件里面,更改一下他的端口(listen port)然后在进程服务启动即可,访问的时候我们需要加上端口号来进行访问


错误6: 启动nginx之前使用-t参数检查语法的时候报错

[root@WNginx01_7 nginx]# nginx  -c /usr/local/nginx/conf/nginx.conf -t
2018/08/24 11:10:34 [emerg] 9886#0: unexpected "}" in /usr/local/nginx/conf/nginx.conf:28
2018/08/24 11:10:34 [emerg] 9886#0: the configuration file /usr/local/nginx/conf/nginx.conf test failed

剖析:

       从翻译上面报错就可以看出,测试这个配置文件失败,因为他在第28行有问题

解决办法:

       我们vim /usr/local/nginx/conf/nginx.conf +28 进到这个配置文件里面,看看这句话是不是语法有什么错误,如果这句话语法正常的话,那就看看它紧结着上面一行的语法有没有错误。Nginx的配置文件每一行结束要用“;”来标识。


评论区

表情

共0条评论
  • 这篇文章还没有收到评论,赶紧来抢沙发吧~

相关内容

点击排行

随机新闻

评论排行榜