nginx 安装

nginx安装

1:
zlib库
https://jaist.dl.sourceforge.net/project/libpng/zlib/1.2.11/zlib-1.2.11.tar.gz

http://www.zlib.net/

执行命令:

./configure    &&    make   &&    make install

 

2:
pcre

https://github.com/PhilipHazel/pcre2/releases/download/pcre2-10.39/pcre2-10.39.zip

 

执行命令:

./configure    &&    make   &&    make install

 

3:

openssl 

yum -y install openssl openssl-devel

 

4:
nginx

http://nginx.org/download/nginx-1.12.0.tar.gz

http://nginx.org/download/nginx-1.14.0.tar.gz

 

安装之前务必要先创建目录nginx 否则无法安装

执行命令: 

./configure --prefix=/usr/local/nginx (首先创建nginx目录)

make && make install

 

5:

iptables

#先检查是否安装了iptables

service iptables status

#安装iptables

yum install -y iptables

#升级iptables

yum update iptables 

#安装iptables-services

yum install iptables-services

重点:开启80端口 

http://www.cnblogs.com/shabake/p/4150160.html

http://www.cnblogs.com/kreo/p/4368811.html

service iptables status 查看iptables状态
service iptables restart iptables服务重启
service iptables stop iptables服务禁用

-----------------------------------------------------------------------


sbin/nginx -s reload 无法重启 执行以下命令

/usr/local/nginx/sbin/nginx -c /usr/local/nginx/conf/nginx.conf

 -------------------------------------------------------------------

nginx 错误解决方法

yum install -y gcc gcc-c++

 

http://jingyan.baidu.com/article/a948d651093ff90a2dcd2ee5.html
 -------------------------------------------------------------------

1、Bad Request - Invalid Hostname

解决方法:删掉proxy_set_header Host $host; 这行代码

就不会提示 Bad Request - Invalid Hostname

 -------------------------------------------------------------------

 

 

启动:/usr/local/nginx/sbin/nginx
关闭:/usr/local/nginx/sbin/nginx -s stop

说明:
我的nginx安装在了/usr/local/nginx目录下了

 

 

ps -ef|grep nginx

 

posted on 2017-01-04 18:57  shabake  阅读(259)  评论(0编辑  收藏  举报

导航