nginx部署多个vue项⽬的2种⽅法
第⼀种 同⼀个域名或者ip  相同端⼝号 部署多个项⽬
通过斜线访问
先看这2种配置
查nginx 和配置⽂件
whereis nginx
查看配置⽂件
f
user  nginx;
nginx 配置文件worker_processes  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_user [$time_local] "$request" '                      '$status $body_bytes_sent "$http_referer" '
'"$http_user_agent" "$http_x_forwarded_for"';
access_log  /var/log/nginx/access.log  main;
sendfile        on;
#tcp_nopush    on;
keepalive_timeout  65;
#gzip  on;
include /etc/nginx/conf.d/*.conf;
}
这个只是基本配置信息
include /etc/nginx/conf.d/*.conf;
查这个⽬录下所有配置⽂件
server {
listen      80;
server_name  localhost;
#charset 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 server 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 server 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
第⼆种⽅法就是简单的监听不同的端⼝号去实现
去访问
直接看配置⽂件
server {
listen      8088;
server_name  localhost;
#charset 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 server 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 server 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;
#}
}
⽂件⽬录
站点⽂件地址

版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系QQ:729038198,我们将在24小时内删除。