Nginx在linux下安裝及簡單命令


安裝環境:Centos7

 

創建目錄及切換至目錄

# mkdir /usr/local/nginx
# cd /usr/local/nginx/

下載nginx包,訪問http://nginx.org下載或http://nginx.org/download或使用命令下載

wget http://nginx.org/download/nginx-1.17.3.tar.gz

解壓nginx包及移至解壓目錄

# tar -zxvf nginx-1.17.3.tar.gz
# cd nginx-1.17.3/

設置安裝路徑

# ./configure --prefix=/usr/local/nginx

若出現錯誤【checking for C compiler ... not found】需要執行如下命令

# yum -y install gcc gcc-c++ autoconf automake make

若出現下面的錯誤,需要安裝openssl

./configure: error: the HTTP rewrite module requires the PCRE library.
You can either disable the module by using --without-http_rewrite_module
option, or install the PCRE library into the system, or build the PCRE library
statically from the source with nginx by using --with-pcre=<path> option.

安裝openssl命令

# yum -y install openssl openssl-devel

編譯--make是用來編譯的,它從Makefile中讀取指令,然后編譯。

# make

安裝--make install是用來安裝的,它也從Makefile中讀取指令,安裝到指定的位置。

# make install

 

至此,nginx已經安裝成功,接下來可以執行nginx命令來操作nginx

 

命令

啟動 -- # /usr/local/nginx/sbin/nginx -c /usr/local/nginx/conf/nginx.conf

重啟 -- # nginx -s reload

重新打開日志文件 -- # nginx -s reopen

測試nginx配置文件是否正確 -- # nginx -t -c /usr/local/nginx/conf/nginx.conf

快速停止 -- # nginx -s stop

完整有序的停止 -- # nginx -s quit

 

也可以通過進程停止nginx

查詢nginx主進程號 -- # ps -ef | grep nginx

有序停止 -- # kill -QUIT 主進程號

快速停止 -- # kill -TERM 主進程號

強制停止 -- # pkill -9 nginx

平滑啟動 -- # kill -HUP 主進程號

 

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM