Migration einer WordPress Instanz zu einen neuen Host

Eine neu leere WordPressinstallation am Zielhost vorbereiten

Pakete installieren


apt install mariadb-client mariadb-server

apt install php7.0 php7.0-mysql

apt install apache2 libapache2-mod-php7.0

Datenbank vorbereiten


mysql -u root

Datenbank für WordPress und DB User anlegen
(wpuser und userpassword entsprechend anpassen)

MariaDB [(none)]> CREATE USER ‚wpuser’@’localhost‘ IDENTIFIED BY ‚userpassword‘;
MariaDB [(none)]> CREATE DATABASE wp_database;
MariaDB [(none)]> GRANT ALL ON `wp_database`.* TO `wpuser`@`localhost`;
MariaDB [(none)]> FLUSH PRIVILEGES;
MariaDB [(none)]> exit;

WordPress installieren

Achtung hierbei werden alle Seiten unter /var/www/html gelöscht (debian default Seite, alte Installationen, andere Webseiten usw.)

cd /tmp
wget https://wordpress.org/latest.tar.gz
tar xpf latest.tar.gz

rm -rf /var/www/html
cp -r /tmp/wordpress /var/www/html
chown -R www-data:www-data /var/www/html
find /var/www/html -type d -exec chmod 750 {} \;
find /var/www/html -type f -exec chmod 640 {} \;

Apache am neuen Host vorbereiten (debian)

mod_rewrite aktivieren

Mod_rewrite ist bei eine debian standard Apache2 Installation schon installiert aber nicht aktiviert.

Als root a2enmod rewrite ausführen. danach mittels systemctl restart apache2.service den Webserver neu starten.


a2enmod rewrite

systemctl restart apache2.service

systemctl status apache2.service

Apache2 soll die .htaccess einlesen beachten

Bei neueren Debian Installationen kann dies gleich in /etc/apache2/apache2.conf geschehen
Vorausgestzt wordpress ist direkt in /var/www/html installiert


# Sets the default security model of the Apache2 HTTPD server. It does
# not allow access to the root filesystem outside of /usr/share and /var/www.
# The former is used by web applications packaged in Debian,
# the latter may be used for local directories served by the web server. If
# your system is serving content from a sub-directory in /srv you must allow
# access here, or in any related virtual host.
<Directory />
Options FollowSymLinks
AllowOverride None
Require all denied
</Directory>

<Directory /usr/share>
AllowOverride None
Require all granted
</Directory>

<Directory /var/www/>
Options Indexes FollowSymLinks
AllowOverride All             #hier von Non auf All ändern
Require all granted
</Directory>

#<Directory /srv/>
#       Options Indexes FollowSymLinks
#       AllowOverride None
#       Require all granted
#</Directory>

Bei älteren Debian Versionen oder wenn WordPress in einem Verzeichniss installiert ist, das mittels eines Virtual Hosts in Apache  eingebunden wird, dann dort unter <Directory> (notfalls einfügen)


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

Default .htaccess (für Permalinks)


cat .htaccess
# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>

all-in-one-wp-migration Plugin Installieren

Dieses Plugin wir auf beiden Hosts installiert

cd /tmp
wget https://downloads.wordpress.org/plugin/all-in-one-wp-migration.6.70.zip
cd /var/www/html/wp-content/plugins/
unzip /tmp/all-in-one-wp-migration.6.70.zip 
chown -R www-data:www-data  all-in-one-wp-migration/
find all-in-one-wp-migration/ -type d -exec chmod 750 {} \;
find all-in-one-wp-migration/ -type f -exec chmod 640 {} \;
rm /tmp/all-in-one-wp-migration.6.70.zip 

Migration

Export

Import

Schreibe einen Kommentar

Deine E-Mail-Adresse wird nicht veröffentlicht. Erforderliche Felder sind mit * markiert.