安装

官方安装指导 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/‘ );

  1. **nginx配置**
  2. ```shell
  3. # 这个匹配似乎有问题? 见: https://www.cnblogs.com/52fhy/p/5054507.html
  4. location /blog/ {
  5. root /usr/share/nginx/html;
  6. index index.html index.php;
  7. if (-f $request_filename/index.html){
  8. rewrite (.*) $1/index.html break;
  9. }
  10. if (-f $request_filename/index.php){
  11. rewrite (.*) $1/index.php;
  12. }
  13. if (!-f $request_filename){
  14. rewrite (.*) $1/index.php;
  15. }
  16. }
  17. location ~ \.php$ {
  18. root /usr/share/nginx/html;
  19. fastcgi_pass 127.0.0.1:9000;
  20. fastcgi_index index.php;
  21. fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
  22. include fastcgi_params;
  23. }
  1. location /blog/ {
  2. index index.html index.php;
  3. if (-f $request_filename) {
  4. break;
  5. }
  6. if (!-f $request_filename){
  7. rewrite (.*) $1/index.php;
  8. }
  9. }
  10. location ~ \.php$ {
  11. fastcgi_pass 127.0.0.1:9000;
  12. fastcgi_index index.php;
  13. fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
  14. include fastcgi_params;
  15. }

调试

开启WordPress的调试信息

  1. # wp_config.php 中添加
  2. ini_set('log_errors','On');
  3. ini_set('display_errors','On');
  4. ini_set('error_reporting', E_ALL );
  5. define('WP_DEBUG', true);
  6. define('WP_DEBUG_LOG', true);
  7. 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调试信息

  1. # nginx.conf 中 server 域内添加
  2. log_format scripts '$document_root$fastcgi_script_name > $request';
  3. access_log /usr/local/var/log/nginx/scripts.log scripts;

image.png

您的 PHP 似乎没有安装运行 WordPress 所必需的 MySQL 扩展

http://2233426.blog.51cto.com/2223426/1264128
yum install php-mysql

mysql_connect(): No such file or directory

  1. # define( 'DB_HOST', 'localhost' ); 改为:
  2. 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服务。

  1. service httpd start # 启动
  2. service httpd restart # 重新启动
  3. 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