系统环境:CentOS-6.3
软件:nginx-1.2.6.tar.gz
安装方式:源码编译安装
安装位置:/usr/local/nginx
下载地址:http://nginx.org/en/download.html
安装前提在安装nginx前,需要确保系统安装了g++、gcc、openssl-devel、pcre-devel和zlib-devel软件。安装必须软件:
[[email protected] /]#yum install gcc-c++ yum -y install zlib zlib-devel openssl openssl--devel pcre pcre-devel |
检查系统安装的Nginx:
[[email protected] local]# find -name nginx ./nginx ./nginx/sbin/nginx ./nginx-1.2.6/objs/nginx |
卸载原有的Nginx
[[email protected] /]# yum remove nginx |
安装
将安装包文件上传到/usr/local中执行以下操作:
[[email protected] local]# cd /usr/local [[email protected] local]# tar -zxv -f nginx-1.2.6.tar.gz [[email protected] local]# rm -rf nginx-1.2.6.tar.gz [[email protected] local]# mv nginx-1.2.6 nginx [[email protected] local]# cd /usr/local/nginx [[email protected] nginx]# ./configure --prefix=/usr/local/nginx [[email protected] nginx]# make [[email protected] nginx]# make install |
配置
#修改防火墙配置: [[email protected] nginx-1.2.6]# vi + /etc/sysconfig/iptables #添加配置项 -A INPUT -m state --state NEW -m tcp -p tcp --dport 80 -j ACCEPT #重启防火墙
[[email protected] nginx-1.2.6]# service iptables restart
|
#方法1 [[email protected] nginx-1.2.6]# /usr/local/nginx/sbin/nginx -c /usr/local/nginx/conf/nginx.conf #方法2 [[email protected] nginx-1.2.6]# cd /usr/local/nginx/sbin [[email protected] sbin]# ./nginx
|
#查询nginx主进程号 ps -ef | grep nginx #停止进程 kill -QUIT 主进程号 #快速停止 kill -TERM 主进程号 #强制停止 pkill -9 nginx |
重启
[[email protected] local]# /usr/local/nginx/sbin/nginx -s reload |
测试
#测试端口 netstat -na|grep 80 #浏览器中测试 http://ip:80 |
声明: 此文观点不代表本站立场;转载须要保留原文链接;版权疑问请联系我们。