Apache and PHP with fcgi on 10.04

Jordon Bedwell jordon at envygeeks.com
Sun Aug 7 23:10:42 UTC 2011


Snippet from Wipe_Out On 07/08/11 14:13:
> Any help converting from what I have setup to an fcgi setup would be appreciated..

I'm only going to show you how to do barebones, this will get you up and
running but this isn't secure at all without some sort of real ACL and
suexec, but then again, I don't remember the last time one of my clients
put up an ACL before I was there o.O most of them think suexec is good
enough.  Anyways suexec is easy enough to install and configure so I'll
just give you the basics:

---

sudo apt-get install php5-cgi \
apache2 \
libapache2-mod-fcgid \
apache2-mpm-itk --no-install-recommends

---

sudo vim /etc/apache2/fcgi.bash
Contents:

#!/bin/sh

# The basics
export PHPRC=/etc/php5/cgi/
export PHP_FCGI_CHILDREN=3
export PHP_FCGI_MAX_REQUESTS=5000

# Time for the fun
exec /usr/lib/cgi-bin/php5

---

sudo chmod a+x /etc/apache2/fcgi.bash

---

sudo a2dismod authn_file \
authz_default \
authz_groupfile \
authz_user \
autoindex \
cgi \
status \
auth_basic \
authz_user

---

sudo echo "AddHandler fcgid-script .php" >> \
/etc/apache2/mods-available/fcgid.conf

---

sudo echo "FCGIWrapper /etc/apache2/fcgi.bash .php" >> \
/etc/apache2/mods-available/fcgid.conf

---

I love Apache and live by Debian, but, it's disgusting that they think
it's alright to violate FHS and Debian supports it because Apache
foundation does and they don't want to "alienate" users. While one could
argue against /srv/www it's well within FHS.

sudo rm -rf /var/www
mkdir -p /srv/www

---

sudo vim /etc/apache2/sites-available/default
Contents:

<VirtualHost *:80>
	ServerAdmin webmaster at localhost

	DocumentRoot /srv/www

	<Directory /srv/www/>
		Options -Indexes +FollowSymLinks -MultiViews +ExecCGI
		AllowOverride None
		Order allow,deny
		allow from all
	</Directory>

	LogLevel warn
	ErrorLog ${APACHE_LOG_DIR}/error.log
	CustomLog ${APACHE_LOG_DIR}/access.log combined
</VirtualHost>

---

echo "<?php phpinfo();" > /srv/www/index.php

---

chown www-data:www-data /srv/www/index.php

---

sudo service apache2 restart

---

firefox http://localhost

---

Oh hai, how are you today FCGI and PHP? Nice to see you...




More information about the ubuntu-users mailing list