How To Set Up Apache2 With mod_fcgid And PHP5 On Debian Etch
How To Set Up Apache2 With mod_fcgid And PHP5 On Debian EtchVersion 1.0 This tutorial describes how you can install Apache2 with mod_fcgid and PHP5 on Debian Etch. 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 NoteI'm using a Debian Etch 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.
2 Installing Apache2/mod_fcgi/PHP5In order to install Apache2, mod_fcgid, and PHP5, run apt-get install apache2 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 ... and open /etc/php5/cgi/php.ini: vi /etc/php5/cgi/php.ini Add the line cgi.fix_pathinfo = 1 right at the end of the file:
Then reload Apache: /etc/init.d/apache2 force-reload
3 Creating Vhosts For www.example1.com And www.example2.comI will now create two vhosts, www.example1.com (with the document root /var/www/web1/web) and www.example2.com (with the document root /var/www/web2/web). www.example1.com will be owned by the user and group web1, and www.example2.com by the user and group web2. First we create the users and groups: groupadd web1 Then we create the document roots and make them owned by the users/groups web1 resp. web2: mkdir -p /var/www/web1/web We will run PHP using suExec; suExec's document root is /var/www, as the following command shows: /usr/lib/apache2/suexec -V server1:~# /usr/lib/apache2/suexec -V Therefore we cannot call the PHP binary (/usr/lib/cgi-bin/php) directly because it is located outside suExec's document root. As suExec does not allow symlinks, the only way to solve the problem is to create a wrapper script for each web site in a subdirectory of /var/www; the wrapper script will then call the PHP binary /usr/lib/cgi-bin/php. The wrapper script must be owned by the user and group of each web site, therefore we need one wrapper script for each web site. I'm going to create the wrapper scripts in subdirectories of /var/www/php-fcgi-scripts, e.g. /var/www/php-fcgi-scripts/web1 and /var/www/php-fcgi-scripts/web2. mkdir -p /var/www/php-fcgi-scripts/web1 vi /var/www/php-fcgi-scripts/web1/php-fcgi-starter
vi /var/www/php-fcgi-scripts/web2/php-fcgi-starter
The PHPRC line contains the directory where the php.ini file is located (i.e., /etc/php5/cgi/ translates to /etc/php5/cgi/php.ini). PHP_FCGI_MAX_REQUESTS is the maximum number of requests before an fcgid process is stopped and a new one is launched. PHP_FCGI_CHILDREN defines the number of PHP children that will be launched. The php-fcgi-starter scripts must be executable, and they (and the directories they are in) must be owned by the web site's user and group: chmod 755 /var/www/php-fcgi-scripts/web1/php-fcgi-starter Now we create the Apache vhosts for www.example1.com and www.example2.com: vi /etc/apache2/sites-available/web1
a2ensite web1 vi /etc/apache2/sites-available/web2
a2ensite web2 Make sure you fill in the right paths (and the correct user and group in the SuexecUserGroup line). Reload Apache afterwards: /etc/init.d/apache2 reload
|



Recent comments
7 hours 53 min ago
12 hours 51 min ago
14 hours 18 min ago
15 hours 11 min ago
16 hours 54 min ago
21 hours 17 min ago
22 hours 9 min ago
1 day 23 min ago
1 day 13 hours ago
1 day 15 hours ago