官方下載地址:http://nginx.org/en/download.html
configure配置文件詳解:http://nginx.org/en/docs/configure.html
安裝gcc g++的依賴庫
sudo apt-get install build-essential sudo apt-get install libtool
安裝pcre依賴庫(http://www.pcre.org/)
sudo apt-get update sudo apt-get install libpcre3 libpcre3-dev
安裝zlib依賴庫(http://www.zlib.net)
sudo apt-get install zlib1g-dev
安裝SSL依賴庫(16.04默認已經安裝了)
sudo apt-get install openssl
安裝Nginx
#下載穩定版本:
wget http://nginx.org/download/nginx-1.16.0.tar.gz
#解壓: tar -zxvf nginx-1.16.0.tar.gz #進入解壓目錄: cd nginx-1.16.0 #配置: ./configure --prefix=/usr/local/nginx #編譯並且安裝: make && make install
#啟動: 1. sudo /usr/local/nginx/sbin/nginx -c /usr/local/nginx/conf/nginx.conf 注意:-c 指定配置文件的路徑,不加的話,nginx會自動加載默認路徑的配置文件,可以通過-h查看幫助命令。
2. cd /usr/local/nginx
./sbin/nginx
#查看進程: ps -ef | grep nginx
root@MACHENIKE:/usr/local/nginx# ps -ef | grep nginx
root 21989 2737 0 16:32 ? 00:00:00 nginx: master process ./sbin/nginx
nobody 21990 21989 0 16:32 ? 00:00:00 nginx: worker process
root 22165 5672 0 16:37 pts/0 00:00:00 grep --color=auto nginx
#根據信號量關閉和重啟nginx:
例:kill -INT 21989
相當於重啟nginx -> kill -HUP 21989
參考:https://www.cnblogs.com/EasonJim/p/7806879.html