安装位置:/usr/local/nginx?
下载地址:http://nginx.org/en/download.html
------------------------------------------------------------------------------------------------------------------------
安装前提
在安装nginx前,需要确保系统安装了g++、gcc、openssl-devel、pcre-devel和zlib-devel软件。安装必须软件:
[root@admin /]#yum install gcc-c++
[root@admin /]#yum -y install zlib zlib-devel openssl openssl--devel pcre pcre-devel
检查系统安装的Nginx:
[root@admin local]# find -name nginx
./nginx
./nginx/sbin/nginx
./nginx-1.2.6/objs/nginx
卸载原有的Nginx
[root@admin /]# yum remove nginx
-----------------------------------------------------------------------------------------------------------------------
安装
将安装包文件上传到/usr/local中执行以下操作:
[root@admin nginx]# tar -zxv -f nginx-1.2.6.tar.gz
[root@admin nginx]# cd nginx-版本号
[root@admin nginx]# ./configure
[root@admin nginx]# make
[root@admin nginx]# make install
按照以上命令,Nginx将被默认安装到/usr/local/nginx目录下
----------------------------------------------------------------------------------------------------------------------
启动
#方法1
[root@admin nginx-1.2.6]# /usr/local/nginx/sbin/nginx -c /usr/local/nginx/conf/nginx.conf
#方法2
[root@admin nginx-1.2.6]# cd /usr/local/nginx/sbin
[root@admin sbin]# ./nginx
------------------------------------------------------------------------------------------------------------------
停止
#查询nginx主进程号?
ps -ef | grep nginx
#停止进程?
kill -QUIT 主进程号?
#快速停止?
kill -TERM 主进程号?
#强制停止?
pkill -9 nginx
--------------------------------------------------------------------------------------------------------------------------
测试
#测试端口?
netstat –na|grep 80
#浏览器中测试?
http://ip:80