The Perfect Server - Ubuntu Lucid Lynx (Ubuntu 10.04) [ISPConfig 2] - Page 6

17 Apache/PHP5/Ruby/Python/WebDAV

Now we install Apache:

aptitude install apache2 apache2-doc apache2-mpm-prefork apache2-utils apache2-suexec libexpat1 ssl-cert

Next we install PHP5, Ruby, and Python (all three as Apache modules):

aptitude install libapache2-mod-php5 libapache2-mod-ruby libapache2-mod-python php5 php5-common php5-curl php5-dev php5-gd php5-idn php-pear php5-imagick php5-imap php5-mcrypt php5-memcache php5-mhash php5-ming php5-mysql php5-pspell php5-recode php5-snmp php5-sqlite php5-tidy php5-xmlrpc php5-xsl

Next we edit /etc/apache2/mods-available/dir.conf:

vi /etc/apache2/mods-available/dir.conf

and change the DirectoryIndex line:

<IfModule mod_dir.c>

          #DirectoryIndex index.html index.cgi index.php index.xhtml index.htm
          DirectoryIndex index.html index.htm index.shtml index.cgi index.php index.php3 index.xhtml


Now we have to enable some Apache modules (SSL, rewrite, suexec, include, and WebDAV):

a2enmod ssl
a2enmod rewrite
a2enmod suexec
a2enmod include
a2enmod dav_fs
a2enmod dav

Restart Apache:

/etc/init.d/apache2 restart

We have to fix a small problem with Ruby. If you install ISPConfig and enable Ruby for a web site, .rbx files will be executed fine and displayed in the browser, but this does not work for .rb files - you will be prompted to download the .rb file - the same happens if you configure Ruby manually for a vhost (i.e., it has nothing to do with ISPConfig). To fix this, we open /etc/mime.types...

vi /etc/mime.types

... and comment out the application/x-ruby line:

#application/x-ruby                             rb

Restart Apache:

/etc/init.d/apache2 restart

Now .rb files will be executed and displayed in the browser, just like .rbx files.

In the next chapter (17.1) we are going to disable PHP (this is necessary only if you want to install ISPConfig on this server). Unlike PHP, Ruby and Python are disabled by default, therefore we don't have to do it.


17.1 Disable PHP Globally

(If you do not plan to install ISPConfig on this server, please skip this section!)

In ISPConfig you will configure PHP on a per-website basis, i.e. you can specify which website can run PHP scripts and which one cannot. This can only work if PHP is disabled globally because otherwise all websites would be able to run PHP scripts, no matter what you specify in ISPConfig.

To disable PHP globally, we edit /etc/mime.types and comment out the application/x-httpd-php lines:

vi /etc/mime.types

#application/x-httpd-php                                phtml pht php
#application/x-httpd-php-source                 phps
#application/x-httpd-php3                       php3
#application/x-httpd-php3-preprocessed          php3p
#application/x-httpd-php4                       php4
#application/x-httpd-php5                       php5

Edit /etc/apache2/mods-enabled/php5.conf and comment out the SetHandler lines:

vi /etc/apache2/mods-enabled/php5.conf

<IfModule mod_php5.c>
    <FilesMatch "\.ph(p3?|tml)$">
        #SetHandler application/x-httpd-php
    <FilesMatch "\.phps$">
        #SetHandler application/x-httpd-php-source
    # To re-enable php in user directories comment the following lines
    # (from <IfModule ...> to </IfModule>.) Do NOT set it to On as it
    # prevents .htaccess files from disabling it.
    <IfModule mod_userdir.c>
        <Directory /home/*/public_html>
            php_admin_value engine Off

Then restart Apache:

/etc/init.d/apache2 restart


18 Proftpd

In order to install Proftpd, run

aptitude install proftpd ucf

You will be asked a question:

Run proftpd: <-- standalone

For security reasons add the following lines to /etc/proftpd/proftpd.conf (thanks to Reinaldo Carvalho; more information can be found here:

vi /etc/proftpd/proftpd.conf

DefaultRoot ~
ServerIdent on "FTP Server ready."

ISPConfig expects the configuration to be in /etc/proftpd.conf instead of /etc/proftpd/proftpd.conf, therefore we create a symlink (you can skip this command if you don't want to install ISPConfig):

ln -s /etc/proftpd/proftpd.conf /etc/proftpd.conf

Then restart Proftpd:

/etc/init.d/proftpd restart

Share this page:

11 Comment(s)

Add comment


From: scristi at: 2010-04-30 13:31:08

do you have any idea how i could install php 5.2 instead of 5.3 (because some of the software i run doesn't work on php 5.3), i could probably compile it from source, but i'm afraid of the incompatibilities, so i would like to use the previous version of php, that karmic koala used, that is in the repositories

From: Taarik at: 2010-05-15 11:16:17

Hi, You can try the script posted at  The script works fine (I think)...the only problem is that PHP is not automatically added-back to Apache. When I do  ls /etc/apache2/mods-enabled/, PHP doesn't appear.

From: Anonymous at: 2010-05-21 17:23:49

The screenshots are fine, but can't you make them optional (you know, a button or something?) and put in a Table of Contents? It is hard to find the actual information I need without viewing all the fluff.

From: Anonymous at: 2011-07-18 20:23:53

Can we have a button that only shows screenshots?  It's hard to get to the good stuff without all that annoying text in the way.

From: Anonymous at: 2010-09-08 10:02:02

Thank you for taking the time to write this out!

From: Anonymous at: 2012-04-19 00:44:12

Thank you for the screenshots. And for the person whining about getting through the fluff, you should be thanking the person who took time out to post screenshots. If you disagree I would like to see you do a better job before being critical of someone else efforts.

From: Anonymous at: 2010-05-12 16:01:18

Just want to give you the right address to Putty:

(The www was missing).


From: at: 2010-07-15 12:24:21

sudo su - (su dash) assumes roots' homedir rather than the users'.

From: Heidi Munksgaard at: 2010-12-06 21:03:50

Hi Falko!

Have been struggeling with setting up my Ubuntu server untill I came across this fantastic tutorial.

Just wanted to point out a little typo in the line:

"openssl x509 -req -days 3650 -in smtpd.csr -signkey smtpd.key -out smtpd.crt"

in the section for making TLS certificates. 

the " -in smtpd.csr -signkey smtpd.key -out smtpd.crt" part will give an error of:

"smtpd.csr; No such file or directory."

You need to change the name from "smtpd.csr" to "smtpd.crt" in the "-in smtpd.csr" part in order to avoid this error.


Heidi Munksgaard

From: DaGeek247 at: 2010-12-31 20:02:31

i love the tutorial, but i also now understand why programs like xampp  are out there. making your own server is tough.

I am wondering, is there like a shell script (for ubuntu users) that would do all this on its own? The user would have to watch the screen and whatnot, but it would help me alot. i frequently run into types and other problems.

From: Pete Gross at: 2010-05-26 00:25:02

After I did your howto  I tried to connect to https://localhost and got an error of " Error code: ssl_error_rx_record_too_long"


I figured the problem out, I just had to run: sudo a2ensite default-ssl 


I'd suggest adding this into your howto, so others don't have the same problem.


Thanks the howto was great!