nginx部署

基于腾讯云服务器centos系统:

云服务登录用户名:urz9g98m
云服务登录密码:********

nginx配置文件

基于宝塔可视化面板

1.登录云服务进入首页、进入nginx

宝塔面板nginx

2.进行配置文件修改

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
user  www www;
worker_processes auto;
error_log /www/wwwlogs/nginx_error.log crit;
pid /www/server/nginx/logs/nginx.pid;
worker_rlimit_nofile 51200;

events
{
use epoll;
worker_connections 51200;
multi_accept on;
}

http
{
include mime.types;
#include luawaf.conf;

include proxy.conf;

default_type application/octet-stream;

server_names_hash_bucket_size 512;
client_header_buffer_size 32k;
large_client_header_buffers 4 32k;
client_max_body_size 50m;

sendfile on;
tcp_nopush on;

keepalive_timeout 60;

tcp_nodelay on;

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 256k;
fastcgi_intercept_errors on;

gzip on;
gzip_min_length 1k;
gzip_buffers 4 16k;
gzip_http_version 1.1;
gzip_comp_level 2;
gzip_types text/plain application/javascript application/x-javascript text/javascript text/css application/xml;
gzip_vary on;
gzip_proxied expired no-cache no-store private auth;
gzip_disable "MSIE [1-6]\.";

limit_conn_zone $binary_remote_addr zone=perip:10m;
limit_conn_zone $server_name zone=perserver:10m;

server_tokens off;
access_log off;

server
{
listen 80;
server_name localhost;
index index.html index.htm index.php;
root /www/server/phpmyadmin;
location \\x7e /tmp/ {
return 403;
}

#error_page 404 /404.html;
include enable-php.conf;

location / {
proxy_pass http://localhost:8666;
}

location \x7e .*\.(gif|jpg|jpeg|png|bmp|swf)$
{
expires 30d;
}

location ~ .*\.(js|css)?$
{
expires 12h;
}

location ~ /\.
{
deny all;
}

access_log /www/wwwlogs/access.log;
}

include /www/server/panel/vhost/nginx/*.conf;
}

基于文件夹寻找nginx存储的文件夹命名

上述nginx配置文件中,可以包含某个文件夹所有的conf文件,所以可以根据不同的部署项目进行区分,防止一个文件过于耦合。

nginx文件夹默认的存储位置为:/www/server/panel/vhost/nginx

nginx配置文件

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
server {
listen 82;
location / {
root /www/wwwroot/element-plus/doc-archive-main; # 将 /www/wwwroot/element-plus/doc-archive-main 替换为您部署文档静态资源的目录
index index.html;
}

}
server {
listen 84;
location / {
root /www/wwwroot/hexo-new/public; # 将 /www/wwwroot/hexo-new/public 替换为您部署文档静态资源的目录
index index.html;
}

}


松耦合的配置方式

正常情况下,应该是区分成 element-plus.conf , hexo-new.conf, 此处文件比较简单,暂时未分开。
整合起来的conf文件

重启nginx,项目依然可以正常运行

nginx部署element-plus