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
[cc lang=”bash”]sudo apt-get update
sudo apt-get upgrade[/cc]
Set ip-number
First we need to set a static IP-adress. In the terminal, edit the file /etc/network/interfaces
[cc lang=”bash”]sudo pico /etc/network/interfaces[/cc]
There should be a line that looks like this (depending on your ethernet port your using).
[cc lang=”bash”]iface eth0 inet dhcp[/cc]
Change it to:
[cc]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
[/cc]
You need to use the ip-numbers for your network.
DNS
Change /etc/resolv.conf to your name servers
[cc]nameserver 8.8.8.8
nameserver 8.8.4.4
nameserver 192.168.1.1
[/cc]
In this case I’m using Googles DNS servers and as a fallback my routers DNS caching DNS server.
Remove resolvconf for dhcp with
[cc lang=”bash”]apt-get remove resolvconf[/cc]
otherwise resolve.conf will be overwritten at every reboot.
SSH
Use SSH to login to your web server, and use SFTP to send files.
[cc lang=”bash”]sudo apt-get install ssh[/cc]
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 loginEfficient 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 statisticsPermalink Redirect – I’ve changed my permalink structure so this redirects with a 301 code to the new locationRobots 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.
[cc lang=”bash”]sudo apt-get install vsftpd
[/cc]
Edit /etc/vsftpd.conf
[cc lang=”bash”]local_enable=YES
write_enable=YES
[/cc]
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:
[cc lang=”bash”]sudo apt-get remove vsftpd
sudo rm /etc/pam.d/vsftpd
sudo apt-get install vsftpd
[/cc]
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
[cc lang=”bash”]sudo apt-get install apache2-mpm-worker libapache2-mod-fcgid[/cc]
Enable fcgid
[cc lang=”bash”]sudo a2enmod fcgid
sudo aptitude install php5-cgi php5-cli
[/cc]
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:
[cc lang=”apache”]
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
[/cc]
Apache mods
WordPress and W3 Total Cache needs some Apache modules, so let’s enable them.
[cc lang=”bash”]sudo a2enmod rewrite
sudo a2enmod expires
sudo a2enmod headers
[/cc]
required for wordpress with W3 total cache
cURL required for Amazon S3, Amazon CloudFront, Rackspace CloudFiles support.[cc lang=”bash”]sudo apt-get install curl php5-curl
[/cc]
HTML Tidy for minify
To be able to use the minify function of W3 Total Cache you need to install php5-tidy.
[cc lang=”bash”] sudo apt-get install php5-tidy
[/cc]
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.
[cc lang=”bash”]sudo apt-get install libgd2-xpm
sudo apt-get install php5-gd
[/cc]
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
[cc lang=”bash”]apt-get install php-apc[/cc]
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.
Guest says
Thank you for great tips Jacken. You used Google DNS.. in my thought, it can make come trouble if someone makes webserver as a mail server.. Google and Hotmail check the sender’s DNS… Anyway, Thank you for your articles.. They’re all really wonderful. I love hifi, server.. also..
Guest says
Thank you for great tips Jacken. You used Google DNS.. in my thought, it
can make come trouble if someone makes webserver as web + mail server..
Google and Hotmail check the sender’s DNS… Anyway, Thank you for your
articles.. They’re all really wonderful. I love hifi, server.. also..
Junseok, Bae says
Thank you for great tips Jacken. And sorry for my 2 comments below(I deleted but they remain.. it may be the bug of DISQUS..). You used Google DNS.. in my thought, it
can make come trouble if someone makes webserver as a mail server..
Google and Hotmail check the sender’s DNS… Anyway, Thank you for your
articles.. They’re all really wonderful. I love hifi, server.. also..