Nginx編譯安裝、ssl、rewrite

一、安裝環境


Nginx編譯安裝、ssl、rewrite


Nginx下載地址:nginx
zlib下載頁面:zlib
pcre下載頁面:pcre


二、編譯安裝:
#useradd nginx -s /sbin/nologin
#yum install gcc-c++ -y
#./configure --prefix=/usr/local/nginx --with-http_ssl_module --with-http_stub_status_module --user=nginx --group=nginx --with-pcre=/opt/pcre-8.42 --with-zlib=/opt/zlib-1.2.11 --with-http_geoip_module --with-http_gzip_static_module --with-http_flv_module --with-http_mp4_module
#make && make install


三、啓動腳本(/lib/systemd/system/nginx.service)
[Unit]
Description=The NGINX HTTP and reverse proxy server
After=syslog.target network.target remote-fs.target nss-lookup.target

[Service]
Type=forking
PIDFile=/usr/local/nginx/logs/nginx.pid
ExecStartPre=/usr/local/nginx/sbin/nginx -t
ExecStart=/usr/local/nginx/sbin/nginx
ExecReload=/bin/kill -s HUP $MAINPID
ExecStop=/bin/kill -s QUIT $MAINPID
PrivateTmp=true

[Install]
WantedBy=multi-user.target


四、啓動服務:
systemctl enable nginx
systemctl start nginx
systemctl reload nginx
systemctl restart nginx
五、配置ssl
Nginx編譯安裝、ssl、rewrite
六、http跳轉https
Nginx編譯安裝、ssl、rewrite
七、其他配置
Nginx編譯安裝、ssl、rewrite

注:
nginx中root與alias指令之間的區別:
root和alias都可以定義在location模塊中,都是用來指定請求資源的真實路徑,例如:
root指令
location /c/ {
root /a/b;
}

訪問http://www.liheng1815.xyz/a/index.html ------------>真實資源路徑:/a/b/c/index.html
真實的路徑是root指定的值加上location制動的值。

alias指令
alias正如其名,是location的路徑別名,不管location怎麼寫,資源的真實路徑都是alias指定的路徑,例如:
location /c/ {
alias /a/b/;
}

訪問http://www.liheng1815.xyz/a/index.html ------------>真實資源路徑:/a/b/index.html

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章