Ubuntu 20.04 is just released on April 23, 2020. You have a WordPress site on old Ubuntu such as Ubuntu 18.04 or 19.10. How would I transfer my WordPress site to the latest Ubuntu 20.04?
This article will walk you through all the steps to transfer your WordPress site to Ubuntu 20.04 on Amazon AWS EC2. However, it should apply to your environment as well.
Contents
Install Nginx Web Server
Nginx is a web server and we will first install Nginx as a reverse proxy for your WordPress installation. The Nginx version is upgrated to 1.17.10 on Ubuntu 20.04 from 1.14.0 on Ubuntu 18.04.
Run the following apt
command with sudo
to install Nginx 1.17.10:
sudo apt install nginx
As you can see from the output, the following Nginx dependencies will be installed:
fontconfig-config fonts-dejavu-core libfontconfig1 libgd3 libjbig0 libjpeg-turbo8 libjpeg8 libnginx-mod-http-image-filter libnginx-mod-http-xslt-filter libnginx-mod-mail libnginx-mod-stream libtiff5 libwebp6 libxpm4 nginx nginx-common nginx-core
The size of Nginx and its dependencies is quite small and only requires around 8 MB (7891 kB).
For your reference, here is the full output of sudo apt install nginx
Reading package lists… Done Building dependency tree Reading state information… Done The following additional packages will be installed: fontconfig-config fonts-dejavu-core libfontconfig1 libgd3 libjbig0 libjpeg-turbo8 libjpeg8 libnginx-mod-http-image-filter libnginx-mod-http-xslt-filter libnginx-mod-mail libnginx-mod-stream libtiff5 libwebp6 libxpm4 nginx-common nginx-core Suggested packages: libgd-tools fcgiwrap nginx-doc ssl-cert The following NEW packages will be installed: fontconfig-config fonts-dejavu-core libfontconfig1 libgd3 libjbig0 libjpeg-turbo8 libjpeg8 libnginx-mod-http-image-filter libnginx-mod-http-xslt-filter libnginx-mod-mail libnginx-mod-stream libtiff5 libwebp6 libxpm4 nginx nginx-common nginx-core 0 upgraded, 17 newly installed, 0 to remove and 0 not upgraded. Need to get 2431 kB of archives. After this operation, 7891 kB of additional disk space will be used. Do you want to continue? [Y/n] y Get:1 http://us-east-1.ec2.archive.ubuntu.com/ubuntu focal/main amd64 fonts-dejavu-core all 2.37-1 [1041 kB] Get:2 http://us-east-1.ec2.archive.ubuntu.com/ubuntu focal/main amd64 fontconfig-config all 2.13.1-2ubuntu3 [28.8 kB] Get:3 http://us-east-1.ec2.archive.ubuntu.com/ubuntu focal/main amd64 libfontconfig1 amd64 2.13.1-2ubuntu3 [114 kB] Get:4 http://us-east-1.ec2.archive.ubuntu.com/ubuntu focal/main amd64 libjpeg-turbo8 amd64 2.0.3-0ubuntu1 [118 kB] Get:5 http://us-east-1.ec2.archive.ubuntu.com/ubuntu focal/main amd64 libjpeg8 amd64 8c-2ubuntu8 [2194 B] Get:6 http://us-east-1.ec2.archive.ubuntu.com/ubuntu focal/main amd64 libjbig0 amd64 2.1-3.1build1 [26.7 kB] Get:7 http://us-east-1.ec2.archive.ubuntu.com/ubuntu focal/main amd64 libwebp6 amd64 0.6.1-2 [185 kB] Get:8 http://us-east-1.ec2.archive.ubuntu.com/ubuntu focal/main amd64 libtiff5 amd64 4.1.0+git191117-2build1 [161 kB] Get:9 http://us-east-1.ec2.archive.ubuntu.com/ubuntu focal/main amd64 libxpm4 amd64 1:3.5.12-1 [34.0 kB] Get:10 http://us-east-1.ec2.archive.ubuntu.com/ubuntu focal/main amd64 libgd3 amd64 2.2.5-5.2ubuntu2 [118 kB] Get:11 http://us-east-1.ec2.archive.ubuntu.com/ubuntu focal/main amd64 nginx-common all 1.17.10-0ubuntu1 [37.3 kB] Get:12 http://us-east-1.ec2.archive.ubuntu.com/ubuntu focal/main amd64 libnginx-mod-http-image-filter amd64 1.17.10-0ubuntu1 [14.3 kB] Get:13 http://us-east-1.ec2.archive.ubuntu.com/ubuntu focal/main amd64 libnginx-mod-http-xslt-filter amd64 1.17.10-0ubuntu1 [12.5 kB] Get:14 http://us-east-1.ec2.archive.ubuntu.com/ubuntu focal/main amd64 libnginx-mod-mail amd64 1.17.10-0ubuntu1 [42.3 kB] Get:15 http://us-east-1.ec2.archive.ubuntu.com/ubuntu focal/main amd64 libnginx-mod-stream amd64 1.17.10-0ubuntu1 [66.9 kB] Get:16 http://us-east-1.ec2.archive.ubuntu.com/ubuntu focal/main amd64 nginx-core amd64 1.17.10-0ubuntu1 [425 kB] Get:17 http://us-east-1.ec2.archive.ubuntu.com/ubuntu focal/main amd64 nginx all 1.17.10-0ubuntu1 [3616 B] Fetched 2431 kB in 0s (18.8 MB/s) Preconfiguring packages … Selecting previously unselected package fonts-dejavu-core. (Reading database … 59605 files and directories currently installed.) Preparing to unpack …/00-fonts-dejavu-core_2.37-1_all.deb … Unpacking fonts-dejavu-core (2.37-1) … Selecting previously unselected package fontconfig-config. Preparing to unpack …/01-fontconfig-config_2.13.1-2ubuntu3_all.deb … Unpacking fontconfig-config (2.13.1-2ubuntu3) … Selecting previously unselected package libfontconfig1:amd64. Preparing to unpack …/02-libfontconfig1_2.13.1-2ubuntu3_amd64.deb … Unpacking libfontconfig1:amd64 (2.13.1-2ubuntu3) … Selecting previously unselected package libjpeg-turbo8:amd64. Preparing to unpack …/03-libjpeg-turbo8_2.0.3-0ubuntu1_amd64.deb … Unpacking libjpeg-turbo8:amd64 (2.0.3-0ubuntu1) … Selecting previously unselected package libjpeg8:amd64. Preparing to unpack …/04-libjpeg8_8c-2ubuntu8_amd64.deb … Unpacking libjpeg8:amd64 (8c-2ubuntu8) … Selecting previously unselected package libjbig0:amd64. Preparing to unpack …/05-libjbig0_2.1-3.1build1_amd64.deb … Unpacking libjbig0:amd64 (2.1-3.1build1) … Selecting previously unselected package libwebp6:amd64. Preparing to unpack …/06-libwebp6_0.6.1-2_amd64.deb … Unpacking libwebp6:amd64 (0.6.1-2) … Selecting previously unselected package libtiff5:amd64. Preparing to unpack …/07-libtiff5_4.1.0+git191117-2build1_amd64.deb … Unpacking libtiff5:amd64 (4.1.0+git191117-2build1) … Selecting previously unselected package libxpm4:amd64. Preparing to unpack …/08-libxpm4_1%3a3.5.12-1_amd64.deb … Unpacking libxpm4:amd64 (1:3.5.12-1) … Selecting previously unselected package libgd3:amd64. Preparing to unpack …/09-libgd3_2.2.5-5.2ubuntu2_amd64.deb … Unpacking libgd3:amd64 (2.2.5-5.2ubuntu2) … Selecting previously unselected package nginx-common. Preparing to unpack …/10-nginx-common_1.17.10-0ubuntu1_all.deb … Unpacking nginx-common (1.17.10-0ubuntu1) … Selecting previously unselected package libnginx-mod-http-image-filter. Preparing to unpack …/11-libnginx-mod-http-image-filter_1.17.10-0ubuntu1_amd64.deb … Unpacking libnginx-mod-http-image-filter (1.17.10-0ubuntu1) … Selecting previously unselected package libnginx-mod-http-xslt-filter. Preparing to unpack …/12-libnginx-mod-http-xslt-filter_1.17.10-0ubuntu1_amd64.deb … Unpacking libnginx-mod-http-xslt-filter (1.17.10-0ubuntu1) … Selecting previously unselected package libnginx-mod-mail. Preparing to unpack …/13-libnginx-mod-mail_1.17.10-0ubuntu1_amd64.deb … Unpacking libnginx-mod-mail (1.17.10-0ubuntu1) … Selecting previously unselected package libnginx-mod-stream. Preparing to unpack …/14-libnginx-mod-stream_1.17.10-0ubuntu1_amd64.deb … Unpacking libnginx-mod-stream (1.17.10-0ubuntu1) … Selecting previously unselected package nginx-core. Preparing to unpack …/15-nginx-core_1.17.10-0ubuntu1_amd64.deb … Unpacking nginx-core (1.17.10-0ubuntu1) … Selecting previously unselected package nginx. Preparing to unpack …/16-nginx_1.17.10-0ubuntu1_all.deb … Unpacking nginx (1.17.10-0ubuntu1) … Setting up libxpm4:amd64 (1:3.5.12-1) … Setting up nginx-common (1.17.10-0ubuntu1) … Created symlink /etc/systemd/system/multi-user.target.wants/nginx.service → /lib/systemd/system/nginx.service. Setting up libjbig0:amd64 (2.1-3.1build1) … Setting up libnginx-mod-http-xslt-filter (1.17.10-0ubuntu1) … Setting up libwebp6:amd64 (0.6.1-2) … Setting up fonts-dejavu-core (2.37-1) … Setting up libjpeg-turbo8:amd64 (2.0.3-0ubuntu1) … Setting up libjpeg8:amd64 (8c-2ubuntu8) … Setting up libnginx-mod-mail (1.17.10-0ubuntu1) … Setting up fontconfig-config (2.13.1-2ubuntu3) … Setting up libnginx-mod-stream (1.17.10-0ubuntu1) … Setting up libtiff5:amd64 (4.1.0+git191117-2build1) … Setting up libfontconfig1:amd64 (2.13.1-2ubuntu3) … Setting up libgd3:amd64 (2.2.5-5.2ubuntu2) … Setting up libnginx-mod-http-image-filter (1.17.10-0ubuntu1) … Setting up nginx-core (1.17.10-0ubuntu1) … Setting up nginx (1.17.10-0ubuntu1) … Processing triggers for ufw (0.36-6) … Processing triggers for systemd (245.4-4ubuntu3) … Processing triggers for man-db (2.9.1-1) … Processing triggers for libc-bin (2.31-0ubuntu9) …
Now if you visit the url of you aws public DNS, you will be able to see the default Nginx page:
Install dependencies, the PHP modules
PHP is the language WordPress is written in. It is upgraded to PHP 7.4 on Ubuntu 20.04 from 7.2 on Ubuntu 18.04, but it shouldn’t make a difference as WordPress is still using older version for compatibility.
Install the fpm module of PHP
First we install php-fpm
to serve PHP scripts as well as WordPress.
sudo apt install php-fpm
p.p1 {margin: 0.0px 0.0px 0.0px 0.0px; font: 11.0px Menlo; color: #000000} p.p2 {margin: 0.0px 0.0px 0.0px 0.0px; font: 11.0px Menlo; color: #000000; min-height: 13.0px} span.s1 {font-variant-ligatures: no-common-ligatures} $ sudo apt install php-fpm Reading package lists... Done Building dependency tree Reading state information... Done The following additional packages will be installed: php-common php7.4-cli php7.4-common php7.4-fpm php7.4-json php7.4-opcache php7.4-readline Suggested packages: php-pear The following NEW packages will be installed: php-common php-fpm php7.4-cli php7.4-common php7.4-fpm php7.4-json php7.4-opcache php7.4-readline 0 upgraded, 8 newly installed, 0 to remove and 0 not upgraded. Need to get 4079 kB of archives. After this operation, 18.1 MB of additional disk space will be used. Do you want to continue? [Y/n] y Get:1 http://us-east-1.ec2.archive.ubuntu.com/ubuntu focal/main amd64 php-common all 2:75 [11.9 kB] Get:2 http://us-east-1.ec2.archive.ubuntu.com/ubuntu focal/main amd64 php7.4-common amd64 7.4.3-4ubuntu1 [979 kB] Get:3 http://us-east-1.ec2.archive.ubuntu.com/ubuntu focal/main amd64 php7.4-json amd64 7.4.3-4ubuntu1 [19.2 kB] Get:4 http://us-east-1.ec2.archive.ubuntu.com/ubuntu focal/main amd64 php7.4-opcache amd64 7.4.3-4ubuntu1 [198 kB] Get:5 http://us-east-1.ec2.archive.ubuntu.com/ubuntu focal/main amd64 php7.4-readline amd64 7.4.3-4ubuntu1 [12.6 kB] Get:6 http://us-east-1.ec2.archive.ubuntu.com/ubuntu focal/main amd64 php7.4-cli amd64 7.4.3-4ubuntu1 [1421 kB] Get:7 http://us-east-1.ec2.archive.ubuntu.com/ubuntu focal/universe amd64 php7.4-fpm amd64 7.4.3-4ubuntu1 [1434 kB] Get:8 http://us-east-1.ec2.archive.ubuntu.com/ubuntu focal/universe amd64 php-fpm all 2:7.4+75 [2792 B] Fetched 4079 kB in 0s (28.9 MB/s) Selecting previously unselected package php-common. (Reading database ... 59839 files and directories currently installed.) Preparing to unpack .../0-php-common_2%3a75_all.deb ... Unpacking php-common (2:75) ... Selecting previously unselected package php7.4-common. Preparing to unpack .../1-php7.4-common_7.4.3-4ubuntu1_amd64.deb ... Unpacking php7.4-common (7.4.3-4ubuntu1) ... Selecting previously unselected package php7.4-json. Preparing to unpack .../2-php7.4-json_7.4.3-4ubuntu1_amd64.deb ... Unpacking php7.4-json (7.4.3-4ubuntu1) ... Selecting previously unselected package php7.4-opcache. Preparing to unpack .../3-php7.4-opcache_7.4.3-4ubuntu1_amd64.deb ... Unpacking php7.4-opcache (7.4.3-4ubuntu1) ... Selecting previously unselected package php7.4-readline. Preparing to unpack .../4-php7.4-readline_7.4.3-4ubuntu1_amd64.deb ... Unpacking php7.4-readline (7.4.3-4ubuntu1) ... Selecting previously unselected package php7.4-cli. Preparing to unpack .../5-php7.4-cli_7.4.3-4ubuntu1_amd64.deb ... Unpacking php7.4-cli (7.4.3-4ubuntu1) ... Selecting previously unselected package php7.4-fpm. Preparing to unpack .../6-php7.4-fpm_7.4.3-4ubuntu1_amd64.deb ... Unpacking php7.4-fpm (7.4.3-4ubuntu1) ... Selecting previously unselected package php-fpm. Preparing to unpack .../7-php-fpm_2%3a7.4+75_all.deb ... Unpacking php-fpm (2:7.4+75) ... Setting up php-common (2:75) ... Created symlink /etc/systemd/system/timers.target.wants/phpsessionclean.timer → /lib/systemd/system/phpsessionclean.timer. Setting up php7.4-common (7.4.3-4ubuntu1) ... Creating config file /etc/php/7.4/mods-available/calendar.ini with new version Creating config file /etc/php/7.4/mods-available/ctype.ini with new version Creating config file /etc/php/7.4/mods-available/exif.ini with new version Creating config file /etc/php/7.4/mods-available/fileinfo.ini with new version Creating config file /etc/php/7.4/mods-available/ffi.ini with new version Creating config file /etc/php/7.4/mods-available/ftp.ini with new version Creating config file /etc/php/7.4/mods-available/gettext.ini with new version Creating config file /etc/php/7.4/mods-available/iconv.ini with new version Creating config file /etc/php/7.4/mods-available/pdo.ini with new version Creating config file /etc/php/7.4/mods-available/phar.ini with new version Creating config file /etc/php/7.4/mods-available/posix.ini with new version Creating config file /etc/php/7.4/mods-available/shmop.ini with new version Creating config file /etc/php/7.4/mods-available/sockets.ini with new version Creating config file /etc/php/7.4/mods-available/sysvmsg.ini with new version Creating config file /etc/php/7.4/mods-available/sysvsem.ini with new version Creating config file /etc/php/7.4/mods-available/sysvshm.ini with new version Creating config file /etc/php/7.4/mods-available/tokenizer.ini with new version Setting up php7.4-readline (7.4.3-4ubuntu1) ... Creating config file /etc/php/7.4/mods-available/readline.ini with new version Setting up php7.4-opcache (7.4.3-4ubuntu1) ... Creating config file /etc/php/7.4/mods-available/opcache.ini with new version Setting up php7.4-json (7.4.3-4ubuntu1) ... Creating config file /etc/php/7.4/mods-available/json.ini with new version Setting up php7.4-cli (7.4.3-4ubuntu1) ... update-alternatives: using /usr/bin/php7.4 to provide /usr/bin/php (php) in auto mode update-alternatives: using /usr/bin/phar7.4 to provide /usr/bin/phar (phar) in auto mode update-alternatives: using /usr/bin/phar.phar7.4 to provide /usr/bin/phar.phar (phar.phar) in auto mode Creating config file /etc/php/7.4/cli/php.ini with new version Setting up php7.4-fpm (7.4.3-4ubuntu1) ... Creating config file /etc/php/7.4/fpm/php.ini with new version Created symlink /etc/systemd/system/multi-user.target.wants/php7.4-fpm.service → /lib/systemd/system/php7.4-fpm.service. Setting up php-fpm (2:7.4+75) ... Processing triggers for man-db (2.9.1-1) ... Processing triggers for systemd (245.4-4ubuntu3) ... Processing triggers for php7.4-cli (7.4.3-4ubuntu1) ... Processing triggers for php7.4-fpm (7.4.3-4ubuntu1) ...
Now we need to change the fpm php setting. Note that you don’t want to directly copy the old php.ini
file because PHP is updated to 7.4 in Ubuntu 20.04 and there are new blocks in the setting file.
The php fpm setting in /etc/php/7.4/fpm/php.ini
, use your favorite editor to open it, e.g., sudo vim /etc/php/7.4/fpm/php.ini
, find the following PHP keys and replace with the following values:
post_max_size = 64M
memory_limit = 256M
max_execution_time = 300
upload_max_filesize = 32M
Reload php7.4-fpm
to make the changes take affect:
sudo service php7.4-fpm reload
Install the MySQL module of PHP
After the fpm module, the most important module is php-mysql
to connect to the MySQL database.
sudo apt install php-mysql
For your reference, here is the raw log:
$ sudo apt install php-mysql Reading package lists… Done Building dependency tree Reading state information… Done The following additional packages will be installed: php7.4-mysql The following NEW packages will be installed: php-mysql php7.4-mysql 0 upgraded, 2 newly installed, 0 to remove and 0 not upgraded. Need to get 123 kB of archives. After this operation, 487 kB of additional disk space will be used. Do you want to continue? [Y/n] y Get:1 http://us-east-1.ec2.archive.ubuntu.com/ubuntu focal/main amd64 php7.4-mysql amd64 7.4.3-4ubuntu1 [121 kB] Get:2 http://us-east-1.ec2.archive.ubuntu.com/ubuntu focal/main amd64 php-mysql all 2:7.4+75 [2000 B] Fetched 123 kB in 0s (2969 kB/s) Selecting previously unselected package php7.4-mysql. (Reading database … 61380 files and directories currently installed.) Preparing to unpack …/php7.4-mysql_7.4.3-4ubuntu1_amd64.deb … Unpacking php7.4-mysql (7.4.3-4ubuntu1) … Selecting previously unselected package php-mysql. Preparing to unpack …/php-mysql_2%3a7.4+75_all.deb … Unpacking php-mysql (2:7.4+75) … Setting up php7.4-mysql (7.4.3-4ubuntu1) … Creating config file /etc/php/7.4/mods-available/mysqlnd.ini with new version Creating config file /etc/php/7.4/mods-available/mysqli.ini with new version Creating config file /etc/php/7.4/mods-available/pdo_mysql.ini with new version Setting up php-mysql (2:7.4+75) … Processing triggers for php7.4-fpm (7.4.3-4ubuntu1) … Processing triggers for php7.4-cli (7.4.3-4ubuntu1) …
Install Other PHP modules
There are a few other PHP modules that are required by WordPress. Simply install them by the following command.
sudo apt install php-curl php-dom php-mbstring php-imagick php-zip php-gd php-intl
Move WordPress directory
The most important part is probably to move your WordPress directory, including the WordPress themes, plugins and the images you have uploaded.
On your current host you are migrating from, compress the WordPress folder:
tar -czvf wp.tar.gz /var/www/wordpress/
Transfer to your local host:
scp pi@rpi.local:/var/www/wp.tar.gz .
Upload to the Ubuntu 20.04 host:
scp wp.tar.gz ubuntu@ec2-54-208-120-28.compute-1.amazonaws.com:~
Uncompress the WordPress folder
cd /
tar -xvf wp.tar.gz
Change the ownership to www-data
, which is the user used for the web. E.g., Nginx and Apache are all ran on the www-data
user. It is not specific to Ubuntu 20.04, but rather inherited from Debian.
sudo chown -R www-data: /var/www/wordpress/
To double check, run `ls -la /var/www/wordpress/`, you should be able to see the www-data user and group:
drwxr-xr-x 5 www-data www-data 4096 Apr 23 18:49 wordpress
Move Nginx WordPress config files
First, use scp
to download your WordPress config files on your old host:
scp pi@rpi.local:/etc/nginx/sites-available/{user,wordpress} old_host
Upload the config files to you new host:
scp old_host/{user,wordpress} ubuntu@ec2-54-208-120-28.compute-1.amazonaws.com:~
On your new host, move the config files to Nginx’s sites-available folder
sudo mv {user,wordpress} /etc/nginx/sites-available
Create soft links to sites-enabled
to enable your WordPress site. Here we use relative links, which are more portable and simpler to reason about.
cd /etc/nginx/sites-enabled sudo ln -s ../sites-available/{user,wordpress} .
We also need to remove the default config, because we already have the user
file for this purpose
sudo rm default
Change php-fpm sock file to PHP 7.4
Because Ubuntu has php 7.4 now, your old socket file path need to be updated. Check each of your config file.
In our case, we need to change
fastcgi_pass unix:/run/php/php7.3-fpm.sock;
to
fastcgi_pass unix:/run/php/php7.4-fpm.sock;
Note that the version number is changed.
Test the configuration file before reload:
nginx -t
If there are no errors, reload nginx by
sudo service nginx reload
Migrate certbot
Let’s Encrypt certificates
If you have enabled HTTPS for you site, you will need to move the SSL certificates as well.
We first install the certbot
tool. Note that we don’t want to upload the installed cert bot files directly as Ubuntu 20.04 has python 3 by default and the certbot name is changed from python-certbot-nginx
to python3-certbot-nginx
.
sudo apt install certbot python3-certbot-nginx
For you reference, here is the output of apt:
sudo apt-get install certbot python3-certbot-nginx Reading package lists… Done Building dependency tree Reading state information… Done The following additional packages will be installed: python3-acme python3-certbot python3-configargparse python3-future python3-icu python3-josepy python3-mock python3-parsedatetime python3-pbr python3-pyparsing python3-requests-toolbelt python3-rfc3339 python3-tz python3-zope.component python3-zope.event python3-zope.hookable Suggested packages: python3-certbot-apache python-certbot-doc python-acme-doc python-certbot-nginx-doc python-future-doc python-mock-doc python-pyparsing-doc The following NEW packages will be installed: certbot python3-acme python3-certbot python3-certbot-nginx python3-configargparse python3-future python3-icu python3-josepy python3-mock python3-parsedatetime python3-pbr python3-pyparsing python3-requests-toolbelt python3-rfc3339 python3-tz python3-zope.component python3-zope.event python3-zope.hookable 0 upgraded, 18 newly installed, 0 to remove and 0 not upgraded. Need to get 112 kB/1264 kB of archives. After this operation, 6659 kB of additional disk space will be used. Do you want to continue? [Y/n] y Get:1 http://us-east-1.ec2.archive.ubuntu.com/ubuntu focal/main amd64 python3-pyparsing all 2.4.6-1 [61.3 kB] Get:2 http://us-east-1.ec2.archive.ubuntu.com/ubuntu focal/universe amd64 python3-certbot-nginx all 0.39.0-1 [50.6 kB] Fetched 112 kB in 0s (3149 kB/s) Selecting previously unselected package python3-josepy. (Reading database … 59986 files and directories currently installed.) Preparing to unpack …/00-python3-josepy_1.2.0-2_all.deb … Unpacking python3-josepy (1.2.0-2) … Selecting previously unselected package python3-pbr. Preparing to unpack …/01-python3-pbr_5.4.5-0ubuntu1_all.deb … Unpacking python3-pbr (5.4.5-0ubuntu1) … Selecting previously unselected package python3-mock. Preparing to unpack …/02-python3-mock_3.0.5-1build1_all.deb … Unpacking python3-mock (3.0.5-1build1) … Selecting previously unselected package python3-requests-toolbelt. Preparing to unpack …/03-python3-requests-toolbelt_0.8.0-1.1_all.deb … Unpacking python3-requests-toolbelt (0.8.0-1.1) … Selecting previously unselected package python3-tz. Preparing to unpack …/04-python3-tz_2019.3-1_all.deb … Unpacking python3-tz (2019.3-1) … Selecting previously unselected package python3-rfc3339. Preparing to unpack …/05-python3-rfc3339_1.1-2_all.deb … Unpacking python3-rfc3339 (1.1-2) … Selecting previously unselected package python3-acme. Preparing to unpack …/06-python3-acme_1.1.0-1_all.deb … Unpacking python3-acme (1.1.0-1) … Selecting previously unselected package python3-configargparse. Preparing to unpack …/07-python3-configargparse_0.13.0-2_all.deb … Unpacking python3-configargparse (0.13.0-2) … Selecting previously unselected package python3-future. Preparing to unpack …/08-python3-future_0.18.2-2_all.deb … Unpacking python3-future (0.18.2-2) … Selecting previously unselected package python3-parsedatetime. Preparing to unpack …/09-python3-parsedatetime_2.4-5_all.deb … Unpacking python3-parsedatetime (2.4-5) … Selecting previously unselected package python3-zope.hookable. Preparing to unpack …/10-python3-zope.hookable_5.0.0-1build1_amd64.deb … Unpacking python3-zope.hookable (5.0.0-1build1) … Selecting previously unselected package python3-zope.event. Preparing to unpack …/11-python3-zope.event_4.4-2build1_all.deb … Unpacking python3-zope.event (4.4-2build1) … Selecting previously unselected package python3-zope.component. Preparing to unpack …/12-python3-zope.component_4.3.0-3_all.deb … Unpacking python3-zope.component (4.3.0-3) … Selecting previously unselected package python3-certbot. Preparing to unpack …/13-python3-certbot_0.40.0-1_all.deb … Unpacking python3-certbot (0.40.0-1) … Selecting previously unselected package certbot. Preparing to unpack …/14-certbot_0.40.0-1_all.deb … Unpacking certbot (0.40.0-1) … Selecting previously unselected package python3-pyparsing. Preparing to unpack …/15-python3-pyparsing_2.4.6-1_all.deb … Unpacking python3-pyparsing (2.4.6-1) … Selecting previously unselected package python3-certbot-nginx. Preparing to unpack …/16-python3-certbot-nginx_0.39.0-1_all.deb … Unpacking python3-certbot-nginx (0.39.0-1) … Selecting previously unselected package python3-icu. Preparing to unpack …/17-python3-icu_2.4.2-0ubuntu3_amd64.deb … Unpacking python3-icu (2.4.2-0ubuntu3) … Setting up python3-configargparse (0.13.0-2) … Setting up python3-requests-toolbelt (0.8.0-1.1) … Setting up python3-icu (2.4.2-0ubuntu3) … Setting up python3-zope.event (4.4-2build1) … Setting up python3-pbr (5.4.5-0ubuntu1) … update-alternatives: using /usr/bin/python3-pbr to provide /usr/bin/pbr (pbr) in auto mode Setting up python3-tz (2019.3-1) … Setting up python3-mock (3.0.5-1build1) … Setting up python3-zope.hookable (5.0.0-1build1) … Setting up python3-pyparsing (2.4.6-1) … Setting up python3-josepy (1.2.0-2) … Setting up python3-future (0.18.2-2) … update-alternatives: using /usr/bin/python3-futurize to provide /usr/bin/futurize (futurize) in auto mode update-alternatives: using /usr/bin/python3-pasteurize to provide /usr/bin/pasteurize (pasteurize) in auto mode Setting up python3-rfc3339 (1.1-2) … Setting up python3-parsedatetime (2.4-5) … Setting up python3-zope.component (4.3.0-3) … Setting up python3-acme (1.1.0-1) … Setting up python3-certbot (0.40.0-1) … Setting up certbot (0.40.0-1) … Created symlink /etc/systemd/system/timers.target.wants/certbot.timer → /lib/systemd/system/certbot.timer. Setting up python3-certbot-nginx (0.39.0-1) … Processing triggers for man-db (2.9.1-1) …
Next we don’t want to run sudo certbot --nginx
. Instead, we will upload the certificates and make sure the cron job still ran to automatically renew our certificate.
On your old host, compress all the file we want. Specifically, we will compress the archive
and renewal
folders. The live
folder, if you noticed, is really having soft links to the archive
folder.
sudo tar -chvzf certs.tar.gz /etc/letsencrypt/archive/lgtm.cf /etc/letsencrypt/renewal/lgtm.cf.conf
Download from old host:
scp pi@rpi.local:~/certs.tar.gz old_host
Upload to our new host:
scp old_host/certs.tar.gz ubuntu@ec2-54-208-120-28.compute-1.amazonaws.com:~
Uncompress the certificates:
cd /
sudo tar -xvf ~/certs.tar.gz
Create the soft symbol links:
cd /etc/letsencrypt/archive/ sudo mkdir -p live/lgtm.cf cd live/lgtm.cf sudo ln -s ../../archive/lgtm.cf/* . sudo mv cert1.pem cert.pem sudo mv chain1.pem chain.pem sudo mv fullchain1.pem fullchain.pem sudo mv privkey1.pem privkey.pem
To double check, use ls -la
in /etc/letsencrypt/archive/live/lgtm.cf
:
total 8
drwxr-xr-x 2 root root 4096 Apr 25 00:12 .
drwxr-xr-x 3 root root 4096 Apr 25 00:04 ..
lrwxrwxrwx 1 root root 31 Apr 25 00:08 cert.pem -> ../../archive/lgtm.cf/cert1.pem
lrwxrwxrwx 1 root root 32 Apr 25 00:08 chain.pem -> ../../archive/lgtm.cf/chain1.pem
lrwxrwxrwx 1 root root 36 Apr 25 00:08 fullchain.pem -> ../../archive/lgtm.cf/fullchain1.pem
lrwxrwxrwx 1 root root 34 Apr 25 00:08 privkey.pem -> ../../archive/lgtm.cf/privkey1.pem
Now test if the nginx error goes away, if you use Let’s encript:
sudo nginx -t
If it does, reload nginx:
sudo service nginx reload
Reference: https://ivanderevianko.com/2019/03/migrate-letsencrypt-certificates-certbot-to-new-server
Migrate WordPress MySQL/MariaDB database
MySQL is upgraded to 8.0.19 on Ubuntu 20.04 from 5.7.29 in Ubuntu 18.04, which is a bug jump. You might want to check the change logs to avoid problems from breaking changes.
Install MySQL on Ubuntu 20.04
First, Install MySQL on the new host:
sudo apt install default-mysql-client default-mysql-server
Create the WordPress user, database, and grant privileges to the user
sudo su
mysql -u root -p
CREATE DATABASE wpdb;
CREATE USER 'wpuser'@'localhost' identified by 'dbpassword';
GRANT ALL PRIVILEGES ON wpdb.* TO 'wpuser'@'localhost';
FLUSH PRIVILEGES;
EXIT;
Backup WordPress database
We need to read the wp-config.php
file to look for the username, password and database name.
After we know them, we use the mysqldump
command with the parameters host, username, and table name. The host can be removed if MySQL is installed locally.
mysqldump --add-drop-table -h mysql_hostserver -u mysql_username -p mysql_databasename
It will promp you to “Enter password:”.
Now download to you dev machine:
scp pi@rpi.local:~/wordpress.bak.sql old_host
Upload to the host with Ubuntu 20.04 installed:
scp old_host/wordpress.bak.sql ubuntu@ec2-54-208-120-28.compute-1.amazonaws.com:~
Restore WordPress database
This is relatively easy given we already have the previous steps.
mysql -u wpuser -p wordpress < wordpress.bak.sql
Now you should be all set.
Reference:
- https://wordpress.org/support/article/backing-up-your-database/
- https://wordpress.org/support/article/restoring-your-database-from-backup/
2 replies on “How To Move and Install WordPress To Ubuntu 20.04”
Thank You
Here is Our blog to do how to migrate Worpress:- https://bit.ly/3AAlg6k
Thank You
Here is Our blog to do how to migrate Worpress:-https://blog.spotfixcrew.com/