前端nginx部署方案(参考)
安装nginx
Ubuntu
sudo apt-get install nginx
安装好的文件位置:
/usr/sbin/nginx:主程序
/etc/nginx:存放配置文件
/usr/share/nginx:存放静态文件
/var/log/nginx:存放日志
在/etc/nginx/nginx.conf文件中新增一行,如图:


在conf下面创建一个vhost目录
进入vhost目录
上传www.your.com_web_80.conf,其中,把your替换成你自己的名字
替换图中内容,其中,/data/www/ 是代码路径,将图中名称替换为你自己的名称
service nginx {start|stop|restart|reload|force-reload|status|configtest|rotate|upgrade}
命令启动。
systemctl status nginx
查看状态
附
nginx.conf文件
#user www;
worker_processes 3;
#error_log logs/error.log;
#error_log logs/error.log notice;
#error_log logs/error.log info;
#pid logs/nginx.pid;
worker_rlimit_nofile 65535;
events {
use epoll;
worker_connections 65535;
}
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;
tcp_nodelay on;
server_tokens off;
client_max_body_size 30m;
keepalive_timeout 60;
fastcgi_connect_timeout 300;
fastcgi_send_timeout 300;
fastcgi_read_timeout 300;
fastcgi_buffer_size 64k;
fastcgi_buffers 4 64k;
fastcgi_busy_buffers_size 128k;
fastcgi_temp_file_write_size 128k;
fastcgi_intercept_errors on;
gzip on;
#gzip_static on;
gzip_proxied any;
gzip_comp_level 5;
gzip_min_length 1024;
gzip_vary on;
gzip_buffers 4 8k;
gzip_http_version 1.1;
gzip_types text/plain text/css application/x-javascript. text/xml application/xml application/xml+rss text/javascript;
include vhost/*.conf;
}
www.your.com_web_80.conf 文件
server
{
listen 80;
server_name www.your.com;
index index.html index.htm index.php index.jsp;
access_log /data/program/nginx/logs/$server_name.access.log;
location / {
root /data/www/zl_website/;
try_files $uri /index.html
index index.html index.htm;
}
}
验证nginx启动成功,访问nginx所在的ip即可,会出现nginx首页
nginx首页访问失败 404
1.检查配置文件,是否全部按照文档部署
2.检查nginx权限,参考
https://www.cnblogs.com/xiaohuiduan/p/9867656.html
[rihide]获客文章nginx配置方案
server {
listen 80;
#listen [::]:80;
server_name weixin.yiliit.com
index index.html index.htm;
#文章映射路径
root /usr/share/nginx/html/dynamic;
error_page 404 /404.html;
location =/404.html {
root /usr/share/nginx/html;
}
location ~ .*\.(gif|jpg|jpeg|png|bmp|swf)$ {
expires 30d;
}
location ~ .*\.(js|css)?$ {
expires 12h;
}
location ~ /.well-known {
allow all;
}
location ~ /\. {
deny all;
}
#后端服务api,如果配置了跨域问题可以直接使用api.youdomain.com访问
location /wechatApi {
proxy_pass https://api.yiliit.com/wechatApi;
proxy_redirect default ;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header REMOTE-HOST $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
}
location /crmApi {
proxy_pass https://api.yiliit.com/crmApi;
proxy_redirect default ;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header REMOTE-HOST $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
}
server_tokens off;
sendfile off;
access_log /var/log/crm.com_access.log;
}
微信校验文件访问nginx方案: 将微信校验文件放在/home/resource/下,nginx配置如下:
server {
listen 80;
server_name wx.yiliit.com;
root /home/resource/;
index index.html;
location / {
}
error_page 404 /404.html;
location = /40x.html {
}
error_page 500 502 503 504 /50x.html;
location = /50x.html {
}
}
[/rihide]
© 版权声明
文章版权归作者所有,未经允许请勿转载。
相关文章
暂无评论...