博客的服务器进行迁移,迁移过程中的各种问题这里记录一下

迁移步骤

  1. 原服务器mysql数据库dump,html打tar包
  2. 将dump文件,tar包到新的服务器上。 这里遇到一个问题
    ftp不能写,错误原因 ,/etc/vsftpd.conf 写权限没有开
    #Uncomment this to enable any form of FTP write command.
    write_enable=YES
    重启
    sudo /etc/init.d/vsftpd restart
  3. 在新服务器上安装nginx,myql,php等。这里遇到一个问题
    connect() to unix:/var/run/php/php7.0-fpm.sock failed (13: Permission denied) while connecting to upstream,
    这里默认的php用www-data启动的,需要把nginx的配置文件conf里 user www-data这一行打开,就是用同一个用户启动
    参考 https://stackoverflow.com/questions/23443398/nginx-error-connect-to-php5-fpm-sock-failed-13-permission-denied
  4. 使用lets encrypted 安装证书的时候,因为nginx是自己编译的,需要指定路径
    sudo apt-get update
    sudo apt-get install software-properties-common
    sudo add-apt-repository ppa:certbot/certbot
    sudo apt-get update
    sudo apt-get install python-certbot-nginx
    如果需要制定nginx的路径,需要 –nginx-server-root 制定nginx配置文件的路径
    sudo certbot –nginx-server-root /nginx/conf -d thurstonzk2008.com
    同时 ,修改nginx里的pid的路径
  5. 安装nginx的时候,如果编译的时候没加上ssl的模块,需要补充,可以参考
    https://blog.seosiwei.com/detail/28
  6. 访问wp-admin页面的时候,出现了ERR_TOO_MANY_REDIRECTS
    一开始,以为是重定向的问题,参考
    https://stackoverflow.com/questions/44242267/nginx-wordpress-gives-err-too-many-redirects
    以及在wp-config.php上加了很多内容
define('FORCE_SSL_ADMIN', true);
// in some setups HTTP_X_FORWARDED_PROTO might contain
// a comma-separated list e.g. http,https
// so check for https existence
if (strpos($_SERVER['HTTP_X_FORWARDED_PROTO'], 'https') !== false)
$_SERVER['HTTPS']='on';

define('FORCE_SSL_LOGIN', true);
define('WP_HOME','https://thurstonzk2008.com');
define('WP_SITEURL','https://thurstonzk2008.com');


define('WP_HOME','https://thurstonzk2008.com');
define('WP_SITEURL','https://thurstonzk2008.com');

没有作用,后来发现是
nginx.conf里
location / {
try_files $uri uri//index.php?q=uri//index.php?q=uri&args; #root html; #index index.html index.htm; } 这个开始的时候报错,把uri/这个给删掉了,需要加上,同时需要补充
index index.php index.html index.html;
7. 插件等更新失败的问题
wordpress的文件权限与nginx和php的用户不一致,需要把用户更改成一致的
可以参考 https://www.bibiqiqi.com/archives/13