PHP rendered as text after Ubuntu 16.04 upgrade
The php
command is provided by php7.0-cli
package on Ubuntu 16.04. Running the CLI is orthogonal to the web server configuration.
You need to install and configure one of the web SAPIs - apache2, fpm or cgi. The most easy is to install apache2 SAPI.
To install apache2 SAPI, run
apt-get install libapache2-mod-php
(this will pull the default PHP version, currentlylibapache2-mod-php7.0
). The package should enable itself and switch to apache2 prefork MPM that's the only MPM supported. If not, try to runa2enmod php7.0
and look for errors. The installation should switch from event MPM to prefork MPM automatically, but if it doesn't, you can switch it manually by doingsudo a2dismod mpm_event
followed bysudo a2enmod mpm_prefork
.To install FPM SAPI, run
apt-get install php-fpm
and then enable FPM by runninga2enconf php7.0-fpm
. The FPM SAPI is more secure, but harder to configure correctly.To install CGI SAPI, run
apt-get install php-cgi
and then enable CGI by runninga2enconf php7.0-cgi
. Please not that CGI is not recommended way how to run PHP, but it might come handy in special deployments.