Nginx 源碼編譯安裝
添加用戶
# useradd nginx -s /sbin/nologin
安裝所需要的系統組件
# yum -y groupinstall "Development tools"
# yum -y install pcre-devel
# yum -y install openssl-devel
創建所需要的臨時目錄
# mkdir -p /var/tmp/nginx/{client,fastcgi,proxy,uwsgi}
解壓nginx安裝包、並編譯安裝
# tar xf nginx-1.8.1.tar.gz # cd nginx-1.8.1 # ./configure --prefix=/usr/local/nginx --conf-path=/etc/nginx/nginx.conf --user=nginx --group=nginx \ --error-log-path=/home/nginx/error.log \ --http-log-path=/home/nginx/access.log \ --pid-path=/var/run/nginx/nginx.pid \ --lock-path=/var/lock/nginx.lock \ --with-http_ssl_module \ --with-http_stub_status_module \ --with-http_gzip_static_module \ --with-http_flv_module \ --with-http_mp4_module \ --http-client-body-temp-path=/var/tmp/nginx/client \ --http-proxy-temp-path=/var/tmp/nginx/proxy \ --http-fastcgi-temp-path=/var/tmp/nginx/fastcgi \ --http-uwsgi-temp-path=/var/tmp/nginx/uwsgi # make -j 2 && make install
配置系統環境變量
vim /etc/profile.d/nginx.sh
export PATH=/usr/local/nginx/sbin:$PATH
讓剛配置好的環境變量生效
source /etc/profile.d/nginx.sh
啓動nginx
/usr/local/nginx/sbin/nginx
查看監聽端口
]# ss -tnlp State Recv-Q Send-Q Local Address:Port Peer Address:Port LISTEN 0 128 *:80 *:* users:(("nginx",3574,6),("nginx",3575,6),("nginx",10892,6))