標籤:style blog http io color ar os sp div
1、下載穩定版本的nginx. http://nginx.org/en/download.html
2、按照如下命令安裝
#檢查系統路徑[[email protected] usr]# pwd/usr#解壓到當前路徑[[email protected] usr]# tar -zxv -f nginx-1.6.2.tar.gz #刪除壓縮包[[email protected] usr]# rm -rf nginx-1.6.2.tar.gz #進入到解壓包下[[email protected] usr]# cd nginx-1.6.2/[[email protected] nginx-1.6.2]# #指定安裝路徑[[email protected] nginx-1.6.2]# ./configure --prefix=/usr/local/nginx#編譯[[email protected] nginx-1.6.2]# make#安裝[[email protected] nginx-1.6.2]# make install#回退到解壓縮包上級目錄[[email protected] usr]# cd ../#解除解壓縮包[[email protected] usr]# rm nginx-1.6.2 -rf
3、安裝缺少包提示
錯誤提示 ./configure: error: the HTTP rewrite module requires the PCRE library.You can either disable the module by using --without-http_rewrite_moduleoption, or install the PCRE library into the system, or build the PCRE librarystatically from the source with nginx by using --with-pcre=<path> option.解決方案[[email protected] nginx-1.6.2]# yum -y install pcre-devel
錯誤提示 ./configure: error: the HTTP gzip module requires the zlib library.You can either disable the module by using --without-http_gzip_moduleoption, or install the zlib library into the system, or build the zlib librarystatically from the source with nginx by using --with-zlib=<path> option.解決方案[[email protected] nginx-1.6.2]# yum install -y zlib-devel
錯誤提示:./configure: error: the HTTP cache module requires md5 functionsfrom OpenSSL library. You can either disable the module by using--without-http-cache option, or install the OpenSSL library into the system,or build the OpenSSL library statically from the source with nginx by using--with-http_ssl_module --with-openssl=<path> options.解決方案[[email protected] nginx-1.6.2]# yum -y install openssl openssl-devel
4、修改防火牆配置:
#修改防火牆配置:[[email protected] nginx]# vi + /etc/sysconfig/iptables#添加配置項-A INPUT -m state --state NEW -m tcp -p tcp --dport 80 -j ACCEPT#重啟防火牆
[[email protected] nginx]# service iptables restart
5、啟動nginx
#方法1
[[email protected] nginx]# /usr/local/nginx/sbin/nginx -c /usr/local/nginx/conf/nginx.conf
#方法2
[[email protected] nginx]# cd /usr/local/nginx/sbin [[email protected] sbin]# ./nginx
6、查看nginx是否啟動
[[email protected] nginx]# netstat -ntlp
或者
#測試連接埠[[email protected] nginx]# netstat –na|grep 80
#瀏覽器中測試http://ip:80
附錄:
#查詢nginx主進程號[[email protected] sbin]# ps -ef | grep nginx#停止進程[[email protected] sbin]# kill -QUIT 主進程號#快速停止[[email protected] sbin]# kill -TERM 主進程號#強制停止[[email protected] sbin]# pkill -9 nginx
轉載請註明出處:[http://www.cnblogs.com/zhoulf/archive/2013/02/09/2909653.html]
centos下安裝nginx