- on Gentoo, make sure your USE contains: suexec, apache2, cgi, fastcgi, session.
- on Gentoo, "emerge apache php mod_fcgid". On other platforms, consult your docs (or just download mod_fcgid and use apxs to install it. it should be pretty seamless)
- Set up your global configuration. On Gentoo, this is done for you, but make sure this gets loaded into your global apache configuration:
LoadModule fcgid_module modules/mod_fcgid.so
SocketPath /var/run/fcgidsock
SharememPath /var/run/fcgid_shm
<Location /fcgid>
SetHandler fcgid-script
Options ExecCGI
allow from all
</Location>
- Add a user and group for your first virtual host, test.example.com. call em "example" if you like
- Set up the directory tree for the virtual host:
/var/www/test.example.com/
/var/www/test.example.com/tmp
/var/www/test.example.com/htdocs
/var/www/test.example.com/htdocs/cgi-bin
- Make some files:
hello HTML world!
/* /var/www/test.example.com/test.php */
print("hello PHP world!");
?>
#!/bin/sh
# /var/www/test.example.com/htdocs/fcgi
PHPRC=/var/www/test.example.com/htdocs/cgi-bin/
export PHPRC
PHP_FCGI_CHILDREN=2
export PHP_FCGI_CHILDREN
PHP_FCGI_MAX_REQUESTS=25000
export PHP_FCGI_MAX_REQUESTS
exec /usr/bin/php-cgi
- Copy your php.ini to /var/www/test.example.com/htdocs/fcgi and edit it so that directories are right. All you'll likely need to change is upload.tmp_dir and session.save_path, but you may want to change others.
- Set fcgi to be executable, and make sure permissions are set on it so that it is owned by your test user/group and other users can't mess with it. If things don't work later, this is a frequent culprit
- Set the immutable bit on php.ini and fcgi (you'll need to be using extended file system attributes on your filesystem to do this, check your OS documentation for details) by running 'chattr +i /var/www/test.example.com/htdocs/*'. You'll need to undo this with chattr -i if you want to change these files in the future.
- Set up this host's configuration:
<VirtualHost *:80>
DocumentRoot /var/www/test.example.com/htdocs/
ServerName test.example.com
SuexecUserGroup example example
<Directory /var/www/test.example.com/htdocs/>
Options +SymLinksIfOwnerMatch
AllowOverride All
Order allow,deny
Allow from all
DirectoryIndex index.html index.php
AddType application/x-httpd-fastphp .php
Action application/x-httpd-fastphp /cgi-bin/fphp
</Directory>
<Directory /var/www/test.example.com/htdocs/cgi-bin/>
SetHandler fcgid-script
FCGIWrapper /var/www/test.example.com/htdocs/cgi-bin/fphp .php
Options +ExecCGI -Includes
allow from all
</Directory>
</VirtualHost>
<VirtualHost *:80>
ServerName aerospace.com
Redirect Permanent / http://test.example.com/
</VirtualHost>
- Give apache a restart and that should be it!
Check out the processes running on your server, and after you hit test.php you should see a php-cgi process running as the example user. If you have problems, error_log and suexec_log in /var/log/apache2/ (or /var/log/httpd/) tend to tell you everything you need to know.
An oh yeah, want to use