微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

centos安装nginx常见错误及解决办法

1. 安装完成Nginx后无法站外访问?@H_404_1@

刚安装好Nginx一个常见的问题是无法站外访问,本机wget、telnet都正常。而服务器之外,不管是局域网的其它主机还是互联网的主机都无法访问站点。如果用telnet的话,提示:@H_404_1@

正在连接到192.168.0.xxx...不能打开到主机的连接, 在端口 80: 连接失败@H_404_1@

如果用wget命令的话,提示:@H_404_1@

Connecting to 192.168.0.100:80... Failed: No route to host.@H_404_1@

如果是以上的故障现象,很可能是被CentOS的防火墙把80端口拦住了,尝试执行以下命令,打开80端口:@H_404_1@

iptables -I INPUT -p tcp --dport 80 -j ACCEPT@H_404_1@

然后用:@H_404_1@

/etc/init.d/iptables status@H_404_1@

查看当前的防火墙规则,如果发现有这样一条:@H_404_1@

ACCEPT tcp -- 0.0.0.0/0 0.0.0.0/0 tcp dpt:80@H_404_1@

就说明防火墙规则已经添加成功了,再在站外访问就正常了。@H_404_1@

2. 编译pcre错误(源码安装Nginx必须先要装pcre)@H_404_1@

libtool: compile: unrecognized option `-DHAVE_CONfig_H'@H_404_1@

libtool: compile: Try `libtool --help' for more @R_61_4045@ion.@H_404_1@

make[1]: *** [pcrecpp.lo] Error 1@H_404_1@

make[1]: Leaving directory `/usr/local/src/pcre-8.21'@H_404_1@

make: *** [all] Error 2@H_404_1@

解决办法:安装g++,别忘了重新configure@H_404_1@

apt-get install g++@H_404_1@

apt-get install build-essential@H_404_1@

make clean@H_404_1@

./configure@H_404_1@

make@H_404_1@

3. make出错@H_404_1@

make: *** No rule to make target `build',needed by `default'. Stop.@H_404_1@

./configure: error: SSL modules require the OpenSSL library.@H_404_1@

You can either do not enable the modules,or install the OpenSSL library@H_404_1@

into the system,or build the OpenSSL library statically from the source@H_404_1@

with Nginx by using --with-openssl=<path> option.@H_404_1@

ubuntu下解决办法:@H_404_1@

apt-get install openssl@H_404_1@

apt-get install libssl-dev@H_404_1@

centos下解决办法:@H_404_1@

yum -y install openssl openssl-devel@H_404_1@

4.依赖软件prce,ssl,zlib未安装错误@H_404_1@

1)如果报错@H_404_1@

./configure: error: the HTTP rewrite module requires the PCRE library.@H_404_1@

You can either disable the module by using --without-http_rewrite_module@H_404_1@

option,or install the PCRE library into the system,or build the PCRE library@H_404_1@

statically from the source with Nginx by using --with-pcre=<path> option.@H_404_1@

需要安装pcre包@H_404_1@

Pcre@H_404_1@

tar zxvf pcre-8.12.tar.gz@H_404_1@

cd pcre-8.12@H_404_1@

./configure@H_404_1@

make@H_404_1@

make install@H_404_1@

2)如果报错@H_404_1@

./configure: error: the HTTP cache module requires md5 functions@H_404_1@

from OpenSSL library. You can either disable the module by using@H_404_1@

--without-http-cache option,or install the OpenSSL library into the system,@H_404_1@

or build the OpenSSL library statically from the source with Nginx by using@H_404_1@

--with-http_ssl_module --with-openssl=<path> options.@H_404_1@

需要安装openssl@H_404_1@

tar zxvf openssl-0.9.8g.tar.gz@H_404_1@

cd openssl-0.9.8g@H_404_1@

./config --prefix=/usr/local/ --openssldir=/usr/local/openssl -g3 shared zlib-dynamic enable-camellia@H_404_1@

make@H_404_1@

make install@H_404_1@

测试是否安装成功:openssl version@H_404_1@

3)如果报错@H_404_1@

configure: error: zlib not found.@H_404_1@

需要安装:gzip.tar.gz@H_404_1@

tar zxvf gzip.tar.gz@H_404_1@

./configure@H_404_1@

make@H_404_1@

make install@H_404_1@

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 [email protected] 举报,一经查实,本站将立刻删除。