安装在/opt/nginx/中
1.在安装nginx前,需要确保系统安装了g++、gcc、openssl-devel、pcre-devel和zlib-devel软件
yum install gcc-c++ |
2.检查是否有nginx
find -name nginx (有的话,卸载原有的nginx ,yum remove nginx) |
3.下载安装
现在/opt下新建文件夹:nginx
wget http://nginx.org/download/nginx-1.5.9.tar.gz tar -zxv -f nginx-1.5.9.tar.gz cd nginx-1.5.9 ./configure --prefix=/opt/nginx (设置配置信息) make make install |
在配置信息的时候出现:
安装pcre-devel解决问题 还有可能出现:
错误提示:./configure: error: the HTTP cache module requires md5 functions 解决办法: yum -y install openssl openssl-devel |
4.配置防火墙
#修改防火墙配置: vi + /etc/sysconfig/iptables #添加配置项 -A INPUT -m state --state NEW -m tcp -p tcp --dport 80 -j ACCEPT #重启防火墙 : service iptables restart |
第三步: 启动ngnix /opt/nginx/sbin/nginx start 或者 ./nginx 停止:
#查询nginx主进程号 重启: [root@admin local]# /usr/local/nginx/sbin/nginx -s reload |