1

thlm | 主站的搭建

 1 month ago
source link: https://benpaodewoniu.github.io/2024/03/24/thlm1/
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.

主站需要的主要是

  • nginx
  • wordpress
  • php7.4
  • mysql8

wordpress

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

mysql

php7.4

nginx

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

wordpress.conf 的内容是

upstream php {
server unix:/run/php/php7.4-fpm.sock;
}


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

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

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

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

location /lumi/Extend {
alias /var/www/wordpress/Extend/;
}

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

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

location ~ \.php$ {
include fastcgi_params;
fastcgi_intercept_errors on;
fastcgi_pass php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
}

location ~* \.(js|css|png|jpg|jpeg|gif|ico)$ {
expires max;
log_not_found on;
}
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"){
}
rewrite ^/([_0-9a-zA-Z-]+/)?(wp-(content|admin|includes).*) /$2 last;
rewrite ^/([_0-9a-zA-Z-]+/)?(.*.php)$ /$2 last;
rewrite ^/(?!lumi/Extend|Static)(.*)$ /index.php?$1 last;
}

About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK