1. 程式人生 > >linux cent os 6.5安裝Nginx

linux cent os 6.5安裝Nginx

exce log ror lib gun -s ges conf rar

1.下載相關組件

yum install -y gcc gcc-c++ 安裝C/C++編譯器

wget http://sourceforge.net/projects/pcre/files/pcre/8.37/pcre-8.37.tar.gz

wget ftp://ftp.openssl.org/source/old/1.0.1/openssl-1.0.1j.tar.gz

wget http://labs.frickle.com/files/ngx_cache_purge-2.1.tar.gz

wget http://nginx.org/download/nginx-1.6.2.tar.gz

順次解壓zlib/PCRE/OPENSSL/PURGE並安裝,例如:

 tar -zxvf openssl-1.0.1j.tar.gz 
  chmod a+x openssl-1.0.1j
 cd openssl-1.0.1j
 ./config --prefix=/usr/local --openssldir=/usr/local/openssl  
 make  
 make install  
./configure --add-module=/root/ngx_cache_purge-2.1 --prefix=/etc/nginx --sbin-path=/usr/sbin/nginx --conf-path=/etc/nginx/nginx.conf --error-log-path=/var
/log/nginx/error.log --http-log-path=/var/log/nginx/access.log --pid-path=/var/run/nginx.pid --lock-path=/var/run/nginx.lock --http-client-body-temp-path=/var/cache/nginx/client_temp --http-proxy-temp-path=/var/cache/nginx/proxy_temp --http-fastcgi-temp-path=/var/cache/nginx/fastcgi_temp --http-uwsgi-temp-path=/var/cache/nginx/uwsgi_temp --http-scgi-temp-path=/var
/cache/nginx/scgi_temp --user=nginx --group=nginx --with-http_realip_module --with-http_addition_module --with-http_sub_module --with-http_dav_module --with-http_flv_module --with-http_mp4_module --with-http_gunzip_module --with-http_gzip_static_module --with-http_random_index_module --with-http_secure_link_module --with-http_stub_status_module --with-http_auth_request_module --with-mail --with-file-aio --with-ipv6 --with-http_spdy_module --with-cc-opt=-O2 -g -pipe -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector --param=ssp-buffer-size=4 -m64 -mtune=generic --with-http_ssl_module --with-openssl=/root/openssl-1.0.1j make make install
錯誤信息:
/usr/local/nginx/sbin/nginx: error while loading shared libraries: libpcre.so.1: cannot open shared object file: No such file or directory
解決方法:
cd /lib64
ln -s libpcre.so.0.0.1 libpcre.so.1
啟動方法: 啟動:nginx 停止:nginx -s stop 重載:nginx reload 命令測試安裝是否完成:
 curl http://127.0.0.1

技術分享

出現上述截圖證明安裝成功。

註意其他主機訪問該Nginx服務器需要打開服務器防火墻80端口

[[email protected] ]# /sbin/iptables -I INPUT -p tcp --dport 80 -j ACCEPT
[[email protected] ]# /etc/init.d/iptables save
[[email protected] ]# /etc/init.d/iptables restart

安裝成功直接訪問如下截圖

技術分享

linux cent os 6.5安裝Nginx