- 安装WordPress安装包,解压缩,安装到指定位置
- 安装php环境:
- 下载:sudo yum install php php-fpm php-mysqlnd
- 安装:sudo systemctl start php-fpmsudo systemctl enable php-fpm
- 检测:php -v
- 查询状态:systemctl status php-fpm.service
- 编写你的wordpress的nginx配置文件,注意wordpress文件路径和php处理器安装位置
server {
listen 8080;
server_name tanyh.com.cn www.tanyh.com.cn; # 替换为你的域名
root /var/www/html; # WordPress 的安装目录
index index.php index.html index.htm;
# 日志文件
access_log /var/log/nginx/wordpress_access.log;
error_log /var/log/nginx/wordpress_error.log;
# 处理 WordPress 静态文件
location / {
try_files $uri $uri/ /index.php?$args;
}
# 处理 PHP 文件
location ~ \.php$ {
include snippets/fastcgi-php.conf;
fastcgi_pass unix:/run/php-fpm/www.sock; # 根据你的 PHP 版本调整找到你的php处理器位置
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi_params;
}
# 禁止访问隐藏文件,如 .htaccess
location ~ /\. {
deny all;
}
# 设置文件上传大小限制(可选)
client_max_body_size 64m;
}