I got myself in a similar situation and I can't find a proper fix.

Here is my use case:

Each site I host on my laptop is configured using a file named www-example1.conf. This file's location is /etc/apache2/sites-enabled/www-example1.conf

The content of this file is:

<VirtualHost *:80>
        ServerAdmin webmaster@localhost
        ServerName www-example1
        ServerAlias www.www-example1
        DocumentRoot /home/myuser/www/www-example1/public_html
        ErrorLog /home/myuser/www/www-example1/error.log
        CustomLog /home/myuser/www/www-example1/access.log combined

The apache user/group is www-data. The www-example1 folder is owned by myuser:www-data. The www-example1 folder has 755 permissions. Inside this folder there are the error.log and access.log files, each with 755 permissions and owned by myuser:www-data.

The issue is that apache fails to start on system boot.

When I use sudo systemctl status apache2, the result is:

● apache2.service - The Apache HTTP Server
     Loaded: loaded (/lib/systemd/system/apache2.service; enabled; vendor preset: enabled)
     Active: failed (Result: exit-code) since Thu 2020-06-18 22:58:00 EEST; 12min ago
       Docs: https://httpd.apache.org/docs/2.4/
    Process: 3044 ExecStart=/usr/sbin/apachectl start (code=exited, status=1/FAILURE)

iun 18 22:58:00 SIA-PC apachectl[3067]: (2)No such file or directory: AH02291: Cannot access directory '/home/myuser/www/www-example1/' for error log of vhost defined at /etc/apache2/sites-enabled/www-example1.conf:1
iun 18 22:58:00 SIA-PC apachectl[3067]: AH00014: Configuration check failed
iun 18 22:58:00 SIA-PC apachectl[3044]: Action 'start' failed.
iun 18 22:58:00 SIA-PC apachectl[3044]: The Apache error log may have more information.
iun 18 22:58:00 SIA-PC systemd[1]: apache2.service: Control process exited, code=exited, status=1/FAILURE
iun 18 22:58:00 SIA-PC systemd[1]: apache2.service: Failed with result 'exit-code'.
iun 18 22:58:00 SIA-PC systemd[1]: Failed to start The Apache HTTP Server.

If I start apache manually using sudo service apache2 start, everything works.

What can I do to make apache start at boot?

Thank you!

I already tried this solution, but to no avail. I would really like to keep my folder structure as it is.

  • 1
    are you sure your user is named myuser? plus could it be that you use an encrypted home folder? normally you would put your Document-root in /var/www/ have a look at this nice tutorial ubuntu.com/tutorials/install-and-configure-apache#1-overview
    – d1bro
    Jun 18, 2020 at 20:38
  • I use an encrypted home folder! Is there any way around this, but to move the www folder outside my home folder? apache is starting just fine if I start it manually, after boot. Maybe there could be a way to delay the auto-start of apache until after the home folder is decrypted? Just guessing... Thank you! Jun 19, 2020 at 17:00
  • okay so I guess if you add sudo service apache2 start at the end of myusers' ~/.profile it should work ?
    – d1bro
    Jun 19, 2020 at 19:34
  • Nope! Adding that to the ~/.profile makes the system freeze right after login. Jun 19, 2020 at 20:06
  • Comment out CustomLog and ErrorLog by adding a # at the beginning and then try to restart apache. Jun 30, 2020 at 0:15

1 Answer 1


I had the same problem

Ubuntu 20.04 work with libphp7.4.so and apache2 work with libphp7.2.so so to fixe it you need to change the configuration of apache2 and this is how i did it :

1- you can check this problem by testing the apache and writing : apache2ctl configtest

The output message :

apache2: Syntax error on line 146 of /etc/apache2/apache2.conf: Syntax error on line 3 of /etc/apache2/mods-enabled/php7.2.load: Cannot load /usr/lib/apache2/modules/libphp7.2.so into server: /usr/lib/apache2/modules/libphp7.2.so: cannot open shared object file: No such file or directory Action 'configtest' failed. The Apache error log may have more information.

2- open the file php7.2.load by gedit /etc/apache2/mods-enabled/php7.2.load you can see

LoadModule php7_module /usr/lib/apache2/modules/libphp7.2.so

3- go to /usr/lib/apache2/modules/ and check the version of libphp by ls , it will be libphp7.4.so

4- back to the file and change the version :

LoadModule php7_module /usr/lib/apache2/modules/libphp7.4.so

save it and restart apache2

systemctl start apache2.service

check the status :

systemctl status apache2.service

That's all :)

  • Thank you for your answer. I tried following the steps you provided, but it was not applicable. The apache configtest output is "Syntax OK". Also, the libraries are correctly loaded... I suspect that the issue is my encrypted home folder, as db429 suggested in a comment above. Oct 18, 2020 at 12: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.