1.安装nginx
https://blog.csdn.net/weixin_42818402/article/details/100572863
2.安装php
https://blog.csdn.net/weixin_42818402/article/details/100572876
3.安装mysql
https://mp.csdn.net/postedit/100572899
4.下载wordpress
- 下载地址https://cn.wordpress.org/download/releases/
- 解压到/root/wp
- 修改/root的进入权限
chmod 555 /root
5.配置nginx
vim /etc/nginx/nginx.conf
server{
...
root /root/wp;
index index.php index.html
...
# PHP配置
location ~ \.php$ {
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi_params;
}
...
}
6. 配置wordpress
- 启动nginx,mysql,php-fpm
- 打开首页,输入提示的信息后得到wp-config配置文件
- 创建wp-config.php并添加
# 这样配置不需要FTP
define("FS_METHOD", "direct");
define("FS_CHMOD_DIR", 0777);
define("FS_CHMOD_FILE", 0777);
- 修改文件夹权限
chmod 777 -R wp-content
chmod 777 -R wp-admin
chmod 777 -R wp-includes
7.解决上传文件大小限制
vim /etc/php.ini
upload_max_filesize = 64M
post_max_size = 64M
max_execution_time = 3600
vim /etc/nginx/nginx.conf
server{
…
client_max_body_size 64m;
}
8.配置HTTPS
- 修改配置
server {
listen 80;
server_name 域名;
# 强制跳转https
rewrite ^(.*) https://$server_name$1 permanent;
}
server {
listen 443 ssl;
server_name 域名;
root /root/wp;
index index.php index.html;
ssl_certificate "/root/cert/域名.pem";
ssl_certificate_key "/root/cert/域名.key";
ssl_session_cache shared:SSL:1m;
ssl_session_timeout 10m;
ssl_ciphers HIGH:!aNULL:!MD5;
ssl_prefer_server_ciphers on;
client_max_body_size 64m;
# Load configuration files for the default server block.
include /etc/nginx/default.d/*.conf;
# PHP配置
location ~ \.php(.*)$ {
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
fastcgi_split_path_info ^((?U).+\.php)(/?.+)$;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
fastcgi_param PATH_INFO $fastcgi_path_info;
fastcgi_param PATH_TRANSLATED $document_root$fastcgi_path_info;
include fastcgi_params;
}
}