2012-10-25

Apache, php, fastcgi and APC on RHEL

  • RHEL6
rpm -ivh http://download.fedoraproject.org/pub/epel/6/i386/epel-release-6-5.noarch.rpm
  • Installation de mod_fcgid depuis les depots epel (pas disponible sur le RHN)
yum install mod_fcgid
  • configuration php
echo 'cgi.fix_pathinfo = 1' >> /etc/php.ini
  • configuration mod_fcgid
cat >> /etc/httpd/conf.d/fcgid.conf < EOF
# add fcgi support
AddHandler fcgid-script .php
FCGIWrapper /var/www/cgi-bin/php-fcgi-starter .php
AddType text/html .php
DirectoryIndex index.php
EOF
  • Configuration de Apache
vim /etc/httpd/conf/httpd.conf
/<Directory \/>
Options ... +ExecCGI
/<Directory "\/var\/www\/html">
Options ... +ExecCGI
  • Ajout wrapper fcgi pour php
cat >/var/www/cgi-bin/php-fcgi-starter <<EOF
#!/bin/sh
PHPRC=/etc/
export PHPRC
export PHP_FCGI_MAX_REQUESTS=5000
export PHP_FCGI_CHILDREN=0
exec /usr/bin/php-cgi
EOF
  • Le rendre executable
chmod +x /var/www/cgi-bin/php-fcgi-starter
  • Création des dossiers necessaires à mod_fcgid
mkdir /etc/httpd/run/mod_fcgid
chown apache.apache /etc/httpd/run/mod_fcgid
  • Lancer apache en mode worker au lieu de fork
vim /etc/sysconfig/httpd
HTTPD=/usr/sbin/httpd.worker
  • désactiver le repo EPEL
  • Installation de APC
yum install php-pecl-apc
  • configuration apc
vim /etc/php.d/apc.ini
apc.shm_size=256
  • Redémarrer apache
service httpd restart