Install and configure WordPress


Duration: 1:00

WordPress is the most popular open source blogging system and CMS on the Web. It is based on PHP and MySQL. Its features can be extended with thousands of free plugins and themes.

In this tutorial we will install WordPress on Apache2 server and create our first post.

What you’ll learn

  • How to set up WordPress
  • How to configure WordPress
  • How to create first post

What you’ll need

  • A computer running Ubuntu Server 16.04 LTS
  • Running Apache2 server
  • You don’t need to know how to configure database.

Install WordPress

Duration: 1:00

To install WordPress, use following command:

sudo apt update
sudo apt install wordpress php libapache2-mod-php mysql-server php-mysql

If you haven’t installed MySQL before, you will be asked for password for “root” MySQL user. You can leave this field empty.

Configure Apache for WordPress

Duration: 2:00

Create Apache site for WordPress. Create /etc/apache2/sites-available/wordpress.conf with following lines:

Alias /blog /usr/share/wordpress
<Directory /usr/share/wordpress>
    Options FollowSymLinks
    AllowOverride Limit Options FileInfo
    DirectoryIndex index.php
    Order allow,deny
    Allow from all
<Directory /usr/share/wordpress/wp-content>
    Options FollowSymLinks
    Order allow,deny
    Allow from all

Then, enable this site with sudo a2ensite wordpress, enable URL rewriting with sudo a2enmod rewrite and reload apache2 with sudo service apache2 reload.

Configure database

Duration: 4:00

To configure WordPress, we need to create MySQL database. Let’s do it!

$ sudo mysql -u root
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 7
Server version: 5.7.20-0ubuntu0.16.04.1 (Ubuntu)

Copyright (c) 2000, 2017, Oracle and/or its affiliates. All rights reserved.

Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

mysql> CREATE DATABASE wordpress;
Query OK, 1 row affected (0,00 sec)

    -> ON wordpress.*
    -> TO wordpress@localhost
    -> IDENTIFIED BY '<your-password>';
Query OK, 1 row affected (0,00 sec)

Query OK, 1 row affected (0,00 sec)

mysql> quit

Now, let’s configure WordPress to use this database. Open /etc/wordpress/config-localhost.php and write:

define('DB_NAME', 'wordpress');
define('DB_USER', 'wordpress');
define('DB_PASSWORD', '<your-password>');
define('DB_HOST', 'localhost');
define('DB_COLLATE', 'utf8_general_ci');
define('WP_CONTENT_DIR', '/usr/share/wordpress/wp-content');

Enable MySQL with sudo service mysql start.

Configure WordPress

Duration: 2:00

Open localhost/blog in your browser. You will be asked for title of your new site, username, password and address e-mail. You can choose if you want to make your site indexed by search engines.

You can now login under localhost/blog/wp-login.php. In Dashboard, you will see bunch of icons and options. Don’t worry, it’s easy!

Write your first post

Duration: 3:00

You have probably noticed that “Hello world!” post. We will delete it and write something more interesting…

All Posts

From Dashboard (localhost/blog/wp-admin/), select “Posts” icon and click on “All Posts”. Mouse over the “Hello world!” post title and select Trash.

To create new post, click on the “Add New” button. You should notice a fancy WYSIWYG editor with simple (but powerful) text formatting options. You may want to switch to Text mode, if you prefer pure HTML.

Let’s write something! It’s as easy, as using text processors that you know from office suites.

Now, click the Publish button. You can now view your brand new post!

That’s all!

Duration: 1:00

Of course, this tutorial has only described basics of WordPress usage, you can do much more with this blogging platform/CMS. You can install one of thousands of available (free and commercial) plugins and themes. You can even configure it as forum (with bbPress plugin), microblogging platform (BuddyPress), eCommerce platform (WooCommerce) or extend existing WordPress features with plugins like JetPack or TinyMCE Advanced.

WordPress manual and documentation is available in the WordPress Codex.You can read it to learn more about WordPress usage, and even something about themes/plugins development.

If you need more guidance on using WordPress, help is always at hand:

Further reading:

1 Like

While doing sudo a2ensite wordpress it would be good idea to add
sudo a2enmod rewrite.
Thank you.

1 Like

I would also add changing to collation, if needed when entering the DB_USER and others MySql settings.

define( ‘DB_COLLATE’, ‘utf8_general_ci’ );

1 Like

Yes, makes sense on both accounts, updated. Thanks!


Happy to help:)

Is it possible to use this method for sites without alias (/blog)?


    -> ON wordpress.*
    -> TO wordpress@localhost
    -> IDENTIFIED BY '<your-password>';

Doesn’t work anymoore
Use maybe this Instead:

CREATE USER 'wordpress'@'localhost' IDENTIFIED BY '<your-password>';
GRANT ALL PRIVILEGES ON wordpress.* TO 'wordpress'@'localhost' WITH GRANT OPTION;

Due to the new version there have to be an other adjustment:
CREATE USER ‘wordpress’@‘localhost’ IDENTIFIED WITH mysql_native_password BY ‘’;

This leaves you with an installation of wordpress that is not able to install plugins. I did some research to see what is required, and apparently doing things this way it is not possible to install plugins without opening yourself up to a world of security vulnerabilities. So no plugins. What means I just wasted all this time for nothing. A warning that this does not install a full, usable version of wordpress would have been nice.

Furthermore, this installs Wordpress so that it appears to users to be located in a subdirectory called “blog/” which does not actually exist. Although you can change the settings so the user-facing site no longer appears to be in this nonexistent subdirectory, there is no way to move /wp-admin out of “[sitedomain]/blog/wp-admin”

You really should make it clear at the BEGINNING that these instructions are for a single, extremely specific and nonstandard install of wordpress. Now I have to start all over again from scratch.

1 Like

Holy bullshit. The installation removed my mariaDB.
What can I do?

You need to do some more research. Blog is an alias, not a directory. This is an example of virtual hosts installation. You could use this installation to run more than one WordPress site by creating other virtualhosts. Create the relevant files with the correct naming convention and you would/could have say localhost/music.

Create /etc/apache2/sites-available/mysite.conf and set an alias to /music with the appropriate virtualhost block along with a /config-mysite.php and enabling mysite as a site and soon you should be on your way to opening http://mysite.

I’m just trying to follow this guide. then all of a sudden I’m expected to know what to do.
How do I create a file?

I don’t use linux / unix everyday and I’ve never used Wordpress.

“Create Apache site for WordPress. Create /etc/apache2/sites-available/wordpress.conf with following lines:”

Ignore the above post about having a Wordpress Site that is unable to use plugins. Admitted, this tutorial does assume a lot (if you know nothing about Ubuntu). Fortunately, I know everything about Ubuntu and if you did follow this tutorial and WERE able to install Ubuntu, everything will work. The author of the post didn’t know enough about Ubuntu, got frustrated, and made his post hoping to either denigrate the author, the tutorial, or both. If he would had read the tutorial a couple more times he might have figured out it was a simple path or permission issue. Those who knew Ubuntu immediately noticed this issue and fixed it on the fly, as it was knowledge he/she had taken for granted through their years of use with Ubuntu.

Plugins work just fine. Make sure you do the ‘chown -R www-data:www-data /usr/share/wordpress’. Yes that line is different than what’s in the tutorial. It is simply a more complete way to set permissions. Chances are that setting the user ownership will be enough, however, in some instances you MAY need the group ownership to be properly set. If not, then you might complain plugins don’t work.

The other possible issue you might have while using this tutorial (with some admitted assumptions) is the issue of pointing the wordpress symlink at /var/www as opposed to pointing at /var/www/html. This unfortunately is another one of those possible assumpition things.

Finally, there was some droning on about /blog not being a directory in the Unix file system. That is correct, if you followed through the tutorial you will know at no time is the a creation of some directory name ‘blog’. This is a symbolic name that is used in the configuration file. It may or MAY NOT actually exist as a directory in your file system.

It’s just a matter of how much you know or don’t know. But just because something doesn’t work because you thought you followed instructions to the ‘t’ probably has more to do with your lack of knowledge of the overall subject.

This guide was not called a comprehensive guide. But I can guarantee you anyone who has used/administered a Ubuntu box for at least a year will have easily set their WordPress site up with the aid of these instructions supplemented by their knowledge of their own system.

I do help with this stuff, but unfortunately for most, I do it professionally on a pay basis, have Ubuntu servers up on the internet now you can peruse (i have a publicly available ubuntu shell server for responsible people) and look at active production servers and how they are configured. Contact me personally if you would like to know more.

The guy who wrote the tutorial needs to be thanked for all the time and effort he put into it. It has helped thousands of people get working sites. Just because 1 guy couldnt figure out how to do something has more to do with that one guy than it does this tutorial.

I’m such a softee. I just can’t help sticking up for people.