0%

thlm | 主站的搭建

主站需要的主要是

  • nginx
  • wordpress
  • php7.4
  • mysql8

wordpress

主要参考

我将 https 的相关证书放在了 ~/https

mysql

php7.4

nginx

我在 site-available 创建了 wordpress.conf,另外将 default 给删除了,关于配置请参考

wordpress.conf 的内容是

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
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
# Upstream to abstract backend connection(s) for php
upstream php {
server unix:/run/php/php7.4-fpm.sock;
}


server {
listen 80;
server_name thlm.com;
listen 443 ssl default_server;
listen [::]:443 ssl default_server;#新增这两个
ssl_certificate /home/ubuntu/httpAll/fullchain.crt;
ssl_certificate_key /home/ubuntu/httpAll/private.pem;

root /var/www/wordpress; # wordpress 的放置路径
index index.php;

location = /favicon.ico {
log_not_found off;
access_log off;
}

location /Static/lumi {
alias /var/www/wordpress/Static/lumi;
index index.html;
try_files $uri $uri/ /Static/lumi/index.html;
}

location = /robots.txt {
allow all;
log_not_found off;
access_log off;
}

#location /Extend {
# alias /var/www/wordpress/Extend/;
#}
location /lumi {
alias /var/www/wordpress/Static/tmp;
index lumi.html;
try_files $uri $uri/ /lumi/lumi.html;
}

location / {
try_files $uri $uri/ /index.php?$args;
}

location ~* ^/xmlrpc.php$ {
return 403;
}

#location /lumi{
# return 301 https://lumi.thlm.com;
#}

location ~ \.php$ {
#NOTE: You should have "cgi.fix_pathinfo = 0;" in php.ini
include fastcgi_params;
fastcgi_intercept_errors on;
fastcgi_pass php;
#The following parameter can be also included in fastcgi_params file
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
}

location ~* \.(js|css|png|jpg|jpeg|gif|ico)$ {
expires max;
log_not_found on;
}
#ignored: “-” thing used or unknown variable in regex/rew
rewrite ^/([_0-9a-zA-Z-]+/)?wp-admin$ /$1wp-admin/ permanent;

if (-f $request_filename){
set $rule_2 1;
}
if (-d $request_filename){
set $rule_2 1;
}
if ($rule_2 = "1"){
#ignored: “-” thing used or unknown variable in regex/rew
}
rewrite ^/([_0-9a-zA-Z-]+/)?(wp-(content|admin|includes).*) /$2 last;
rewrite ^/([_0-9a-zA-Z-]+/)?(.*.php)$ /$2 last;
#rewrite /. /index.php last;
rewrite ^/(?!Extend|Static|lumi|icon)(.*)$ /index.php?$1 last;
}

server {
listen 80;
server_name dao.thlm.com;
listen 443 ssl;
listen [::]:443 ssl;#新增这两个
ssl_certificate /home/ubuntu/httpAll/fullchain.crt;
ssl_certificate_key /home/ubuntu/httpAll/private.pem;
root /var/www/wordpress/Static/thlm/;

# rewrite ^(.*)$ https://$host$1 permanent;

location / {
try_files $uri $uri/ /index.php?$args;
index index.php;
}

location ~* ^/xmlrpc.php$ {
return 403;
}

location /thlmholder {
alias /var/www/wordpress/Static/html/thlmholder;
index index.html;
}

location ~ \.php$ {
include fastcgi_params;
fastcgi_intercept_errors on;
fastcgi_pass php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
}
}
server {
listen 80;
server_name mp.thlm.com;
listen 443 ssl;
listen [::]:443 ssl;#新增这两个
ssl_certificate /home/ubuntu/httpAll/fullchain.crt;
ssl_certificate_key /home/ubuntu/httpAll/private.pem;
root /var/www/wordpress/Static/thlmadmin/;

# rewrite ^(.*)$ https://$host$1 permanent;

location / {
try_files $uri $uri/ /index.php?$args;
index index.php;
}

location ~ \.php$ {
include fastcgi_params;
fastcgi_intercept_errors on;
fastcgi_pass php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
}
}
请我喝杯咖啡吧~