nginx部署多个vue项⽬的2种⽅法
第⼀种 同⼀个域名或者ip 相同端⼝号 部署多个项⽬
通过斜线访问
先看这2种配置
查找nginx 和配置⽂件
whereis nginx
查看配置⽂件
f崆峒古镇
ur nginx;
worker_process 1;
error_log /var/log/nginx/error.log warn;
pid /var/run/nginx.pid;
events {
worker_connections 1024;
}
http {
include /etc/pes;
default_type application/octet-stream;
log_format main '$remote_addr - $remote_ur [$time_local] "$request" ' '$status $body_bytes_nt "$http_referer" '
'"$http_ur_agent" "$http_x_forwarded_for"';
access_log /var/log/nginx/access.log main;
ndfile on;
#tcp_nopush on;
keepalive_timeout 65;
#gzip on;
include /etc/nginx/conf.d/*.conf;
}
这个只是基本配置信息
include /etc/nginx/conf.d/*.conf;
查找这个⽬录下所有配置⽂件
云南香格里拉旅游rver {内分泌检查
listen 80;
rver_name localhost;
#chart koi8-r;
#access_log /var/log/nginx/host.access.log main;
#第⼀种⽅法这个直接/访问
location / {
root /usr/share/nginx/html;红星闪耀中华
index index.html index.htm;
}
#根/student 访问指向地点
location /student {
接待流程及标准alias /usr/share/nginx/student;
index index.html index.htm;
}
#error_page 404 /404.html;
# redirect rver error pages to the static page /50x.html
#
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root /usr/share/nginx/html;
}
# proxy the PHP scripts to Apache listening on 127.0.0.1:80
#
#location ~ \.php$ {
# proxy_pass 127.0.0.1;
#}
# pass the PHP scripts to FastCGI rver listening on 127.0.0.1:9000 #
#location ~ \.php$ {
# root html;
# fastcgi_pass 127.0.0.1:9000;
# fastcgi_index index.php;
# fastcgi_param SCRIPT_FILENAME /scripts$fastcgi_script_name; # include fastcgi_params;
#}
# deny access to .htaccess files, if Apache's document root
# concurs with nginx's one
#
#location ~ /\.ht {
# deny all;
#}
}
重启nginx服务
nginx -s reload
第⼆种⽅法就是简单的监听不同的端⼝号去实现
去访问
直接看配置⽂件
rver {
listen 8088;
rver_name localhost;
#chart koi8-r;黄鹤楼传说>支付宝余额宝利息
#access_log /var/log/nginx/host.access.log main;
location / {
root /usr/share/nginx/student;
index index.html index.htm;
}
#error_page 404 /404.html;
# redirect rver error pages to the static page /50x.html
#
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root /usr/share/nginx/html;
}
# proxy the PHP scripts to Apache listening on 127.0.0.1:80
#
#location ~ \.php$ {
# proxy_pass 127.0.0.1;
#}
# pass the PHP scripts to FastCGI rver listening on 127.0.0.1:9000 #
#location ~ \.php$ {
# root html;
钟表图
# fastcgi_pass 127.0.0.1:9000;
# fastcgi_index index.php;
# fastcgi_param SCRIPT_FILENAME /scripts$fastcgi_script_name; # include fastcgi_params;
#}
# deny access to .htaccess files, if Apache's document root
# concurs with nginx's one
#
#location ~ /\.ht {
# deny all;
#}
}
⽂件⽬录
站点⽂件地址