Initial installation Ubuntu Server

Last time I configured my web server with Ubuntu Server, I had problems finding all the instructions on what and how to install everything needed to get a WordPress blog with W3 Total Cache, CDN, Apache2 MPM Worker and fcgi working. So this is my attempt to write down the steps needed to get the server going. You might find it of interest if your needs are similar to mine. Here’s the requirements for my WordPress blog.

  • Apache MPM Worker threaded version
  • APC PHP Opcode optimizer
  • All the required modules for W3 Total Cache
  • Graphics libraries for Mint statistics

I’m not going to describe the basic install. There’s a lot of pages available to help you with that. Just remember to enable LAMP Server software during the install process.

After the install, let’s first make sure everything is up to date.

apt-get update

sudo apt-get update 
sudo apt-get upgrade

Set ip-number

First we need to set a static IP-adress. In the terminal, edit the file /etc/network/interfaces

sudo pico /etc/network/interfaces

There should be a line that looks like this (depending on your ethernet port your using).

iface eth0 inet dhcp

Change it to:

iface eth0 inet static address 192.168.1.100 netmask 255.255.255.0 network 192.168.1.0 broadcast 192.168.1.255 gateway 192.168.1.1

You need to use the ip-numbers for your network.

DNS

Change /etc/resolv.conf to your name servers

nameserver 8.8.8.8
nameserver 8.8.4.4
nameserver 192.168.1.1

In this case I’m using Googles DNS servers and as a fallback my routers DNS caching DNS server.

Remove resolvconf for dhcp with

apt-get remove resolvconf

otherwise resolve.conf will be overwritten at every reboot.

SSH

Use SSH to login to your web server, and use SFTP to send files.

sudo apt-get install ssh

login ssh without password

To make login via SSH easier and to make it simple to connect to the server remotely for backup, set it up so you can login without a password

Wordpress installation

Because I’m not going to have multiple domains on my server there’s no need to do a multiple site setup. I just use the default location /var/www for my files. Just go to the WordPress home page and follow the instructions on how to install it in that location. After that you have to install the plugins you need. The plugins I use are:

  • W3 Total Cache – for speeding up the site
  • All in One SEO Pack – For making the pages more SEO friendly
  • WordPress SEO Plugin – SEO optimisations and Sitemap creation
  • BWP Google XML Sitemaps – Creates the Sitemap files for search engines
  • CodeColorer – Beautifies code
  • Disqus Comment System – A connected comment system with easy login
  • Efficient Related Posts – Shows related posts that might interest the reader
  • Yet Another Related Posts Plugin (YARPP) – Shows related posts that might interest the reader
  • Google Custom Search Plugin – I use Google Search instead of the built-in search to minimize the load on the server
  • Minty – Adds the necessary javascript for keeping Mint statistics
  • Permalink Redirect – I’ve changed my permalink structure so this redirects with a 301 code to the new location
  • Robots Meta – Allows you to control meta tags and add nofollow to tags or archives
  • SEO Friendly Images – Adds missing info in pictures
  • SEO Slugs – Makes the URL more SEO friendly
  • TentBlogger Optimize WordPress Database Plugin – Makes it real easy to optimize the MySQL database
  • WP Smush.it – Makes sure to compress uploaded images optimally
  • WPtouch – Adds a mobile theme for iPhone, iPad and Android devices

install ftp

Wordpress comes with an automatic update function to make it easier to do updates of WordPress and plugins. To use it, I install FTP on the machine. But remember, don’t have the FTP ports open directly, only use it if you have your machine behind a firewall. FTP is not secure, so it’s much better to use sftp for uploading and editing files.

sudo apt-get install vsftpd

Edit /etc/vsftpd.conf

local_enable=YES
write_enable=YES

Change anonymous_enable=YES to NO

I had problems after installing vsftpd refusing to let local users login. Apparently it’s a bug. Here’s a fix:

sudo apt-get remove vsftpd
sudo rm /etc/pam.d/vsftpd
sudo apt-get install vsftpd

After doing that, everything worked fine.

Apache2 mpm worker

I’m using the faster threaded version of Apache, called Apache2 mpm worker.

Faster threaded apache2

sudo apt-get install apache2-mpm-worker libapache2-mod-fcgid

Enable fcgid

sudo a2enmod fcgid
sudo apt install php5-cgi php5-cli

Add the following to /etc/apache2/httpd.conf or place these basic configuration settings in a file under /etc/apache2/conf.d. For example, /etc/apache2/conf.d/00-myconf (“00-” will help insure it is read first before other /etc/apache2/conf.d files, which is necessary).

Code:

AddHandler fcgid-script .php FCGIWrapper /usr/lib/cgi-bin/php5 .php Options +ExecCGI

AddHandler fcgid-script .php FCGIWrapper /usr/lib/cgi-bin/php5 .php Options ExecCGI FollowSymlinks Indexes

Apache mods

WordPress and W3 Total Cache needs some Apache modules, so let’s enable them.

sudo a2enmod rewrite
sudo a2enmod expires
sudo a2enmod headers

required for wordpress with W3 total cache

cURL required for Amazon S3, Amazon CloudFront, Rackspace CloudFiles support.

sudo apt-get install curl php5-curl

HTML Tidy for minify

To be able to use the minify function of W3 Total Cache you need to install php5-tidy.

sudo apt-get install php5-tidy

GD graphics library for spark lines in mint

I use Google Analytics for my statistics, but I also have Mint, because it’s quick to get a glance of the incoming traffic. But to get the Sparks Pepper to work you need to install the GD library.

sudo apt-get install libgd2-xpm
sudo apt-get install php5-gd

Opcode cache

Alternative PHP Cache is a free, open source (PHP license) framework that optimizes PHP intermediate code and caches data and compiled code from the PHP bytecode compiler in shared memory.

Using this will speed up the execution time of PHP code.

APC http://pecl.php.net/package/APC

apt-get install php-apc

MySQL and blog backup

In the next installment I’ll walk you through how to setup an external backup of your WordPress blog.

Stay tuned.