Configuring a Debian Sarge Server, Part II

By | September 2, 2007

Today it’s time to post the second in the series of how to configure your own VPS (Virtual Private Server). For the basics on setting up Apache and the configuring the server see part I of configuring a debian server.

In this part I’ll guide you through setting up PHP and MySQL. Which I believe are the basic things you’ll need for running any kind of webserver. And yes I know ASP is also beautifull, it’s just useless on Linux sofar.

Installing PHP
First the easy things. Installing PHP is probably one of the easiest steps. Just update your apt cache by running the following command:

:> apt-get update

Though this may not always be necessary, it’s better to update then get a nasty suprise later on. After this you should be able to search for PHP5. Why use version 5 rather then 4, well because there’s a rumor going round that support is being dropped for version 4. So lets install the needed libraries:

:> apt-install php5 php5-mysql

If everything goes correctly this will also install MySQL v14.12, it at least did that for me. Must be a dependancy for php5-mysql. However if it is not installed correctly then just run:

:> apt-install mysql-server5

Configuring PHP and MySQL
This step should be pretty straight forward since it’s pretty much done for you when installing the applications. However we just want to make sure about it. We first want to make sure that PHP is properly attached to Apache. This is done by adding (or checking if it already exists) the following lines to httpd.conf:

LoadModule php5_module /usr/lib/apache2/modules/
<IfModule mod_php5.c>
    AddType application/x-httpd-php .php .phtml .php3
    AddType application/x-httpd-php-source .phps

What this does is pretty simple. It loads the module and then attaches the .php extension to the module so that PHP now handles all requests ending on ‘.php‘.

To test if PHP is setup correctly you can create a page called ‘test.php’ in any of the websites you’ve configured in part 1 of the series. Add the following content to the page:

   echo phpinfo();

If everything is setup correctly you should see a listing of the configuration of PHP. If not then you need to walk through all the steps again to find the problem. If you’re still having problems after this then please post them and I’ll try and help you were ever I can.

Leave a Reply