How to Install WordPress on Ubuntu 17.10 with Apache, MariaDB, PHP7.1

This tutorial is going to show you how to install WordPress on Ubuntu 17.10 with Apache, MariaDB and PHP7.1. WordPress is the most popular content management system (CMS) in the world. It is estimated that more than a quarter of websites today are powered by WordPress.

PHP7.1 made into the Ubuntu 17.10 repository and WordPress runs perfectly with it. This tutorial assumes that you have already set up a LAMP stack on Ubuntu 17.10. If not, please check out the following tutorial.

After finishing LAMP installation, come back here and read on.

Step 1: Download WordPress

SSH into your Ubuntu 17.10 server and update existing software.

sudo apt update && sudo apt upgrade

Next, go to download page and download the zip archive. You can acquire the direct download link by right-clicking the download button and select copy link location.

install wordpress on ubuntu 17.10

Then at the command line, type in wget followed by the direct download link to download WordPress to your Ubuntu 17.10 server.


Next, extract the zip archive using the command below.

sudo apt install unzip

sudo unzip

A new directory named wordpress will be created in the current working directory. Now We move this directory and all its content to Apache web root. Replace with you real domain name.

sudo mv wordpress/ /var/www/

Step 2: Create a Database and User for WordPress Site

Log into MariaDB shell as root with the following command.

sudo mariadb -u root

Once you are logged in, create a database for WordPress using the following command. I named it wordpress, but you can use whatever name you like such as you site name. (Don’t leave out the semicolon.)

create database wordpress;

Then enter the command below to create a database user for WordPress. This command also grant all privileges of WordPress database to the user.

grant all privileges on wordpress.* to wpuser@localhost identified by 'your-password';

Flush the privileges table for the changes to take effect and then exit out of MariaDB shell.

flush privileges;


Step 3: Configure WordPress

Go to your WordPress directory.

cd /var/www/

Copy the sample configuration file.

sudo cp wp-config-sample.php wp-config.php

Now edit the new config file.

sudo nano wp-config.php

Find the following lines and replace the red texts with the database name, username and password you created in the previous step.

/** The name of the database for WordPress */
define('DB_NAME', 'database_name_here');

/** MySQL database username */
define('DB_USER', 'username_here');

/** MySQL database password */
define('DB_PASSWORD', 'password_here');

Save and close the file. We also need to set the Apache user (www-data) as the owner of the WordPress site directory using the following command.

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

Step 4: Create an Apache Virtual Host file for WordPress

Go to /etc/apache2/sites-available/ directory.

cd /etc/apache2/sites-available/

Run the following command to create a virtual host file for your WordPress site.

sudo nano

Paste the following text into the file.

<VirtualHost *:80>       

        DocumentRoot /var/www/

        ErrorLog ${APACHE_LOG_DIR}/
        CustomLog ${APACHE_LOG_DIR}/ combined

Save and close the file. Then test configurations.

sudo apache2ctl configtest

If you see “Syntax OK”, then enable this virtual host.

sudo a2ensite

And reload Apache for the changes to take effect.

sudo systemctl reload apache2

Set a correct A record for your domain name, then enter your domain name in browser address bar. You shall see the WordPress installation wizard. Select a language.


If the installation wizard isn’t displayed, then you probably need to install some PHP7 extensions.

sudo apt install php7.1-mbstring php7.1-xml php7.1-mysql php7.1-common php7.1-gd php7.1-json php7.1-cli php7.1-curl

Then reload Apache and the wizard should now be displayed.

sudo systemctl reload apache2

Create an admin account and click install WordPress button.

wordpress php7.1 ubuntu 17.10

And now your new WordPress site is installed.

install wordpress ubuntu 17.10 LAMP

How to Redirect www to non-www

The Apache configuration we created allows site visitors to access the website via both www and non-www domain. You can redirect one version to another by going to WordPress Dashboard > Settings > General. Then set WordPress Address and Site Address to your preferred version.

wordpress redirct www to non www

I hope this tutorial helped you install WordPress on Ubuntu 17.10 with Apache, MariaDB and PHP7.1. As always, if you found this post useful, then subscribe to our free newsletter. In the next tutorial, we will see how to install a free SSL certificate with Apache and how to enable HTTP/2 protocol for faster performance.

Rate this tutorial
[Total: 4 Average: 5]