標籤:des style blog http color io os 使用 ar
1. 下載:http://nginx.org/en/download.html
2. 安裝依賴:yum -y install gcc gcc-c++ autoconf libjpeg libjpeg-devel libpng libpng-devel freetype freetype-devel libxml2 libxml2-devel zlib zlib-devel glibc glibc-devel glib2 glib2-devel bzip2 bzip2-devel ncurses ncurses-devel curl curl-devel e2fsprogs e2fsprogs-devel krb5 krb5-devel libidn libidn-devel openssl openssl-devel openldap openldap-devel nss_ldap openldap-clients openldap-servers pcre 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安裝路徑。如果沒有指定,預設為 /usr/local/nginx。
--sbin-path=<path> - Nginx可執行檔安裝路徑。只能安裝時指定,如果沒有指定,預設為<prefix>/sbin/nginx
--conf-path=<path> - 在沒有給定-c選項下預設的nginx.conf的路徑。如果沒有指定,預設為<prefix>/conf/nginx.conf。
--pid-path=<path> - 在nginx.conf中沒有指定pid指令的情況下,預設的nginx.pid的路徑。如果沒有指定,預設為 <prefix>/logs/nginx.pid。
--lock-path=<path> - nginx.lock檔案的路徑。
--error-log-path=<path> - 在nginx.conf中沒有指定error_log指令的情況下,預設的錯誤記錄檔的路徑。如果沒有指定,預設為 <prefix>/logs/error.log。
--http-log-path=<path> - 在nginx.conf中沒有指定access_log指令的情況下,預設的訪問日誌的路徑。如果沒有指定,預設為 <prefix>/logs/access.log。
--user=<user> - 在nginx.conf中沒有指定user指令的情況下,預設的nginx使用的使用者。如果沒有指定,預設為 nobody。
--group=<group> - 在nginx.conf中沒有指定user指令的情況下,預設的nginx使用的組。如果沒有指定,預設為 nobody。
--builddir=DIR - 指定編譯的目錄
--with-rtsig_module - 啟用 rtsig 模組最後安裝
7. make && make install
8. 設定成系統開機服務
在 /etc/init.d/ 目錄下建立 nginx 檔案 內容如下:
#!/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. 添加到服務:
chmod 0777 /etc/init.d/nginx
chkconfig --add nginx
chkconfig --level 345 nginx on
chkconfig --list nginx
啟動
service nginx start
停止
service nginx stop
CentOS安裝Nginx