Wibble Support Package – Ensuring Your WordPress Site is Performing & Safe
Our Wibble Support Package keeps your WordPress site secure and fast. This post explains how it protects your infrastructure.
Sometimes as a web design & development studio, we are required to step out of the box.
This is a walkthrough for setting up an Apache2 server on Ubuntu to host a WordPress site. I will cover the installation and configuration of Apache, MySQL (MariaDB), PHP, WP-CLI, and SSL certificates, as well as some optional steps for setting up a WordPress site.
To a lot of people, this blog post will not make sense and that’s ok, that is the point of using an award-winning web design and web development studio who see themselves as the best web design studio in Ireland, we know what we are doing. As a fully managed WordPress hosting provider we have the ability to set up a web server using a custom setup, should it be needed to.
We were brought in to set up a third party’s server with a specific config. There was limited / poor documentation on the setup with specifics in WordPress so we decided to set up our own guide for other web developers or web agencies that would need to set up an Apache2 Server for WordPress.
Before we begin, it’s important to ensure your system is up-to-date. Run the following commands from your server’s home directory (/var/www/html) with sudo privileges:sudo apt update && apt upgrade
sudo apt update && apt upgrade
You should see this output:

Apache is the web server software we’ll use. To install it, use the following command:
sudo apt install apache2
You should see this output:

To verify that Apache is installed and running, run:
systemctl status apache2
You should see this output:

You can further verify by opening a web browser and navigating to your server’s IP address. If Apache is installed correctly, you’ll see the default Apache welcome page eg:

We’ll use MariaDB, an open-source fork of MySQL, as our database engine. Install it with:
sudo apt install mariadb-server mariadb-client
This installs the MariaDB server and client packages.

Next, secure your MariaDB installation by running:
mysql_secure_installation
This command will prompt you to set a root password, remove anonymous users, disallow remote root login, remove the test database, and reload privileges. Answer these prompts according to your security preferences.
The first step will prompt you to change the root password to login to the database. You can opt to change it or skip if you are convinced that you have a strong password. To skip changing type n.

For safety’s sake, you will be prompted to remove anonymous users. Type Y.

Next, disallow remote root login to prevent hackers from accessing your database. However, for testing purposes, you may want to allow log in remotely (optional) if you are configuring a virtual server. Type Y.

Next, remove the test database. Type Y.

Finally, reload the database to apply the changes. Type Y.

Now it’s time to log in to our MariaDB database as root and create a database for accommodating our WordPress data.
sudo mysql -u root -p
Output:

Create a database for our WordPress installation. Change wordpress_db to name of site i.e. dbexamplesite
CREATE DATABASE wordpress_db;
Output:

Next, create a database user for our WordPress setup. Change wp_user to the name you’d like. Change wp_user to the username for this database, change password to your password:
CREATE USER 'wp_user'@'localhost' IDENTIFIED BY 'password';
Output:

Grant privileges to the user Next, grant the user permissions to access the database:
GRANT ALL ON wordpress_db.* TO 'wp_user'@'localhost' IDENTIFIED BY 'password';
Output

Great, now you can exit the database:
FLUSH PRIVILEGES;
Exit;
PHP is required for WordPress to function. Install it along with the MySQL extension:
sudo apt install php php-mysql libapache2-mod-php php-cli php-curl php-gd php-xml php-mbstring php-zip
This installs PHP and the PHP extension for MySQL. See the example snippet of output you should see:

To confirm PHP is installed, create an info.php file in the /var/www/html/directory:
sudo vim /var/www/html/info.php
Add the following content to the file:
<?php
phpinfo();
?>
Save and close the file. Then, visit https://ip-address/info.php in your browser. This will display PHP information.

Remember to remove this file after verifying PHP installation for security reasons:
sudo rm /var/www/html/info.php
WP-CLI is the command-line interface for WordPress, which simplifies many WordPress management tasks.
Navigate to the root folder:
cd /var/www/html
Remove the default index.html file:
sudo rm index.html
Install WP-CLI:
sudo curl -O https://raw.githubusercontent.com/wp-cli/builds/gh-pages/phar/wp-cli.phar
Downloads the file from the given URL.
Make the file executable and move it to your PATH
sudo chmod +x wp-cli.phar
sudo mv wp-cli.phar /usr/local/bin/wp
sudo chmod +x wp-cli.phar: Makes the WP-CLI file executable.
sudo mv wp-cli.phar /usr/local/bin/wp: Moves the file to a directory in your PATH, allowing you to run it using the wp command.
Test the installation
wp --info
Set file permissions if you are not a root user on the server but do have sudo access as you may need to have this for file updates via SFTP:
sudo chmod -R 777 /var/www/html
Create a site folder:
sudo mkdir example.com
Navigate to the new directory and download WordPress:
cd example.com
then:
wp core download
To enable HTTPS, you’ll need an SSL certificate. You can use the default snake-oil cert for dev only, generate a self-signed SSL certificate for testing or use Let’s Encrypt for free, production-ready certificates. For self-signed:
Enable the SSL module and restart Apache:
sudo a2enmod ssl
systemctl restart apache2
Export your database from your existing development site. This is typically done through a database manager like phpMyAdmin.
Import the database to your new server using WP-CLI:
wp db import <filename.sql>
This imports the given SQL file into the WordPress database.
Run a search-replace to update URLs:
wp search-replace 'https://example-stage.link/' 'http://example.com/' --dry-run
Copy the wp-content folder from your existing site to your new server using FileZilla or similar.
Edit the Apache configuration files to point to your new site directory:sudo vi /etc/apache2/sites-available/000-default.conf
sudo vi /etc/apache2/sites-available/default-ssl.conf
Update the DocumentRoot to /var/www/html/example.com and add <Directory> directives.
Verify DNS resolution by checking these files for the correct site root path and domain:
sudo vi /etc/apache2/sites-available/000-default.conf
sudo vi /etc/apache2/sites-available/default-ssl.conf
sudo vi /etc/hosts
sudo vi /etc/apache2/apache2.conf
sudo vi /var/www/html/example.com/.htaccess
sudo vi /var/www/html/example.com/wp-config.php
Remember to adjust commands and configurations to fit your specific environment.
Wibble are known as the go-to agency on the Island of Ireland for all things WordPress: from management and development to support and hosting. We like to see ourselves as the best WordPress web design agency there is. Our Google reviews back this up and we are proud that so many of our web design clients refer us to their peers.
This blog post gives a brief demonstration into the level of expertise that we possess around everything to do with WordPress and fully managed WordPress hosting.
If your current host isn’t cutting it in terms of fully managed WordPress support and hosting, contact us to see can we help look after your exisitng WordPress site or help you set up a new web server for a new project.
Studio Location
Floor 2,Telephone
+44 (0)28 90 098 678
hello@wearewibble.com
Get in touch with us today with the details below, or use the contact form to ask us a question and one of our Wibblers will get back to you.
"*" indicates required fields