Monday, September 6, 2010

How To Set Up Apache2 With mod_fcgid And PHP5 On Ubuntu 10.04

Follow me on Twitter
Last edited 08/18/2010

This tutorial describes how you can install Apache2 with mod_fcgid and PHP5 on Ubuntu 10.04. mod_fcgid is a compatible alternative to the older mod_fastcgi. It lets you execute PHP scripts with the permissions of their owners instead of the Apache user.

I do not issue any guarantee that this will work for you!

 

1 Preliminary Note

I'm using an Ubuntu 10.04 server in this tutorial with the hostname server1.example.com and the IP address 192.168.0.100.

I will create two Apache vhosts in this tutorial, www.example1.com and www.example2.com, to demonstrate the usage of mod_fcgid.

Make sure you're logged in as root:

sudo su

/bin/sh is a symlink to /bin/dash, however we need /bin/bash, not /bin/dash. Therefore we do this:

dpkg-reconfigure dash

Install dash as /bin/sh? <-- No

In addition to that, we must disable AppArmor:

/etc/init.d/apparmor stop
update-rc.d -f apparmor remove
aptitude remove apparmor apparmor-utils

 

2 Installing Apache2/mod_fcgi/PHP5

In order to install Apache2, mod_fcgid, and PHP5, run

aptitude install apache2 apache2-suexec libapache2-mod-fcgid php5-cgi

If Apache2 was already installed with PHP5 as an Apache module, disable the PHP5 module now:

a2dismod php5

Then enable the following modules...

a2enmod rewrite
a2enmod suexec
a2enmod include
a2enmod fcgid

... and open /etc/php5/cgi/php.ini:

vi /etc/php5/cgi/php.ini

Uncomment the line cgi.fix_pathinfo

No comments:

Post a Comment