I have a web server running Ubuntu 17.04 that I am attempting to set up with Apache. Everything ran great until I decided to host two websites on a single machine through virtualHosts. Now apache refuses to start up with even a single host enabled. Each time I attempt to start Apache I get this error:
apache2: Syntax error on line 80 of /etc/apache2/apache2.conf:
DefaultRuntimeDir must be a valid directory, absolute or relative to ServerRoot.None of my attempts to fix this have come to anything including:
apt purge apache2 && rm -r /etc/apache2 All line 80 of the error message tells me is DefaultRuntimeDir ${APACHE_RUN_DIR}.
And at no time do I see where or what APACHE_RUN_DIR is declared as.
Can someone help me out?
9 Answers
The command
source /etc/apache2/envvarssorted my problem out (after trying ALL the others).
To check whether all is well or not use the command
apache2 -SI found that was quicker than using my DNS records.
2There is a missing update in "man apache2", at least for option -V;
Today, one should use either "apachectl" or "apache2ctl" instead of
"apache2" for at least some options, as stated in
3Apache2 uses /etc/apache2/envvars to set environment variables. You can use this information to make sure the directory ${APACHE_RUN_DIR} points to is valid.
I was experiencing the same issue while upgrading from 14.04 to 17.04.
Problem was: ${APACHE_RUN_DIR} was set to /var/run/apache2, but the apache2 folder was missing in /var/run.
The fix for me was: mkdir /var/run/apache2
in my case it was regarding "Require all denied" line in apache2.conf file which (again) in my case was typed in as just "Require denied"
Had the same problem, and could solve it by using:
apache2ctl start I had this issue with Ubuntu 20.14 and Apache2 after running Vagrant. My resolution was to change the Document Root in
/etc/apache2/sites-enabled/000-default.confBefore Change -> DocumentRoot /var/www/HTML
I deleted the "HTML" (because I am not using the HTML directory (this is just for development no production)
After Change -> DocumentRoot /var/www/
I then restarted Apache
sudo systemctl stop apache2
sudo systemctl start apache2and all is well.
Reenebling php5.6 apache module helps to fix this problem.
Press Ctrl+Alt+T and type these:
sudo a2dismod php5.6
sudo a2enmod php5.6Then restart apache2 service:
sudo service apache2 restart I have just had this error and run through all the ideas given and none worked. What I had done was changed the URL in the sites-available .conf file, restarted apache and boom. It stopped working. The solution is to go into sites-enabled and remove the old file there and then restart apache2. I hope that helps someone!
Here is the answer of which I found;
apache2 -S replied;
apache2: Syntax error on line 80 of /etc/apache2/apache2.conf: DefaultRuntimeDir takes one argument, Common directory for run-time files (shared memory, locks, etc.)
Line 80 of /etc/apache2/apache2.conf:DefaultRuntimeDir ${APACHE_RUN_DIR}
Line 86 gave away the /etc/apache2/envars file which shows this:
export APACHE_PID_FILE=/var/run/apache2$SUFFIX/apache2.pid
export APACHE_RUN_DIR=/var/run/apache2$SUFFIX
export APACHE_LOCK_DIR=/var/lock/apache2$SUFFIX
Indicating the environment is set.
Looking at the /var/run/apache2 folder, it is owned by Root.
Run: chown -R www-data:www-data /var/run/apache2
Which should now allow the non-root user running Apache2 to write to the folder Re-run systemctl restart apache2
apache2 -S Now works properly.