1. Download: http://nginx.org/en/download.html
2. install dependency: yum-y install GCC gcc-C ++ Autoconf libjpeg-devel libpng-devel FreeType-devel libxml2 libxml2-devel zlib-devel glibc-devel glib2 glib2-devel Bzip2 bzip2-devel ncurses- devel curl-devel e2fsprogs e2fsprogs-devel krb5 krb5-devel libidn-devel OpenSSL-devel OpenLDAP openldap-devel nss_ldap openldap-clients openldap-servers PCRE-devel
3. wget http://nginx.org/download/nginx-1.4.4.tar.gz
4. Tar zxf nginx-1.4.4.tar.gz
5. CD nginx-1.4.4
6 ../configure
-- Prefix = <path>-nginx installation path. If not specified, the default value is/usr/local/nginx.
-- Sbin-Path = <path>-nginx Executable File Installation path. It can only be specified during installation. If it is not specified, the default value is <prefix>/sbin/nginx
-- Conf-Path = <path>-the default nginx. conf path without the-C option. If not specified, the default value is <prefix>/CONF/nginx. conf.
-- PID-Path = <path>-if no PID command is specified in nginx. conf, the default nginx. PID path is used. If not specified, the default value is <prefix>/logs/nginx. PID.
-- Lock-Path = <path>-nginx. Lock file path.
-- Error-log-Path = <path>-default error log path when no error_log command is specified in nginx. conf. If not specified, the default value is <prefix>/logs/error. log.
-- Http-log-Path = <path>-the default access log path when no access_log command is specified in nginx. conf. If not specified, the default value is <prefix>/logs/access. log.
-- User = <user>-the default nginx user if no USER command is specified in nginx. conf. If not specified, the default value is nobody.
-- Group = <group>-the default group used by nginx when no USER command is specified in nginx. conf. If not specified, the default value is nobody.
-- Builddir = Dir-specify the compiled directory
-- With-rtsig_module-enables the rtsig module for final installation
7. Make & make install
8. Set to system boot Service
Create an nginx file in the/etc/init. d/directory as follows:
#!/bin/bash # nginx Startup script for the Nginx HTTP Server# this script create it by gcec at 2009.10.22.# it is v.0.0.1 version.# if you find any errors on this scripts,please contact gcec cyz.# and send mail to support at gcec dot cc.## 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/nginxnginx_config=/usr/local/nginx/conf/nginx.confnginx_pid=/usr/local/nginx/logs/nginx.pid RETVAL=0prog="nginx" # Source function library.. /etc/rc.d/init.d/functions # Source networking configuration.. /etc/sysconfig/network # Check that networking is up.[ ${NETWORKING} = "no" ] && exit 0 [ -x $nginxd ] || exit 0 # Start nginx daemons functions.start() { if [ -e $nginx_pid ];then echo "nginx already running...." exit 1fi 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 /usr/local/nginx/logs/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 "$1" instart) start ;;stop) stop ;;reload) reload ;;restart) stop start ;;status) status $prog RETVAL=$? ;;*) echo $"Usage: $prog {start|stop|restart|reload|status|help}" exit 1esacexit $RETVAL
9. Add to service:
Chmod 0777/etc/init. d/nginx
Chkconfig -- add nginx
Chkconfig -- level 345 nginx on
Chkconfig -- list nginx
Start
Service nginx start
Stop
Service nginx stop
Install nginx on centos