Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
Convert Apache to PHP-FPM
# Install dependencies
sudo apt-get install -y apache2-mpm-worker
sudo apt-get install -y libapache2-mod-fastcgi php5-fpm
# Disable prefork & Enable fcgi
sudo a2dismod php5 mpm_prefork
sudo a2enmod actions fastcgi alias mpm_worker
# Create fcgi file
sudo touch /usr/lib/cgi-bin/php5.fcgi
# Change permissions
sudo chown -R www-data:www-data /usr/lib/cgi-bin
# Add configuration file
cat > /etc/apache2/conf-available/php5-fpm.conf << EOL
<IfModule mod_fastcgi.c>
AddHandler php5.fcgi .php
Action php5.fcgi /php5.fcgi
Alias /php5.fcgi /usr/lib/cgi-bin/php5.fcgi
FastCgiExternalServer /usr/lib/cgi-bin/php5.fcgi -socket /var/run/php5-fpm.sock -pass-header Authorization -idle-timeout 3600
<Directory /usr/lib/cgi-bin>
Require all granted
# Enable PHP-FPM conf
sudo a2enconf php5-fpm
# Restart services
sudo service apache2 restart && sudo service php5-fpm restart
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment