Installing Mysql and Apache [part3]

Now we’re going to install mysql and apache and make a few changes so that they run OK in limited memory. I’m going to use the package manager to install them. You can compile and install them from source to get exactly what you want but be prepared to update them manually as bug and vulnerabilities are fixed.

First install apache and mysql using apt

sudo apt-get install apache2 php5 mysql-server mysql-client php5-mysql -y

Enter a root mysql password when prompted. Remeber what it is – you’ll need it.

Say No to allowing the old password method

If you setup the firewall as in the previous post you’ll need to run the following to allow web port 80 connections to your vps

sudo sed '/Allow connections/ a\iptables -A INPUT -p tcp -i eth0 --dport 80 -m state --state NEW -j ACCEPT' -i /usr/local/bin/

You should now be able to go to the default page for your apache installation by going to your server name in your web browser

Once we know it’s working we’ll shut Apache down for now

sudo /etc/init.d/apache2 stop

Next I need to change some settings for Mysql as I’ve only got 256MB memory. I’ll use the ‘medium’ configuration for now – I can always change some settings later

sudo gunzip /usr/share/doc/mysql-server-5.0/examples/my-medium.cnf.gz
sudo mv /etc/mysql/my.cnf /etc/mysql/my.cnf.orig
sudo cp /usr/share/doc/mysql-server-5.0/examples/my-medium.cnf /etc/mysql/my.cnf

and restart mysql for those changes to take effect

sudo /etc/init.d/mysql restart

I’m going to use Apache for WordPress which works nicely with mod_rewrite. To enable that run

sudo a2enmod rewrite

There’s a lot more we should do to secure Apache but that will have to be another post

This post is part of a 4 part series that goes from getting a vps, securing it, installing LAMP and installing WordPress.The 4 parts are –

Setting up a vps with [part1]

Securing my Ubuntu VPS [part2]

Installing WordPress on a VPS [part4]

My VPS was from and was running under XEN.

The configuration is 256Mb memory & 10Gb disk space for $18 a month.

The vps was provisioned with Ubuntu Fiesty Fawn but I upgraded that to the latest version – Gutsy Gibbon