How to install an Ubuntu based Web Server

By | May 24, 2009

I recently upgraded my old VPS, which was running with Ubuntu 6.06, to a fresh new Hardy Heron version. That gave me the opportunity to make a clean installation and configuration and then transfer my websites to the new server.

Hint: I did all the install and update stuff as root user. If you have another user with sudo rights, then apply a sudo before most of the commands here.

Updating the Apt

First step I did was updating the packages.

apt-get update
apt-get upgrade

LAMP

After that i installed the primary components, like Apache, PHP5 and MySQL:

First the webserver itself:

apt-get install apache2

I installed additional Apache modules. An easy way to do that is to use a3enmod:

a2enmod ssl
a2enmod rewrite
a2enmod suexec
a2enmod include

Just don’t forget to reload your apache afterwards:

/etc/init.d/apache2 force-reload

Afterwards install PHP5:

apt-get install php5
apt-get install php5-cli
apt-get install php5-dev
apt-get install php-pear

Some more PHP5 modules are following later.

PEAR is a package repository which enables you to install additional PHP package libraries.

To make sure that my link to PEAR is up to date, I use the following command:

pear channel-update pear.php.net

Installing MySQL is rather simple:

apt-get install mysql-client mysql-server libmysqlclient15-dev

Afterwards you get asked to enter a MySQL root password. Make sure to keep that one safe!

I say I need some more PHP5 modules, so here they come:

apt-get install php5-gd
apt-get install php5-mcrypt
apt-get install php5-imagick
apt-get install php5-curl
apt-get install php5-xmlrpc php5-xsl
apt-get install php5-mhash

Additional tools

To create statistics based on my webserver’s log files, I use awstats:

apt-get install awstats

Just make sure that the folder /usr/lib/cgi-bin is password protected (or move the file awstats.pl to a more secure location.

Configuration of awstats is another topic, I don’t want to talk too much about right now. There is an example file in the folder /etc/awstats just digg through it 🙂

To keep the server time up to date you can install ntp:

apt-get install ntp ntpdate

Now there is always the correct time on your server.

Finally

I did some more stuff but those are the basics to install on a fresh web server. Another hint: make sure your server is able to send mails to the outside world (maybe install another MTA, but make sure only the server itself can relay mails, unless you want to use the server as SMTP server as well).

If you have anything to add to this howto, I am happy for every comment on it.

Kommentare

Kommentare