1. Pre-installation Environment preparation
Install Make:
# yum-y Install gcc automake autoconf libtool make
Install g++:
# yum Install gcc gcc-c++
2. Generally need to first install Pcre, Zlib, the former in order to rewrite rewrite, the latter for gzip compression
Installing Pcre
: http://www.pcre.org/
# TAR-XVF Pcre-8.36.tar.gz
# CD pcre-8.36
#./configure--prefix=/usr/local/pcre
# make
# make Install
Installing zlib
: http://www.zlib.net/
# CD/USR/LOCAL/SRC
# TAR-XVF Zlib-1.2.8.tar.gz
# CD zlib-1.2.8
#./configure--prefix=/usr/local/zlib
# make
# make Install
Install SSL (some VPS default does not install SSL)
# CD/USR/LOCAL/SRC
# wget http://www.openssl.org/source/openssl-1.0.1c.tar.gz
# TAR-ZXVF Openssl-1.0.1c.tar.gz
3. Installing Nginx
# Groupadd Vc_php_grp
# useradd-g Vc_php_grp vc_php_usr-s/bin/nologin
./configure--prefix=/usr/local/--with---user=--group=--with--- with-zlib=/usr/local/src/zlib-1.2. 8 --with-pcre=/usr/local/src/pcre-8.36--with-openssl=/usr/local/src/openssl-1.0 . 1c
Configuration Summary+usingPCRE Library:/usr/local/src/pcre-8.36+usingOpenSSL Library:/usr/local/src/openssl-1.0. 1c+usingBuiltin MD5 Code+ SHA1 Library isNot found+usingZlib Library:/usr/local/src/zlib-1.2.8nginx path Prefix:"/usr/local/nginx"nginx binary file:"/usr/local/nginx/sbin/nginx"nginx configuration prefix:"/usr/local/nginx/conf"nginx configuration file:"/usr/local/nginx/conf/nginx.conf"nginx pid File:"/usr/local/nginx/logs/nginx.pid"nginx error log file:"/usr/local/nginx/logs/error.log"nginx HTTP access log file:"/usr/local/nginx/logs/access.log"nginx HTTP client request body temporary files:"client_body_temp"nginx HTTP proxy temporary files:"proxy_temp"nginx http fastcgi temporary files:"fastcgi_temp"nginx http Uwsgi temporary files:"uwsgi_temp"nginx http scgi temporary files:"scgi_temp"
Attention:
--with-openssl=/usr/local/src/openssl-1.0.1c
--with-zlib=/usr/local/src/zlib-1.2.8
--with-pcre=/usr/local/src/pcre-8.36
Point to the source package decompression path, not the path of installation, otherwise it will be an error
4. Start Nginx
/usr/local/nginx/sbin/nginx
5. Set up reboot
vi/etc/init.d/Nginx (Enter the following code) #!/bin/bash# nginx Startup script forThe Nginx HTTP server# it isV.0.0.2version.# chkconfig:- - the# Description:nginx isA 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.confnginxd=/usr/local/nginx/sbin/Nginxnginx_config=/usr/local/nginx/conf/Nginx.confnginx_pid=/usr/local/nginx/logs/nginx.pidRETVAL=0Prog="Nginx"# Source Function library:/etc/rc.d/init.d/functions# Source Networking configuration:/etc/sysconfig/network# Check that networking isUp . [${networking}="No"] && exit0[ -X $nginxd] | | Exit0# Start Nginx daemons Functions.start () {if[ -e $nginx _pid];then echo"Nginx already running ...."Exit1fi echo-N $"starting $prog:"Daemon $nginxd-c ${nginx_config} RETVAL=$?Echo [$RETVAL=0] && Touch/var/Lock/subsys/Nginxreturn$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 " $" inchstart) Start; stop) stop;; reload) reload;; restart) stop start;; Status) status $prog RETVAL=$? ;;*) echo $"Usage: $prog {start|stop|restart|reload|status|help}"Exit1esacexit $RETVAL
# chmod 775/etc/init.d/nginx #赋予文件执行权限
# chkconfig Nginx on #设置开机启动
#/etc/init.d/nginx Restart #重启
Open the server IP address in the browser and test if the Nginx installation was successful.
If you need to work with PHP scripts, you also need to install php-fpm.
Linux Source Installation Nginx