在CentOS 6.4上安装Nginx 1.12.1可以通过源码编译或YUM安装实现。以下是两种方法的详细步骤:
yum groupinstall "Development Tools" -y
yum install pcre-devel zlib-devel openssl-devel -y
wget http://nginx.org/download/nginx-1.12.1.tar.gz
tar -zxvf nginx-1.12.1.tar.gz
cd nginx-1.12.1
./configure \
--prefix=/usr/local/nginx \
--with-http_ssl_module \
--with-http_stub_status_module \
--with-pcre
make && make install
/usr/local/nginx/sbin/nginx
curl http://localhost
如果看到Nginx欢迎页面,说明安装成功。
rpm -Uvh http://dl.fedoraproject.org/pub/epel/6/x86_64/epel-release-6-8.noarch.rpm
yum install nginx -y
nginx -v
如果版本不符合,需通过源码编译安装。
echo "/usr/local/nginx/sbin/nginx" >> /etc/rc.local
chmod +x /etc/rc.d/rc.local
iptables -I INPUT -p tcp --dport 80 -j ACCEPT
service iptables save
如果有其他问题(如模块定制、SSL配置),可进一步补充说明需求。