How to install Wordpress 4.5 on Ubuntu 16.04 LAMP
This tutorial exists for these OS versions
- Ubuntu 16.04 (Xenial Xerus)
- Ubuntu 14.04 LTS (Trusty Tahr)
On this page
This document describes how to install and configure Wordpress 4.5 on Ubuntu 16.04. WordPress started in 2003 with a single bit of code to enhance the typography of everyday writing and with fewer users than you can count on your fingers and toes. Since then it has grown to be the largest self-hosted blogging tool in the world, used on millions of sites and seen by tens of millions of people every day. This tutorial explains the process of installing Wordpress 4.5 on Ubuntu 16.04 in the form of a simple-to-follow guide.
1 Preliminary Note
This tutorial is based on the Ubuntu 16.04 server installation CD. You have to set up a basic Ubuntu 16.04 (Xenial Xerus) server installation before you continue with this tutorial. The system should have a static IP address. I use 192.168.1.100 as my IP address in this tutorial and server1.example.com as the hostname. The server must have a LAMP server installed in Ubuntu 16.04 e.g. as described in this tutorial before you proceed.
2 WordPress Database initialization
I will create the database for Wordpress as follows. Login to the MySQL or MariaDB database as root user:
mysql -u root -p
And create a database with the name wordpressdb, a user with the name wordpressuser and the password wordpresspassword. Please use different and secure password on your installation, the password used here is just an example!
CREATE DATABASE wordpressdb;
CREATE USER wordpressuser@localhost IDENTIFIED BY 'wordpresspassword';
GRANT ALL PRIVILEGES ON wordpressdb.* TO wordpressuser@localhost;
Then exit the MySQL shell:
FLUSH PRIVILEGES;
exit
Restart services
service apache2 restart
service mysql restart
3 Installation of WorPpress 4.5
Go to the /tmp directory in which we will the download the latest version of the WordPress as follows:
cd /tmp
wget http://wordpress.org/latest.zip
We have to install unzip to unpack the WordPress archive:
apt-get install unzip
Unzip the WordPress zip archive in the /var/www/html folder:
unzip -q latest.zip -d /var/www/html/
Now set appropriate permissions for the WordPress directory.
chown -R www-data:www-data /var/www/html/wordpress
chmod -R 755 /var/www/html/wordpress
Further, we need to create the uploads directory beneath the wp-content directory at our document root. This will be the parent directory of our content:
mkdir -p /var/www/html/wordpress/wp-content/uploads
We need to allow the web server itself to write to this directory. We can do this by assigning user and group ownership of this directory to our web server user www-data. This will allow the web server to create files and directories under this directory, which will permit us to upload content to the server. Proceed like this:
chown -R www-data:www-data /var/www/html/wordpress/wp-content/uploads
Now proceed to the web installation of Wordpress. Go to the URL http://192.168.1.100/wordpress/ in your web browser. The WordPress installer will show up.
Select language and press Continue:
The welcome screen shows up in the selected language. Click on Let's go.
Type in the Login details of the WordPress database that we created in step 2. The database host is "localhost" and the prefix can be left at its default. Then click on the "Submit" button.
Wordpress saves the database configuration details to the file /var/www/html/wordpress/wp-config.php. Click on "Run the install" to proceed to the next part of the installer.
Now enter some details for the Blog like website title, admin username, password and email address. I used these values:
Site Title = My Wordpress Blog Admin Email = [email protected] Username = admin Admin password = howtoforge
The above values are just examples and you should use the real title and email address here. Using admin as administrator name is ok for an internal website but you might want to use a nonstandard name or your personal name instead.
The press InstallWordpress to finish the installation:
Now we will proceed towards the login page by pressing LogIn:
Type in the credentials that you selected during WordPresspress installation. The WordPress Dashboard will show up.
6 Configure Pretty Permalinks for WordPress
This part is optional.
By default, WordPress creates URLs dynamically that look something like this http://server_domain_name_or_IP/?p=1. This isn't exactly the most useful interface for visitors or search engines, so most users want to modify this. WordPress has the ability to create "pretty" permalinks which will clean up the URL into a more human-friendly format. The following steps show you how to setup pretty permalinks in your WordPress Blog.
6.1 Apache Rewrite
We will modify the apache virtual host file for Wordpress 4.5 to allow .htaccess overrides. Add the following (red) lines in the 000-default.conf file:
nano /etc/apache2/sites-available/000-default.conf
[...]
ServerAdmin webmaster@localhost DocumentRoot /var/www/html ServerName server1.example.com <Directory /var/www/html/> AllowOverride All </Directory> [...]
Next, we have to to enable the Apache rewrite module. Run:
a2enmod rewrite
service apache2 restart
6.2 Permalink Settings in WordPress
Now we can easily adjust the permalink settings through the WordPress administration interface. Go to Settings-->Permalinks:
I'll choose "Post name" as Pretty-Link format for my blog so that the Post title is used in the URL.
When you have made your selection, click "Save Changes" to generate the rewrite rules.
Congratulations! You now have a fully functional WordPress 4.5 instance on your Ubuntu 16.04 :)
7 Links
- Wordpress : http://wordpress.org/
- Ubuntu : http://www.ubuntu.com/