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 by executing the following command. 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/

        #This enables .htaccess file, which is needed for WordPress Permalink to work. 
        <Directory "/var/www/">
             AllowOverride All

        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: 9 Average: 4.7]

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

  • Gary Bisaga
    2 years ago

    Another flawless tutorial! Thank you!

  • Hi
    Thank you for the neat instructions. However I get stuck at the last part. Can’t get to the wordpress installation wizard in the browser.

    “Set a correct A record for your domain name, then enter your domain name in browser address bar.” Can you please explain this? Is this relevant for local testing. I don’t have a domain, I just want to test locally.

    ” ServerName” Am I supposed to replace ‘’ with ‘localhost’ or just the domainname that I put after /www/var/ during installation?

    I am still getting the “Apache2 Ubuntu Default Page” when I go to localhost in the browser. or is there something else I am supposed to type in the browser to access the wordpress installation?

    Thank you !

    • localhost will bring you to the default Apache virtual host.

      If you don’t have a domain name and just want to install WordPress on your local computer, you can create a local DNS entry in /etc/hosts file like below. localhost

      So you can type in in the browser address bar and it will take you to your WordPress installation.

  • I have a local Ubuntu 18.04 server on the same LAN as my windows laptop.
    I have followed the below procedures:
    And all appears to be working fine. I can reach the apache splash page and

    I would like to create a local wordpress instance on the server to learn how to build webpages.
    Will this procedure work for Ubuntu 18:04?

    • Fantastic website with flawless instructions.

      by carefully reading through the instructions, I have converted my Intel NUC into a functioning web server with almost no previous linux experience.

      Note: This procedure does work for ubuntu 18.04. However the latest wordpress release recommends PHP7.3 so I upgraded that.

Leave a Comment

  • Comments with links are moderated by admin before published.
  • Your email address will not be published.
  • Use <pre> ... </pre> HTML tag to quote the output from your terminal/console.
  • Please use the community ( for questions unrelated to this article.
  • I don't have time to answer every question. Making a donation would incentivize me to spend more time answering questions.