CentOS 6.3 install and configure the Nginx method
- 2020-05-09 19:51:36
- OfStack
zhoulf 2013-02-09 New Year's eve original
Installation instructions
System environment: CentOS-6.3
Software: nginx - 1.2.6. tar. gz
Installation: source code compilation and installation
Installation location: /usr/local/nginx
Download address: http: / / nginx org/en/download html
Install the prerequisite
Before installing nginx, you need to ensure that the g++, gcc, openssl-devel, pcre-devel, and zlib-devel software are installed on your system. Required software for installation:
[root@admin /]#yum install gcc-c++
yum -y install zlib zlib-devel openssl openssl--devel pcre pcre-devel
Check Nginx for system installation:
[root@admin local]# find -name nginx
./nginx
./nginx/sbin/nginx
./nginx-1.2.6/objs/nginx
Uninstall the original Nginx
[root@admin /]# yum remove nginx
The installation
Upload the installation package file to /usr/local and do the following:
[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
# Modify firewall configuration:
[root@admin nginx-1.2.6]# vi + /etc/sysconfig/iptables
# Add configuration item
-A INPUT -m state --state NEW -m tcp -p tcp --dport 80 -j ACCEPT
# Restart the firewall
[root@admin nginx-1.2.6]# service iptables restart
Start the
# methods 1
[root@admin nginx-1.2.6]# /usr/local/nginx/sbin/nginx -c /usr/local/nginx/conf/nginx.conf
# methods 2
[root@admin nginx-1.2.6]# cd /usr/local/nginx/sbin
[root@admin sbin]# ./nginx
stop
# The query nginx The main process,
ps -ef | grep nginx
# Stop the process
kill -QUIT The main process,
# A quick stop
kill -TERM The main process,
# Forced to stop
pkill -9 nginx
restart
[root@admin local]# /usr/local/nginx/sbin/nginx -s reload
test
# Test port
netstat � na|grep 80
# Test in the browser
http://ip:80