5

I can't able to restart apache2 service. I execute this command apache2ctl configtest and this below error it shows :

apache2: Syntax error on line 146 of /etc/apache2/apache2.conf: Syntax error on line 2 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: cannot open shared object file: No such file or directory
Action 'configtest' failed.
The Apache error log may have more information.

when I execute apache2 service start command it shows this below error :

apache2.service - The Apache HTTP Server
   Loaded: loaded (/lib/systemd/system/apache2.service; enabled; vendor preset: enabled)
  Drop-In: /lib/systemd/system/apache2.service.d
           └─apache2-systemd.conf
   Active: failed (Result: exit-code) since Sat 2018-10-27 21:39:15 IST; 14s ago
  Process: 24290 ExecStart=/usr/sbin/apachectl start (code=exited, status=1/FAILURE)
 Main PID: 19188 (code=exited, status=0/SUCCESS)

Oct 27 21:39:15 abc systemd[1]: Starting The Apache HTTP Server...
Oct 27 21:39:15 abc apachectl[24290]: apache2: Syntax error on line 146 of /etc/apache2/apache2.conf: Syntax error 
Oct 27 21:39:15 abc apachectl[24290]: Action 'start' failed.
Oct 27 21:39:15 abc apachectl[24290]: The Apache error log may have more information.
Oct 27 21:39:15 abc systemd[1]: apache2.service: Control process exited, code=exited status=1
Oct 27 21:39:15 abc systemd[1]: apache2.service: Failed with result 'exit-code'.
Oct 27 21:39:15 abc systemd[1]: Failed to start The Apache HTTP Server.

How to solve this error and run apache2 successfully?

Please help me.

Thanks.

7
  • It's strange that it's called a syntax error, but the main problem seems to be this: Syntax error on line 146 of /etc/apache2/apache2.conf: Syntax error on line 2 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: cannot open shared object file: No such file or directory. /usr/lib/apache2/modules/libphp7.0.so is missing. Oct 27, 2018 at 16:33
  • Yes. In this folder libphp7.0.so is not found. What should I do now? Oct 27, 2018 at 16:39
  • Please someone guide me. Oct 27, 2018 at 16:53
  • What did you change before running configtest! Oct 27, 2018 at 17:58
  • @RohanHapani Is there: /usr/lib/apache2/modules another version of libphp7.0.so. e.g libphp7.2.so or libphp7.3.so?
    – metallic
    Oct 27, 2018 at 20:57

2 Answers 2

1

In my case, it happened due to a PHP upgrade but backdated configuration.

Try the following commands (The example shown below is for PHP version 7.0 and 7.2, replace the version with your own):

a2dismod php7.0
mv /etc/apache2/mods-available/php7.0.conf /etc/apache2/mods-available/php7.2.conf
mv /etc/apache2/mods-available/php7.0.load /etc/apache2/mods-available/php7.2.load

Edit /etc/apache2/mods-enabled/php7.2.load with a text editor and change the content with php7.2. Please check your PHP version and replace it properly. The move commands are not important, but good to sync with the version name.

Then enable mod and reload apache.

a2enmod php7.2
service apache2 start
1
  • Thanks it solved my problem of after upgrading popOS from 21.04 to 22.04. As my php version changed from 8.0 to 8.1. OP can accept this as answer if it solves their problem too. Apr 27, 2022 at 15:35
0

Apologies for not asking specifics before hand, but comment on this and I can try to update this answer to be more specific.

The error is pretty self-explanatory. Apache has a structure for loading modules attached to the service. On Ubuntu there are 3 important files for each module. Let's look at the mpm_prefork module that you should probably have out of the box. In /etc/apache2/mods-enabled/ you'll find a mpm_prefork.load and an mpm_prefork.conf file.

Read those with vi or nano like so nano /etc/apache2/mods-enabled/mpm_prefork.load In here, you'll see that it's looking for a companion binary file called /usr/lib/apache2/modules/mod_mpm_prefork.so. Notice how the path seems similar to the error you're getting?

So in your case you appear to have a php7.0.load file which is looking for /usr/lib/apache2/modules/libphp7.0.so. You should look to see that file is indeed there or not by listing that directory with ls /usr/lib/apache2/modules/ Is it there?

If not, then I recommend trying to reinstall php, which wouldn't be the worst idea since php7.0 is going to be deprecated soon anyways (Dec 3, 2018 to be exact).

So run the following:

dpkg --get-selections | grep php*  # list all php packages installed
sudo apt remove php7.0  # but replace php7.0 with whatever you installed
sudo apt update
sudo apt install php libapache2-mod-php
2
  • It's not working. Can you please tell me other way? Oct 28, 2018 at 13:18
  • There are /usr/lib/apache2/modules/libphp7.0.so is missing. Oct 28, 2018 at 13:18

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.