1.解壓nginx
tar -xvf nginx.xxxx.tar
2.進入安裝源包
3.開始安裝,安裝nginx前,我們首先要確保系統安裝了g++、gcc、openssl-devel、pcre-devel和zlib-devel軟件
yum install gcc-c++
yum -y install zlib zlib-devel openssl openssl–devel pcre pcre-devel
4.開始安裝
./configure --prefix=/usr/local/nginx
注意:–prefix=/usr/local/nginx,指定安裝路徑,可更改,如果不寫,則是安裝到默認路徑下/usr/local/nginx
5.配置nginx的環境變量
export NGINX_HOME=/home/tools/nginx-1.15.8
export PATH=$PATH:$NGINX_HOME/sbin
6.進入安裝目錄,
cd /usr/local/nginx/sbin/
7.啓動nginx
./nginx
走到這一步,已經基本成功了,如果還想添加第三方組件,繼續
8.查看當前安裝組件
configure arguments是已經添加成功的組件
configure arguments: --prefix=/usr/local/nginx --sbin-path=/usr/local/nginx/sbin/nginx --conf-path=/usr/local/nginx/conf/nginx.conf --error-log-path=/var/log/nginx/error.log --pid-path=/var/run/nginx/nginx.pid --lock-path=/var/lock/nginx.lock --user=nginx --group=nginx --with-http_ssl_module --with-http_flv_module --with-http_gzip_static_module --http-log-path=/var/log/nginx/access.log --http-client-body-temp-path=/var/tem/nginx/client --http-proxy-temp-path=/var/tem/nginx/proxy --http-fastcgi-temp-path=/var/tem/nginx/fcgi --with-http_stub_status_module
9.下面開始添加組件
首先關閉nginx
/usr/local/nginx/sbin/nginx -s stop
回到安裝源目錄,在安裝源目錄下執行
./configure --prefix=/usr/local/nginx --sbin-path=/usr/local/nginx/sbin/nginx --conf-path=/usr/local/nginx/conf/nginx.conf --error-log-path=/var/log/nginx/error.log --pid-path=/var/run/nginx/nginx.pid --lock-path=/var/lock/nginx.lock --user=nginx --group=nginx --with-http_ssl_module --with-http_flv_module --with-http_gzip_static_module --http-log-path=/var/log/nginx/access.log --http-client-body-temp-path=/var/tem/nginx/client --http-proxy-temp-path=/var/tem/nginx/proxy --http-fastcgi-temp-path=/var/tem/nginx/fcgi --with-http_stub_status_module
再執行
make
千萬不可再執行make install
然後執行
cp ./objs/nginx /usr/local/nginx/sbin/
重新啓動nginx