2

I have PHP7 installed on my Ubuntu 14.04 laptop. It was working perfectly all this while. Now, for some reason my apache2 isn't starting.

anjanesh@anjanesh-Latitude-3560:~$ sudo /etc/init.d/apache2 start
 * Starting web server apache2                                                                                                                  * 
 * The apache2 configtest failed.
Output of config test was:
apache2: Syntax error on line 140 of /etc/apache2/apache2.conf: Syntax error on line 3 of /etc/apache2/mods-enabled/php7.0.load: Cannot load /usr/lib/apache2/modules/libphp7.0.so into server: /usr/lib/apache2/modules/libphp7.0.so: undefined symbol: ap_map_http_request_error
Action 'configtest' failed.
The Apache error log may have more information.

All the files are in place. There is libphp7.0.so in /usr/lib/apache2/modules.

6
  • Post the apache error log... Mar 16, 2017 at 11:35
  • pastebin.com/zEgZxXjC
    – anjanesh
    Mar 16, 2017 at 11:44
  • /var/log/apache2/error.log - pastebin.com/GmtAXUz9
    – anjanesh
    Mar 16, 2017 at 11:53
  • Will it be too much to ask that you re-install after a full purge as I did the same from that site and mine is ok... Mar 16, 2017 at 12:01
  • 1
    I just did sudo-apt-get update and updated the software and it now works.
    – anjanesh
    Mar 16, 2017 at 12:06

3 Answers 3

3

Reinstalled PHP on 16.04 LTS to fix this. Note: after running apt update Apache2 would not install until a sudo apt autoremove had been run.

Install Apache

sudo aptitude install apache2

Install MySQL

sudo aptitude install mysql-server

Install PHP

sudo aptitude install php7.0 libapache2-mod-php7.0 php7.0 php7.0-common php7.0-gd php7.0-mysql php7.0-mcrypt php7.0-curl php7.0-intl php7.0-xsl php7.0-mbstring php7.0-zip php7.0-bcmath php7.0-iconv php-mcrypt

Start Apache

apachectl start
3
  • I think 16.04 has PHP7 by default. In my case, I am using 14.04 and ondrej/php7
    – anjanesh
    May 15, 2017 at 12:44
  • It took me several iterations to find this combination to fix this on my 16.04 machine. One thing I did learn is that it is possible to keep adding on packages or reinstalling packages until it works :)
    – Underverse
    May 15, 2017 at 13:17
  • Always I use this answer, Thanks
    – Malus Jan
    Mar 24, 2021 at 21:37
2

Not enough reputation to comment ...

Doing sudo apt-get update wasn't enough for me (OP's Comment under the question).

But then also doing sudo apt-get upgrade fixed it.

0

If you are upgrading your php version using ondrej ppa (sudo add-apt-repository ppa:ondrej/php). You need to upgrade the apache2 version too.

Please add the below ppa too and upgrade the apache2 package.

sudo add-apt-repository ppa:ondrej/apache2
sudo apt update 
sudo apt install -y apache2

Then enable the libapache2-mod-php7.0 or libapache2-mod-php.

$ sudo a2enmod php 

or

$ sudo a2enmod php7.0

or

$ sudo a2enmod php7.1

Restart the apache.

$ sudo service apache2 restart

Your problem is solved.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .