首页 > 代码库 > linux cent os 6.5安装Nginx

linux cent os 6.5安装Nginx

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端口

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

 

安装成功直接访问如下截图

技术分享

 

linux cent os 6.5安装Nginx