Web-hosting is getting cheaper and cheaper, to the point where using a VPS (virtual private server) is a more viable option than ever before. The guide I’ll be focusing on in the coming weeks will turn your vanilla VPS hosting plan into a roaring beast.
In a nutshell by the end of this guide your VPS will have the following installed and configured:
- Nginx – Front-end cache. This will make your website blazingly fast, and use far less system resources than a typical web-serving environment
- Apache 2.2 & PHP 5.3 – back-end webserver for producing dynamic content
- Postfix – Sendmail alternative – set up as a SMTP relay through Gmail or another provider
- Monit – to automatically monitor server health and proactively restart services and send alerts if something fails
- Munin – server monitoring software to produce graphs and reports of server health
- Awstats – website statistics package for monitoring
- MySQL – database setup, including replication for automatic backups of databases
- Backups – Using rsync to backup a 1:1 copy of your entire server to an off-site location
- General configuration – grease the cogs, make everything super smooth
Part 1 : Apache & PHP
Without a web-service we can’t really do anything, so lets get something up and running. Get a shell on your VPS and elevate your privileges to root access before performing any of the following:
1) Install EPEL and IUS repos for Yum
These contain extra software packages which we’ll be using throughout the guide. These are for 64-bit CentOS 5, if you are looking for 32-bit change the ‘x86_64′ part of the URL to ‘i386′.
2) Use Yum to install PHP and Apache
Your hosting plan may have already come with installs for these. You can test by doing a ‘yum list installed httpd* php*’ — if you get any results it means you already have packages installed for these. You can either remove using ‘yum remove httpd* php*’ or continue onto Step 4 if you’d just like to configure.
Otherwise lets install Apache and PHP with several popular modules. Obviously if you require different modules you can install to suit – ‘yum list php53u*’ will show all that are available. At the time of writing the version on the IUS repo version for PHP is 5.3.6.
sudo yum install httpd php53u php53u-common php53u-gd php53u-ldap php53u-mcrypt php53u-mysql php53u-pear php53u-xml
3) Fire up Apache and test PHP is running
Believe it or not that’s all you’ll need to do to get a basic web server up and running. You can test everything is working by issuing the following commands:
echo "<?php phpinfo(); ?>" >> /var/www/html/index.php
/etc/init.d/httpd start
Now point a browser at your VPS’ IP address and you should be presented with a PHP info page. I won’t go into the intricacies of configuring Apache, but you can get started by simply placing your website in the /var/www/html/ folder for now. You may wish to remove the /var/www/html/index.php file once you’ve tested, as you generally don’t want the outside world seeing this info.

Hello there, just became aware of our blog through Google, and found that it’s really informative. I’m| going to watch out for brussels. I will be grateful if you continue this in future. A lot of Many people will be benefited from your writing. Cheers!
I Hope you can finish this great tutorial series. Nice job!
Hmm is anyone else experiencing problems with the images
on this blog loading? I’m trying to determine if its a problem on my end or if it’s the blog.
Any feed-back would be greatly appreciated.