Centos安装、配置nginx
                                                            生活随笔
收集整理的這篇文章主要介紹了
                                Centos安装、配置nginx
小編覺得挺不錯的,現在分享給大家,幫大家做個參考.                        
                                參考 https://www.cnblogs.com/jeffhong99/p/11362361.html
安裝nginx
[root@localhost~]# yum -y install nginx安裝成功后nginx的幾個默認目錄
[root@localhost~]# whereis nginx 執行目錄:/usr/sbin/nginx 模塊所在目錄:/usr/lib64/nginx/modules 配置所在目錄:/etc/nginx/ 默認站點目錄:/usr/share/nginx/html主要配置文件:/etc/nginx/nginx.conf PID目錄:/var/run/nginx.pid 錯誤日志:/var/log/nginx/error.log 訪問日志:/var/log/nginx/access.lognginx服務相關命令
[root@localhost~]# systemctl start nginx.service [root@localhost~]# systemctl stop nginx.service [root@localhost~]# systemctl reload nginx.service [root@localhost~]# systemctl restart nginx.service [root@localhost~]# systemctl status nginx.service // 設置開機自啟動 [root@localhost~]# systemctl enable nginx // 查看版本 [root@localhost~]# nginx -V // 檢查nginx配置文件 [root@localhost~]# nginx -t配置nginx
1、簡單網站映射
server {listen 80;server_name english.starlemon.pro;location / {root /usr/share/nginx/pro.starlemon.english;index index.html;} }2、多域名映射到不同端口
server {listen 80;server_name api.english.starlemon.pro;location / {proxy_pass http://127.0.0.1:2012;} }3、配置https
參考阿里云:在Nginx或Tengine服務器上安裝證書
server{listen 443 ssl;server_name english.starlemon.pro;ssl_certificate /etc/nginx/cert/3262481_english.starlemon.pro.pem;ssl_certificate_key /etc/nginx/cert/3262481_english.starlemon.pro.key;ssl_session_timeout 5m;ssl_protocols TLSv1 TLSv1.1 TLSv1.2; ssl_ciphers ECDHE-RSA-AES128-GCM-SHA256:ECDHE:ECDH:AES:HIGH:!NULL:!aNULL:!MD5:!ADH:!RC4; ssl_prefer_server_ciphers on;location / {root /usr/share/nginx/pro.starlemon.english;index index.html index.htm;} }4、http轉https
server {listen 80;server_name english.starlemon.pro;rewrite ^(.*)$ https://english.starlemon.pro permanent; } 與50位技術專家面對面20年技術見證,附贈技術全景圖總結
以上是生活随笔為你收集整理的Centos安装、配置nginx的全部內容,希望文章能夠幫你解決所遇到的問題。
 
                            
                        - 上一篇: WebStorm开发微信小程序:解决在w
- 下一篇: CentOS压缩命令zip
