安装php以及所有wordpress需要的扩展
apt install php-cli php-fpm php-mysql php-json php-opcache php-mbstring php-xml php-gd php-curl
配置nginx
server {
listen 443 ssl;
listen [::]:443 ssl;
root /var/www/wordpress;
server_name example.com; # substitute your machine's IP address or FQDN
index index.php index.html index.htm;
ssl_certificate /etc/nginx/ssl/fullchain.cer;
ssl_certificate_key /etc/nginx/ssl/example.com.key;
location ~ \.php$ {
include /etc/nginx/fastcgi.conf;
fastcgi_pass unix:/run/php/php8.1-fpm.sock; #这里具体看看你的是什么版本的
}
#伪静态
location / {
try_files $uri $uri/ /index.php?$args;
}
rewrite /wp-admin$ $scheme://$host$uri/ permanent;
#缓存
location ~* \.(js|css|png|jpg|jpeg|gif|ico|svg)$ {
expires max;
log_not_found off;
}
}
server {
listen 80;
listen [::]:80;
server_name example.com;
return 301 https://$server_name$request_uri;
}
授予访问权限(nginx和php是以www-data用户和组的形式运行的)
chown -R www-data:/var/www/wordpress
重载nginx配置,重启nginx和php
nginx -s reload
systemctl restart nginx
systemctl restart php8.1-fpm
Comments | NOTHING