伺服器上部署nginx,部署多個獨立的代碼,用nginx做功能變數名稱映射的配置方法: 2. 在/data/nginx/conf/ 目錄下創建不同的配置文件 3.配置對應的配置文件,以hw.keplermarket.cn.vhost為例 4.放置發佈的代碼到對應的目錄,例如 /data/deploy/hw. ...
伺服器上部署nginx,部署多個獨立的代碼,用nginx做功能變數名稱映射的配置方法:
- 修改/usr/local/nginx/conf/nginx.conf文件,重點是最後一行,include /data/nginx/conf/*vhost;
http { include mime.types; default_type application/octet-stream; log_format main '$remote_addr - $remote_user [$time_local] "$request" ' '$status $body_bytes_sent "$http_referer" ' '"$http_user_agent" "$http_x_forwarded_for"'; access_log logs/access.log main; sendfile on; #tcp_nopush on; #keepalive_timeout 0; keepalive_timeout 65; #gzip on; include /data/nginx/conf/*vhost; }
2. 在/data/nginx/conf/ 目錄下創建不同的配置文件
3.配置對應的配置文件,以hw.keplermarket.cn.vhost為例
server{ listen 80; server_name hw.keplermarket.cn; error_log /data/nginx/logs/hw.keplermarket.cn/error.log; location / { root /data/deploy/hw.keplermarket.cn/; access_log /data/nginx/logs/hw.keplermarket.cn/access.log main; try_files $uri $uri/ /index.html; } }
4.放置發佈的代碼到對應的目錄,例如 /data/deploy/hw.keplermarket.cn/ 下放置相應的代碼