WordPress搬迁

搜到的教程全都是用phpmyadmin的,简直无力吐槽。

1、打包整个网站

tar -czvf filename filepath

2、导出整个数据库表,建议使用root用户以规避权限问题。

mysqldump -u username -p password -h hostname database_name > output_file.sql

3、解压并修改根目录权限

tar -xf
chown www-data:www-data -R /path/dir

4、创建数据库

CREATE DATABASE databasename CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci;
CREATE USER "username"@"hostname" IDENTIFIED BY "password";
GRANT ALL PRIVILEGES ON databasename.* TO "username"@"hostname";
FLUSH PRIVILEGES;  

5、导入数据,同样建议使用root用户。

mysql -u your_username -p -h your_host -P your_port -D your_database < output_file.sql

7、创建apache2配置

<VirtualHost *:80>
   ServerName web.site
   Redirect permanent / https://web.site/
</VirtualHost>

<VirtualHost *:443>
  DocumentRoot /var/www/wordpress/
  ServerName web.site

  SSLEngine on
  SSLCertificateFile /etc/ssl/web/web.site.crt
  SSLCertificateKeyFile /etc/ssl/web/web.site.key
  SSLCertificateChainFile /etc/ssl/word/root_bundle.crt

  <Directory /var/www/wordpress/>
    Require all granted
    AllowOverride All
    Options FollowSymLinks MultiViews
  </Directory>

</VirtualHost>

8、安装依赖

apt update & apt upgrade
apt install apache2 php mysql-server php-mysql redis-server php-redis php-curl php-dom php-imagick php-mbstring php-zip php-gd php-intl

9、启用模块

a2enmod ssl rewrite

10、重载网站

systemctl restart apache2