nginx 下載地址在 http://nginx.org/download/nginx
首先下載nginx包 bash
wget http://nginx.org/download/nginx-1.13.2.tar.gz 我這邊下載的是1..13.2ui
下載完成後解壓 tar -zxvf nginx-1.13.2.tar.gzcode
執行./configure 不過這部報錯 blog
./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.進程
表示須要安裝pcre包。ssl
你可能還須要安裝
sudo apt-get install openssl libssl-devget
執行 ./configure --with-http_ssl_module openssl
正常狀況顯示 it
Configuration summary
+ using system PCRE library
+ using system OpenSSL library
+ using system zlib library
nginx path prefix: "/usr/local/nginx"
nginx binary file: "/usr/local/nginx/sbin/nginx"
nginx modules path: "/usr/local/nginx/modules"
nginx configuration prefix: "/usr/local/nginx/conf"
nginx configuration file: "/usr/local/nginx/conf/nginx.conf"
nginx pid file: "/usr/local/nginx/logs/nginx.pid"
nginx error log file: "/usr/local/nginx/logs/error.log"
nginx http access log file: "/usr/local/nginx/logs/access.log"
nginx http client request body temporary files: "client_body_temp"
nginx http proxy temporary files: "proxy_temp"
nginx http fastcgi temporary files: "fastcgi_temp"
nginx http uwsgi temporary files: "uwsgi_temp"
nginx http scgi temporary files: "scgi_temp"
執行make
make install
修改
(1)在線安裝的啓動過程
$sudo /etc/init.d/nginx start
(2)源代碼安裝的啓動過程
$cd /usr/local/nginx
$sbin/nginx
而後就能夠訪問了,http://localhost/ , 一切正常!若是不能訪問,先不要繼續,看看是什麼緣由,
2、重啓
更改配置重啓nginx
kill -HUP 主進程號或進程號文件路徑 或者使用 cd /usr/local/nginx/sbin ./nginx -s reload
判斷配置文件是否正確
nginx -t -c /usr/local/nginx/conf/nginx.conf 或者 cd /usr/local/nginx/sbin ./nginx -t
查詢nginx主進程號
ps -ef | grep nginx
從容中止 kill -QUIT 主進程號
快速中止 kill -TERM 主進程號
強制中止 kill -9 nginx
若nginx.conf配置了pid文件路徑,若是沒有,則在logs目錄下
kill -信號類型 '/usr/local/nginx/logs/nginx.pid'