skip to Main Content

I install apache2 on ubuntu 18.04. This is fresh install with all default configuration.

I tried to start apache2 but failed. And this is what I see.

# systemctl status apache2.service 
● 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 Wed 2020-03-11 23:17:35 WIB; 13s ago
  Process: 9151 ExecStart=/usr/sbin/apachectl start (code=exited, status=139)

Mar 11 23:17:35 xdn.id systemd[1]: Starting The Apache HTTP Server...
Mar 11 23:17:35 xdn.id apachectl[9151]: Segmentation fault
Mar 11 23:17:35 xdn.id apachectl[9151]: Action 'start' failed.
Mar 11 23:17:35 xdn.id apachectl[9151]: The Apache error log may have more information.
Mar 11 23:17:35 xdn.id systemd[1]: apache2.service: Control process exited, code=exited status=139
Mar 11 23:17:35 xdn.id systemd[1]: apache2.service: Failed with result 'exit-code'.
Mar 11 23:17:35 xdn.id systemd[1]: Failed to start The Apache HTTP Server.

When I check /var/log/apache2/error.log, there is empty.

What’s wrong with this error?

2

Answers


  1. The “status=139” error must have something to do with having multiple, conflicting versions of PHP enabled.

    I am running 18.04 and an old PHP site I run only locally ceased to work. I am guessing aptitude installed and enabled php7.2, possibly when I installed kubuntu-desktop a few weeks back.

    Regardless, I had two versions of PHP enabled:

     $ cd /etc/apache2/
     $ l mods-*/php*
    -rw-r--r-- 1 root root 867 Jun  9  2017 mods-available/php5.6.conf
    -rw-r--r-- 1 root root 102 Jun  9  2017 mods-available/php5.6.load
    -rw-r--r-- 1 root root 867 Mar  2  2017 mods-available/php7.0.conf
    -rw-r--r-- 1 root root 102 Oct  1  2018 mods-available/php7.0.load
    -rw-r--r-- 1 root root 855 Jul  7  2017 mods-available/php7.1.conf
    -rw-r--r-- 1 root root 102 Jul  7  2017 mods-available/php7.1.load
    -rw-r--r-- 1 root root 855 Feb  8  2019 mods-available/php7.2.conf
    -rw-r--r-- 1 root root 102 Feb  8  2019 mods-available/php7.2.load
    lrwxrwxrwx 1 root root  29 Jul  1  2017 mods-enabled/php5.6.conf -> ../mods-available/php5.6.conf
    lrwxrwxrwx 1 root root  29 Jul  1  2017 mods-enabled/php5.6.load -> ../mods-available/php5.6.load
    lrwxrwxrwx 1 root root  29 May 28 06:05 mods-enabled/php7.2.conf -> ../mods-available/php7.2.conf
    lrwxrwxrwx 1 root root  29 May 28 06:05 mods-enabled/php7.2.load -> ../mods-available/php7.2.load
    

    In my case, I am fine with using php5.6, because the site is not online and is purely for my local use only. So disabling 7.2 did the trick:

    sudo a2dismod php7.2
    

    Now my php mods-enabled are less confusing to apache3:

     $ l mods-*/php*
    -rw-r--r-- 1 root root 867 Jun  9  2017 mods-available/php5.6.conf
    -rw-r--r-- 1 root root 102 Jun  9  2017 mods-available/php5.6.load
    -rw-r--r-- 1 root root 867 Mar  2  2017 mods-available/php7.0.conf
    -rw-r--r-- 1 root root 102 Oct  1  2018 mods-available/php7.0.load
    -rw-r--r-- 1 root root 855 Jul  7  2017 mods-available/php7.1.conf
    -rw-r--r-- 1 root root 102 Jul  7  2017 mods-available/php7.1.load
    -rw-r--r-- 1 root root 855 Feb  8  2019 mods-available/php7.2.conf
    -rw-r--r-- 1 root root 102 Feb  8  2019 mods-available/php7.2.load
    lrwxrwxrwx 1 root root  29 Jul  1  2017 mods-enabled/php5.6.conf -> ../mods-available/php5.6.conf
    lrwxrwxrwx 1 root root  29 Jul  1  2017 mods-enabled/php5.6.load -> ../mods-available/php5.6.load
    

    Naturally for a live site one would want to disable php-5.6 and leave the php7.2 enabled, because you should run the newer version in real life.

    sudo a2dismod php5.6
    sudo a2enmod php7.2
    

    Then the php mods should look like this:

     $ l mods-*/php*
    -rw-r--r-- 1 root root 867 Jun  9  2017 mods-available/php5.6.conf
    -rw-r--r-- 1 root root 102 Jun  9  2017 mods-available/php5.6.load
    -rw-r--r-- 1 root root 867 Mar  2  2017 mods-available/php7.0.conf
    -rw-r--r-- 1 root root 102 Oct  1  2018 mods-available/php7.0.load
    -rw-r--r-- 1 root root 855 Jul  7  2017 mods-available/php7.1.conf
    -rw-r--r-- 1 root root 102 Jul  7  2017 mods-available/php7.1.load
    -rw-r--r-- 1 root root 855 Feb  8  2019 mods-available/php7.2.conf
    -rw-r--r-- 1 root root 102 Feb  8  2019 mods-available/php7.2.load
    lrwxrwxrwx 1 root root  29 May 29 17:43 mods-enabled/php7.2.conf -> ../mods-available/php7.2.conf                                                                         
    lrwxrwxrwx 1 root root  29 May 29 17:43 mods-enabled/php7.2.load -> ../mods-available/php7.2.load                                                                         
    

    Don’t forget to resatart the server!

    systemctl restart apache2
    

    Thanks to Pavel’s comment for inspiring this line of research!

    Login or Signup to reply.
  2. I got this error and I fixed it by enabling PHP version 8.0 (current stable) and disabling PHP version 7.4 (old) in my ubuntu 20.04 by these commands:

    sudo a2dismod php7.4
    sudo a2enmod php8.0
    sudo service apache2 restart
    

    After doing these check your apache status by:

    sudo systemctl status apache2.service
    

    It has to be green and must show you active (running).

    NOTE: You can do this to any PHP version that you have and want to
    change.

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search