下载地址:http://nginx.org/en/download.html
vim /etc/yum.repos.d/nginx.repo
[nginx-stable]
name=nginx stable repo
baseurl=http://nginx.org/packages/centos/$releasever/$basearch/
gpgcheck=1
enabled=1
gpgkey=https://nginx.org/keys/nginx_signing.key
module_hotfixes=true
yum install nginx -y
[root@server ~]# yum -y install pcre-devel openssl openssl-devel gd-devel
[root@server ~]# yum -y groups install ‘Development Tools‘
[root@server ~]# mkdir -p /var/log/nginx
[root@server ~]# chown -R nginx.nginx /var/log/nginx/
[root@server ~]# cd /usr/src/
[root@server src]# wget http://nginx.org/download/nginx-1.12.0.tar.gz
[root@server ~]# cd /usr/src/
[root@server src]# tar xf nginx-1.12.0.tar.gz
[root@server src]# cd nginx-1.12.0
[root@server nginx-1.12.0]# ./configure --prefix=/usr/local/nginx --user=nginx --group=nginx --with-debug --with-http_ssl_module --with-http_realip_module --with-http_image_filter_module --with-http_gunzip_module --with-http_gzip_static_module --with-http_stub_status_module --http-log-path=/var/log/nginx/access.log --error-log-path=/var/log/nginx/error.log
[root@server nginx-1.12.0]# make -j 2 && make install
[root@server nginx-1.12.0]# echo ‘export PATH=/usr/local/nginx/sbin:$PATH‘ > /etc/profile.d/nginx.sh
[root@server nginx-1.12.0]# . /etc/profile.d/nginx.sh
//注:
[root@nginx-server nginx-1.12.0]# echo $PATH
/usr/local/nginx/sbin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/root/bin
[root@server ~]# nginx
[root@server ~]# ss -antl
原文:https://www.cnblogs.com/yanghaizhen/p/14870788.html