How To Install and Configure WordPress on Ubuntu 14.04

Post Reply
User avatar
Site Admin
Site Admin
Posts: 584
Joined: Fri Jul 31, 2009 6:27 pm
Are you a filthy spam bot?: No
Location: Behind You

How To Install and Configure WordPress on Ubuntu 14.04

Post: # 424Post LHammonds
Thu Feb 18, 2016 4:42 pm

Greetings and salutations,

I hope this thread will be helpful to those who follow in my foot steps as well as getting any advice based on what I have done / documented.

This is a Work-In-Progress topic so I will be updating this thread as I learn more about Ubuntu and WordPress.

To discuss this thread, please participate here: Ubuntu Forums

High-level overview

This thread will cover installation of a dedicated Ubuntu server, Apache Web service and WordPress web site. The server will be installed inside a virtual machine vSphere 5.5 running on ESXi 5.5 servers. Although there are some VMware-specific steps, they are very few and the majority of this documentation will work for other VMs such as VirtualBox or even directly installed onto a physical machine. If you have any advice on doing things better, please let me know. I love feedback and learning better ways of doing things!

After Ubuntu Server is installed, Apache web server will be installed and configured. Next will be the installation and configuration of WordPress which will utilize an existing remote MySQL server.

Tools utilized in this process
Helpful links

The list below are sources of information that helped me configure this system as well as some places that might be helpful to me later on as this process continues.

This documentation will need to make use of some very-specific information that will most-likely be different for each person / location. And as such, I will note some of these in this section. They will be highlighted in red throughout the document as a reminder that you should plug-in your own value rather than actually using my "place-holder" value.

Under no circumstance should you use the actual values I list below. They are place-holders for the real thing. This is just a checklist template you need to have answered before you start the install process.

Wherever you see RED in this document, you need to substitute it for what your company uses. Use the list below as a template you need to have answered before you continue.
  • Ubuntu Server name: srv-wordpress
  • Internet domain:
  • Ubuntu Server IP address:
  • Ubuntu Server IP subnet mask:
  • Ubuntu Server IP gateway:
  • Internal DNS Server 1:
  • Internal DNS Server 2:
  • External DNS Server 1:
  • External DNS Server 2:
  • Ubuntu Admin ID: administrator
  • Ubuntu Admin Password: myadminpass
  • Email Server (remote):
  • MySQL Server (remote):
  • MySQL root Password: mysqlrootpass
  • MySQL WordPress user: wordpressuser
  • MySQL WordPress Password: mysqlwordpresspass
  • Windows Share ID: wordpressshare
  • Windows Share Password: mywordpresssharepass
I also assume the reader knows how to use the VI editor. If not, you will need to beef up your skill set or use a different editor in place of it.

Installation of Ubuntu Server

This documentation will assume you have installed Ubuntu Server according to this article: How To Install Ubuntu Server

Installation of MySQL Server

This documentation will assume you have installed a separate and dedicated MySQL server according to this article: How To Install MySQL/MariaDB

On your WordPress server, be sure to add a host entry that points to your MySQL server in /etc/hosts. srv-mysql
MySQL Database Creation

A database and user account need to be created on the database server.

Use PuTTY to connect to your database server and type the following commands:
mysql CREATE DATABASE wordpress; CREATE USER wordpressuser; SET PASSWORD FOR 'wordpressuser'@'%'=PASSWORD('wordpressuserpassword'); GRANT ALL PRIVILEGES ON wordpress.* TO wordpressuser IDENTIFIED BY 'wordpressuserpassword'; FLUSH PRIVILEGES; exit
Apache Web Server Installation

  1. Connect to the SRV-WordPress server using PuTTY.
  2. At the login prompt, login with your administrator account (administrator / myadminpass) and then temporarily grant yourself super user privilages by typing sudo su
  3. Type the following commands:
    aptitude -y install apache2 php5 libapache2-mod-php5 php5-mysql libssh2-php php5-tidy php5-curl aptitude -y install php5-gd php5-xmlrpc php5-mcrypt php5-pspell php5-imagick php5-imap php5-xsl php5enmod imap php5enmod json php5enmod mcrypt
  4. If you plan on utilizing email functions (and who doesn't!!!), type the following commands:
    aptitude -y install php-pear pear install mail pear install Net_SMTP
  5. Restart the Apache service:
    service apache2 restart
  6. Create the following file: /var/www/phpinfo.php
    <?php phpinfo(); ?>
  7. To verify that Apache is running and working, open a web browser and go to and you should see a web page that says "It works!"
  8. To verify that PHP is running, open a web browser and go to and you should see a long web page showing PHP configuration information along with a mysql and mysqli sections.
Add Web Site Icon

If you want a custom icon to show up to the left of URL in the address bar, you need to follow these steps.

  1. Create a 16x16 image that is 16 colors (4-bit) with dimensions of 16x16 pixels and save it as a .BMP file called favicon.bmp
  2. Use your favorite icon editor to convert the BMP image to an ICO file. (e.g. IrfanView)
  3. Copy favicon.ico to \\\share
  4. Connect to the SRV-WordPress server using PuTTY.
  5. At the login prompt, login with your administrator account (administrator / myadminpass) and then temporarily grant yourself super user privilages by typing sudo su
  6. Type the following commands:
    mv /srv/samba/share/favicon.ico /var/www/html/. chown www-data:root /var/www/html/favicon.ico chmod 0755 /var/www/html/favicon.ico
  7. Edit /etc/apache2/httpd.conf and add the following line:
    AddType image/x-icon .ico
  8. Restart the Apache web server by typing service apache2 restart
  9. Once that is done, open a web browser and go to and refresh the page. You should see your icon to the left of the URL in the address bar.
Install WordPress

Now we are going to download the WordPress archive and extract it to our site and setup the correct permissions.
cd /tmp wget tar -xvzf /tmp/latest.tar.gz -C /var/www/html/ cp /var/www/html/wordpress/wp-config-sample.php /var/www/html/wordpress/wp-config.php mkdir /var/www/html/wordpress/wp-content/uploads chown www-data:root --recursive /var/www/html/* find /var/www/html/. -type d -exec chmod 755 '{}' \+ find /var/www/html/. -type f -exec chmod 644 '{}' \+ chmod 0755 /var/www/html/favicon.ico service apache2 restart
Configure WordPress

We need to modify the configuration so it points to our database server with the correct database name and user credentials.
  1. Edit /var/www/html/wordpress/wp-config.php and make the following changes:
    define('DB_NAME', 'wordpress'); define('DB_USER', 'wordpressuser'); define('DB_PASSWORD', 'mysqlwordpresspass'); define('DB_HOST', 'srv-mysql');
  2. Open a web browser and go to
  3. You should see the initial "Welcome" page where you setup your initial settings. Do so and click the "Install WordPress" button at the bottom.
Active Directory Authentication

I would like AD autentication to reduce the number of places where IDs and passwords are stored but chose not to do so because of the security risks noted in this article:

Apache and Active Directory

WordPress Plugins

Once you get logged into your WordPress dashboard, you might want to add a few plugins.

It is a simple matter of clicking on the "Plugins" link to the left on your dashboard and then click "Add New", find/select a plugin and then activate it.

Here are some plugins I like to use which suit my environment:
  • Local Avatars by Peter Sterling
  • Event Calendar / Scheduler by DHTMLX LTD
  • NextGEN Gallery by Photocrafti Media
  • Smart Youtube PRO by Vladimir Prelovac
  • WPtouch Moble Plugin by BraveNewCode
Web Developer Access

Let's say you have a user John Doe that needs access to the web files, here is how you can allow him access to upload files to the site.

Create a user called jdoe and set his home folder to the root of the web site and make him part of the group that the web service belongs to:
sudo useradd -d /var/www/html -G www-data jdoe
Now set his password:
sudo passwd jdoe
If jdoe already exists on your server, you can instead modify his account:
sudo usermod -a -G www-data jdoe
If jdoe already exists, you probably don't want to mess with his existing home directory setting but if you do, this is how you do it:
sudo usermod -d /var/www/html jdoe
The last thing to do is to make sure the web site is group-writable and to set the setgid sticky bit permission on the website's root directory to ensure any files created will inherit the group ID from the parent directory. That means when John Doe uploads an html file, it will belong to the www-data group which is the same as the web service and allows the web server to display that file rather than an access denied error.
sudo chmod -R g+w /var/www/html sudo chmod g+s /var/www/html

Post Reply