# yum install gcc gcc-c++ make automake autoconf libtool pcre pcre-devel zlib zlib-devel openssl openssl-devel
进入Nginx的上传目录:
# cd /usr/local/src/
解压安装包:
# tar -zxvf nginx-1.6.2.tar.gz
进入解压后的文件夹:
# cd nginx-1.6.2
指定编译位置:
# ./configure --prefix=/usr/local/nginx
编译:
# make && make install
通过修改/conf/nginx.conf文件来修改Nginx的配置信息
# vi /usr/local/nginx/conf/nginx.conf
# vi /etc/sysconfig/iptables
添加:
## nginx
-A INPUT -m state --state NEW -m tcp -p tcp --dport 80 -j ACCEPT
添加后重启防火墙:
# service iptables restart
# /usr/local/nginx/sbin/nginx -t
出现以下信息,代表成功
nginx: the configuration file /usr/local/nginx/conf/nginx.conf syntax is ok
nginx: configuration file /usr/local/nginx/conf/nginx.conf test is successful
# /usr/local/nginx/sbin/nginx
查看Nginx进程
# ps -ef|grep nginx
停止Nginx
# /usr/local/nginx/sbin/nginx -s stop
重启Nginx
# /usr/local/nginx/sbin/nginx -s reload
编辑/etc下的rc.local文件
# vi /etc/rc.local
添加:
/usr/local/nginx/sbin/nginx