Posted on

Duplicating a WordPress site locally

Use the Snap Creek Duplicator plugin. The plugin generates a zip file and an installer.php script. First, delete all the files and folders in the local WordPress root folder. Then copy the zip file and the installer script to this folder, and browse to installer.php. Click ‘next’ a few times, enter the database details, done.

Posted on

Running multiple WordPress sites on Ubuntu Studio 20.04 LTS

Step 1: install Apache2

sudo apt install apache2

start Apache and have it run on system boot:

sudo systemctl enable --now apache2

We’re not accessing this externally, so no need for any firewall stuff.

Step 2: Install MySQL database server

sudo apt install mysql-server

The installation output tells us that the mysqld will log errors to /var/log/mysql/error.log.

Check the server is running with:

sudo mysql

This will connect to the MySQL server as the administrative database user root, which is inferred by the use of sudo when running this command. To exit the MySQL console, type ‘exit’.

Step 3: Install PHP

sudo apt install php libapache2-mod-php php-mysql

Step 4: Create databases

Logon to the mysql server:

sudo mysql


CREATE DATABASE databaseName1db;
CREATE DATABASE databaseName2db;

Now create the database users and passwords:

CREATE USER 'wp_user1'@'localhost' IDENTIFIED BY 'user1_password';
CREATE USER 'wp_user2'@'localhost' IDENTIFIED BY 'user2_password';

GRANT ALL PRIVILEGES ON databaseName1db.* TO 'wp_user1'@'localhost';
GRANT ALL PRIVILEGES ON databaseName2db.* TO 'wp_user2'@'localhost';


Step 5: create Apache server blocks

Now create a server block for each website:

sudo nano /etc/apache2/sites-available/
sudo nano /etc/apache2/sites-available/

Here’s an example of the content of each .conf file:

<VirtualHost *:80>
  DocumentRoot /var/www/

  <Directory /var/www/>
    Options Indexes FollowSymLinks MultiViews
    AllowOverride All
    Order allow,deny
    allow from all
  ErrorLog ${APACHE_LOG_DIR}/error.log
  CustomLog ${APACHE_LOG_DIR}/access.log combined

Next, enable the server blocks:

sudo a2ensite
sudo a2ensite

Step 6: create document root folder for each site

sudo mkdir -p /var/www/
sudo mkdir -p /var/www/

When done, copy the latest WordPress into each folder.

Step 9: configure WordPress database settings

To create WordPress wp-config.php for each domain:

sudo cp /var/www/ /var/www/
sudo cp /var/www/ /var/www/

Then open each wp-config.php file and edit the database connection info.

Step 10: Permissions, etc

Modify the directory permissions:

sudo chown -R www-data:www-data /var/www/
sudo chmod -R 755 /var/www/

Check Apache settings, enable rewrite module and restart server:

sudo apachectl configtest
sudo a2enmod rewrite
sudo systemctl restart apache2.service

Step 11: set up local hosts file

We need to redirect requests to serve our locally hosted sites to the local Apache server, rather than have them go out to the external internet. This is done by adding two entries to the /etc/hosts file:

sudo nano /etc/hosts

Add a line for each of our local sites:       localhost       QPC-ATTIC
[XXX.XXX.XXX.XXX = IP address of local server]
[XXX.XXX.XXX.XXX = IP address of local server]