作業環境: Centos 7
- 安裝 nginx
- 添加CentOS 7 Nginx yum资源库
- rpm -Uvh http://nginx.org/packages/centos/7/noarch/RPMS/nginx-release-centos-7-0.el7.ngx.noarch.rpm
- 安裝
- yum install nginx
- 配置nginx
- mkdir -p /etc/nginx/config.d
- vim /etc/nginx/nginx.conf #編輯如下
........................
http { include /etc/nginx/conf.d/*.conf; #Nginx設定檔包含config.d的所有conf檔
.......................
.......................
- Nginx 設定專案的 conf
- vim /etc/nginx/config.d/<proj>.conf
listen 80;
server_name unapy.test.com; #對外的Url
location / {
proxy_pass http://127.0.0.1:5000; #對應內網的Url
}
}
- 啟動 Nginx
- service nginx start
- 停止 Nginx
- service nginx stop
- 設定開機自動啟動 Setting reboot auto start Nginx
- chkconfig nginx onchkconfig nginx on
- #顯示Note: Forwarding request to 'systemctl enable nginx.service'.
- 出現502錯誤,關閉 selinux
- sudo vim /etc/sysconfig/selinux
sudo vim /etc/sysconfig/selinux
如果不是使用yum安裝,需自行設定配置檔
請參考其他網站教學
相關參考
留言
張貼留言