Zhoulf 2013-02-09 New Year's Eve original
Installation Instructions
System Environment: CentOS-6.3
Software: nginx-1.2.6.tar.gz
Installation Method: source code compilation installation
Installation Location:/usr/local/nginx
Download Address: http://nginx.org/en/download.html
Installation Prerequisites
Before installing Nginx, you need to make sure that the system has g++, GCC, Openssl-devel, Pcre-devel, and Zlib-devel software installed. Installation must be software:
Copy Code code as follows:
[Root@admin/] #yum install gcc-c++
Yum-y install zlib zlib-devel OpenSSL openssl--devel pcre pcre-devel
Check the nginx of the system installation:
Copy Code code as follows:
[Root@admin local]# find-name Nginx
./nginx
./nginx/sbin/nginx
./nginx-1.2.6/objs/nginx
Uninstall the original Nginx
Copy Code code as follows:
[Root@admin/]# Yum Remove Nginx
Installation
Upload the installation package file to/usr/local to perform the following actions:
Copy Code code as follows:
[Root@admin local]# cd/usr/local
[Root@admin local]# tar-zxv-f nginx-1.2.6.tar.gz
[Root@admin local]# RM-RF nginx-1.2.6.tar.gz
[Root@admin local]# MV nginx-1.2.6 nginx
[Root@admin local]# Cd/usr/local/nginx
[Root@admin nginx]#./configure--prefix=/usr/local/nginx
[Root@admin nginx]# make
[Root@admin nginx]# make install
Configuration
Copy Code code as follows:
#修改防火墙配置:
[Root@admin nginx-1.2.6]# VI +/etc/sysconfig/iptables
#添加配置项
-A input-m state--state new-m tcp-p TCP--dport 80-j ACCEPT
#重启防火墙
[Root@admin nginx-1.2.6]# Service iptables restart
Start
Copy Code code as follows:
#方法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
Stop it
Copy Code code as follows:
#查询nginx主进程号
Ps-ef | grep nginx
#停止进程
Kill-quit Main process Number
#快速停止
Kill-term Main process Number
#强制停止
Pkill-9 Nginx
Reboot
[Root@admin local]#/usr/local/nginx/sbin/nginx-s Reload
Test
Copy Code code as follows:
#测试端口
Netstat–na|grep 80
#浏览器中测试
Http://ip:80