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
</VirtualHost>
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.
sudo service apache2 start
at the end of myusers'~/.profile
it should work ?CustomLog
andErrorLog
by adding a#
at the beginning and then try to restart apache.