1. Download the installation package
wget http://nginx.org/download/nginx-1.8.0.tar.gz
2. Unzip
Tar zxvf nginx-1.8.0.tar.gz
3. Preparing the installation Environment
Yum-y install gcc gcc-c++ autoconf automake make
Yum-y install zlib zlib-devel OpenSSL openssl--devel pcre pcre-devel
4. Enter Ngxin extract directory [cd/data/nginx/nginx-1.8.0 can modify it by itself]
Execution:./configure
Make && make install
5. Modify the configuration file
Configuration file path:/usr/local/nginx/conf/nginx.conf
6. Set Boot up
Entry:/etc/init.d/
VI Nginx
Fill in the content:
#=================================
#!/bin/bash
# nginx Startup script for the Nginx HTTP Server
# It is v.0.0.2 version.
# Chkconfig:-85 15
# Description:nginx is a high-performance Web and proxy server.
# It has a lot of features, but it's not for everyone.
# Processname:nginx
# Pidfile:/var/run/nginx.pid
# config:/usr/local/nginx/conf/nginx.conf
Nginxd=/usr/local/nginx/sbin/nginx
Nginx_config=/usr/local/nginx/conf/nginx.conf
Nginx_pid=/var/run/nginx.pid
Retval=0
Prog= "Nginx"
# Source function library.
. /etc/rc.d/init.d/functions
# Source Networking configuration.
. /etc/sysconfig/network
# Check that networking are up.
[${networking} = "No"] && exit 0
[-X $nginxd] | | Exit 0
# Start Nginx daemons functions.
Start () {
If [-e $nginx _pid];then
echo "Nginx already running ..."
Exit 1
Fi
Echo-n $ "Starting $prog:"
Daemon $nginxd-C ${nginx_config}
Retval=$?
Echo
[$RETVAL = 0] && Touch/var/lock/subsys/nginx
Return $RETVAL
}
# Stop Nginx daemons functions.
Stop () {
Echo-n $ "Stopping $prog:"
Killproc $nginxd
Retval=$?
Echo
[$RETVAL = 0] && rm-f/var/lock/subsys/nginx/var/run/nginx.pid
}
# Reload Nginx service functions.
Reload () {
Echo-n $ "Reloading $prog:"
#kill-hup ' Cat ${nginx_pid} '
Killproc $nginxd-hup
Retval=$?
Echo
}
# See how we were called.
Case "$" in
Start
Start
;;
Stop
Stop
;;
Reload
Reload
;;
Restart
Stop
Start
;;
Status
Status $prog
Retval=$?
;;
*)
echo $ "Usage: $prog {start|stop|restart|reload|status|help}"
Exit 1
Esac
Exit $RETVAL
==========================
Save exit.
Vi/etc/rc.local add/etc/init.d/nginx Start save and exit the next reboot will take effect, implement nginx self-boot
Reference
Http://www.myhack58.com/Article/sort099/sort0102/2015/66341.htm
CentOS nginx1.8 Installation