To configure php7 to run with your server you need to do some configuration:
1. Make sure you remove any traces of php/php5
Open a terminal Ctrl+Alt+T and:
cd /etc/apache2/mods-enabled
ls -la
The output should not contain any php5.conf
or php5.load
, but if it does, do the following:
# this is the proper way of disabling modules
sudo a2dismod php5
# run this only if the above command didn't remove the php5 sym-links
sudo rm php5.load
sudo rm php5.conf
Now add the php7.0.conf
and php7.0.load
instead:
# this is the proper way of enabling modules
sudo a2enmod php7.0
# run this only if the above command didn't create the php7.0 sym-links
sudo ln -s php7.0.conf ../mods-available/php7.0.conf
sudo ln -s php7.0.load ../mods-available/php7.0.load
The output of ls -la php*
should look like this:
lrwxrwxrwx 1 root root 29 Apr 15 03:55 php7.0.conf -> ../mods-available/php7.0.conf
lrwxrwxrwx 1 root root 29 Apr 15 03:55 php7.0.load -> ../mods-available/php7.0.load
After dealing with the modules we now come to the /etc/apache2/conf-enabled
directory. Remove any traces of php/php5 here as well by sudo rm <name>
Then, if needed do:
# the proper way of enabling configs
sudo a2enconf php7.0-cgi
sudo a2enconf php7.0-fpm
# do those commands only if the above didn't work out
sudo ln -s php7.0-cgi.conf ../conf-available/php7.0-cgi.conf
sudo ln -s php7.0-fpm.conf ../conf-available/php7.0-fpm.conf
The output of ls -la php*
should look like this:
lrwxrwxrwx 1 root root 33 Apr 21 17:00 php7.0-cgi.conf -> ../conf-available/php7.0-cgi.conf
lrwxrwxrwx 1 root root 33 Apr 21 17:01 php7.0-fpm.conf -> ../conf-available/php7.0-fpm.conf
2. Restarting Apache2
Before restarting Apache make sure to clean out the Apache error.log
then restart:
sudo su
> /var/log/apache2/error.log
exit
sudo service apache2 restart
Now check the error.log
by issuing cat /var/log/apache2/error.log | less
(piping through less enables you to easy scroll up and down, q
exits the output).
If your error.log
contains many (and I literally mean a heap of) some MIBS not found
do the following:
sudo apt install libsnmp-dev
sudo net-snmp-config --snmpconfpath
sudo apt-get install snmp snmp-mibs-downloader
sudo su
> /var/log/apache2/error.log
exit
sudo service apache2 restart
The check again the error.log
it now should only contain 3 lines:
[Sat Apr 23 01:39:07.504005 2016] [mpm_prefork:notice] [pid 1647] AH00169: caught SIGTERM, shutting down
[Sat Apr 23 01:39:08.685774 2016] [mpm_prefork:notice] [pid 9590] AH00163: Apache/2.4.18 (Ubuntu) mod_perl/2.0.9 Perl/v5.22.1 configured -- resuming normal operations
[Sat Apr 23 01:39:08.685938 2016] [core:notice] [pid 9590] AH00094: Command line: '/usr/sbin/apache2'
Your Apache with php7.0 should now be properly configured.
php
command) is orthogonal to the other PHP SAPIs (apache2, FPM, CGI, ...), so working command line PHP doesn't say anything about working PHP in the HTTP server.sudo apt-get install php-mbstring
(who would have thought, right?)