After struggling a bit to find a working configuration for my PHP server setup based on PHP 7 FPM and Apache 2.4, here’s my working config.
Activate Apache actions mod: sudo a2enmod actions
Edit /etc/apache2/mods-available/fastcgi.conf
1 2 3 4 5 6 7 8 9 10 11 12 13 14 |
<IfModule mod_fastcgi.c> AddHandler fastcgi-script .fcgi #FastCgiWrapper /usr/lib/apache2/suexec FastCgiIpcDir /var/lib/apache2/fastcgi AddHandler php-fcgi .php Action php-fcgi /php-fcgi Alias /php-fcgi /usr/lib/cgi-bin/php FastCgiExternalServer /usr/lib/cgi-bin/php -appConnTimeout 10 -idle-timeout 250 -s$ <Directory /usr/lib/cgi-bin> Require all granted </Directory> </IfModule> |
Basically, that’s telling apache to use PHP executable when someone is requesting a .php file.
Be sure php7.0-fpm service is running sudo service php7.0-fpm status. If not, start it sudo service php7.0-fpm start.
Here’s an example of a virtual host config file
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 |
<VirtualHost *:80> ServerAdmin louwii@serv.com ServerName site.com ServerAlias www.site.com #Documents root : root folder of the website DocumentRoot /var/www/sites/site/ DirectoryIndex index.php index.html #website options <Directory /var/www/sites/site/> Options -Indexes Allowoverride All Require all granted </Directory> #logs ErrorLog /var/log/apache2/site-error_log TransferLog /var/log/apache2/site-access_log </VirtualHost> |