How To Install and Configure WordPress on Ubuntu 12.04

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

How To Install and Configure WordPress on Ubuntu 12.04

Post by LHammonds » Fri Aug 30, 2013 8:23 am

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 4.1 running on ESXi 4.1 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.
Assumptions

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: mydomain.com
  • Ubuntu Server IP address: 192.168.107.30
  • Ubuntu Server IP subnet mask: 255.255.255.0
  • Ubuntu Server IP gateway: 192.168.107.1
  • Internal DNS Server 1: 192.168.107.212
  • Internal DNS Server 2: 192.168.107.213
  • External DNS Server 1: 8.8.8.4
  • External DNS Server 2: 8.8.8.5
  • Ubuntu Admin ID: administrator
  • Ubuntu Admin Password: myadminpass
  • Email Server (remote): 192.168.107.25
  • MySQL Server (remote): 192.168.107.20
  • 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

On your WordPress server, be sure to add a host entry that points to your MySQL server in /etc/hosts.
192.168.107.20 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
  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 http://192.168.107.30 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 http://192.168.107.30/phpinfo.php 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 \\192.168.107.30\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/. chown www-data:root /var/www/favicon.ico chmod 0755 /var/www/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 http://192.168.107.30 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 http://wordpress.org/latest.tar.gz tar -xvzf /tmp/latest.tar.gz -C /var/www/ chown www-data:root --recursive /var/www/* find /var/www/. -type d -exec chmod 755 '{}' \+ find /var/www/. -type f -exec chmod 644 '{}' \+ chmod 0755 /var/www/favicon.ico service apache2 restart
[/list]

Configure WordPress

We need to modify the configuration so it points to our database server with the correct database name and user credentials.
  1. Copy the config sample:
    cp /var/www/wordpress/wp-config-sample.php /var/www/wordpress/wp-config.php
  2. Edit /var/www/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');
  3. Open a web browser and go to http://192.168.107.30/wordpress
  4. 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

Post Reply

Who is online

Users browsing this forum: No registered users and 9 guests