Issue the command: a2enconf php7.2-cgi
This will enable the default configuration for PHP to be served through as a Common Gateway Interface. There are multiple ways to run php, one as a CGI Daemon, on or FPM which boasts being the faster of the two. We are going to go with CGI option.
After enabling php's configuration using apaches built in tool, we are going to alter a couple preferences, and restart the server.
By navigating to /etc/php/
7.2/ will show you a few folders depending on your chosen install option. You want to target the apache2 folder, and the php.ini inside.
*If you changed directories one by one, you may have noticed the folder structure indicates that PHP has its own config file under cli as well. This means running php scripts from the command line, may perform unexpectedly, unless you configure that php.ini file as well.
Inside the php.ini config file, we want to change the localisation options first. This was, simple scripts work correctly, out of the box.
Line 939 should be your timezone, we will set ours to read 'date.timezone =
*7.2 would be the correct version if you are following our walkthroughs, you can swap out version numbers if you've stopped by and just wanted this snippet of info.
Restart your apache2 instance by issuing the command: systemctl restart apache2
Lets install the package
##As the super user, you will need to apt install another package. root@wrench:/home/alpha# apt install php-fpm -y
After the installation has completed, we will need to add the FPM directive to a <VirtualHost> structure we've previously set up. In our case that should be /etc/apache2/sites-available/default.conf
##Go ahead and open up /etc/apache2/sites-available/default.conf. root@wrench:/home/alpha# nano /etc/apache2/sites-available/default.conf # add into your existing <VirtualHost> - </VirtualHost> <FilesMatch \.php$> SetHandler "proxy:unix:/var/run/php/php7.2-fpm.sock|fcgi://localhost/" </FilesMatch> </VirtualHost>
CTRL+X followed by y to save your changes.
##Issue this command to enable FastCGI root@wrench:/home/alpha# time(a2enmod proxy_fcgi setenvif && a2enconf php7.2-fpm) && systemctl restart apache2