安装
官方安装指导 https://wordpress.org/support/article/how-to-install-wordpress/
简单教程 https://www.wpdaxue.com/how-to-install-wordpress.html
相对路径部署
WordPress配置
https://wordpress.org/support/article/changing-the-site-url/
https://help.dreamhost.com/hc/en-us/articles/214580498-How-do-I-change-the-WordPress-Site-URL-
https://www.wpbeginner.com/wp-tutorials/how-to-change-your-wordpress-site-urls-step-by-step/#wpconfigfile
- The “Site Address (URL)” setting is the address you want people to type in their browser to reach your WordPress blog.
- The “WordPress Address (URL)” setting is the address where your WordPress core files reside.
```shell
wp_config.php 中添加:
define( ‘WP_HOME’, ‘http://geekz.online/blog/‘ ); define( ‘WP_SITEURL’, ‘http://geekz.online/blog/‘ );
**nginx配置**
```shell
# 这个匹配似乎有问题? 见: https://www.cnblogs.com/52fhy/p/5054507.html
location /blog/ {
root /usr/share/nginx/html;
index index.html index.php;
if (-f $request_filename/index.html){
rewrite (.*) $1/index.html break;
}
if (-f $request_filename/index.php){
rewrite (.*) $1/index.php;
}
if (!-f $request_filename){
rewrite (.*) $1/index.php;
}
}
location ~ \.php$ {
root /usr/share/nginx/html;
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi_params;
}
location /blog/ {
index index.html index.php;
if (-f $request_filename) {
break;
}
if (!-f $request_filename){
rewrite (.*) $1/index.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;
}
调试
开启WordPress的调试信息
# wp_config.php 中添加
ini_set('log_errors','On');
ini_set('display_errors','On');
ini_set('error_reporting', E_ALL );
define('WP_DEBUG', true);
define('WP_DEBUG_LOG', true);
define('WP_DEBUG_DISPLAY', true);
报错解决
PHP Primary script unknown
https://segmentfault.com/a/1190000017789890
https://blog.zengrong.net/post/primary-script-unknown-on-macos/
原因只有两个,一个是php-fpm找不到php文件,一个是php-fpm没有权限读取和执行文件
nginx调试信息
# nginx.conf 中 server 域内添加
log_format scripts '$document_root$fastcgi_script_name > $request';
access_log /usr/local/var/log/nginx/scripts.log scripts;
您的 PHP 似乎没有安装运行 WordPress 所必需的 MySQL 扩展
http://2233426.blog.51cto.com/2223426/1264128
yum install php-mysql
mysql_connect(): No such file or directory
# define( 'DB_HOST', 'localhost' ); 改为:
define( 'DB_HOST', '127.0.0.1' );
文章链接404
https://codex.wordpress.org/Using_Permalinks
上传的文件尺寸超过php.ini中定义的upload_max_filesize值
1、一般来说VPS服务器的话,就是找到php.ini这个文件,然后修改里面几个参数即可。php.ini的路径的话,大家可以通过命令:find / -name php.ini 来找到php.ini的路径
2、找到php.ini这个文件后,
3、在线、或者使用文本、sublime Text等程序打开,
4、搜索upload_max_filesize 和post_max_size,改一下文件上传最大限制,比如都改为20M,
5、然后保存,重启一下apache服务。
service httpd start # 启动
service httpd restart # 重新启动
service httpd stop # 停止服务
升级需要FTP
假设你的wordpress安装目录为/home/wwwroot/lnmp.org
lnmp的情况: chown -R ww:www
/home/wwwroot/lnmp.org
apache的情况: chown -R apache:root /usr/share/wordpress
另外可能 还需要修改下Wordpress的配置文件,wp-config.php,加入这么一行:define('FS_METHOD', "direct");
主题
知更鸟
http://songxiongfeng.com/282.html
迁移
https://zhuanlan.zhihu.com/p/50803437