Why is my Apache not working after upgrading to Ubuntu 14.04?
I had this problem even though apache was working for me. I simply wanted to do a quick
$ /usr/sbin/apache2 -V
to find the value of SERVER_CONFIG_FILE
. Because that's not the way to start apache2 any more it fails with the errors the OP posts. A quick and dirty workaround is simply to set the envvars that are missing first:
$ source /etc/apache2/envvars
$ /usr/sbin/apache2 -V
This sets the APACHE_LOCK_DIR variable and all is well (-D SERVER_CONFIG_FILE="apache2.conf"
).
I had this problem : The cause is in the file
/etc/apache2/sites-available/000-default.conf
where the root have changed:
before upgrade = /var/www
after upgrade = /var/www/html
So edit to modify this file
sudo gedit /etc/apache2/sites-available/000-default.conf
And restart apache
sudo service apache2 restart
Symptoms and solution
In many Q&A web sites or forums, people confuse symptoms and actual causes. I just upgraded a ubuntu server from 13.10 to 14.04.1 and ran into the exact same symptoms described by the OP, including:
1- apache apparently not working.
2- apache configuration variable undefined.
3- the syntax error mentioned by the OP.
The problem is that not all of these symptoms are actually germane to the actual problem and they only serve as a distraction to those who try their best to help.
Different root problems may cause administrators to come to sites like this one with roughly the same description: "I upgraded the OS and now apache is not working..."
One specific cause
Having all the exact same apparent symptoms as the OP, I was attracted to this question. Unfortunately, the only answer that contained a valid hint to the real root cause of my problem was downvoted (-1), posted by user1469291 with a rep of 1!! So I searched further other web sites until I found a clear explanation of the problem (and thereby of the solution).
The solution that follows may not solve the OP's real problem, but I'm sure that it'll help others who may be attracted to this question for the same reasons as I was.
/etc/apache2/apache2.conf contains:
# Include generic snippets of statements
IncludeOptional conf-enabled/*.conf
# Include the virtual host configurations:
IncludeOptional sites-enabled/*.conf
which means that only site configuration files in /etc/apache2/sites-enabled/ ending in .conf will get loaded. Older symlink in that directory will be ignored.
It used to be simply sites-enabled/*. That's why all my virtual host configuration files that I simply named ww1.example.com, ww2.example.com, etc, used to work but suddenly and initially inexplicably stopped working after the upgrade.
So, either change the directive above and reload apache, or, like I did, manually remove all the older symlinks in sites-enabled/, rename all the files in sites-available/ to add the suffix .conf and then re-enabled each site individually.
In addition, the default directive in apache.conf are stricter:
<Directory />
Options FollowSymLinks
AllowOverride None
Require all deny
</Directory>
<Directory /var/www/>
Options Indexes FollowSymLinks
AllowOverride None
Require all granted
</Directory>
So if you host your virtual sites in /home/user/somewhere, make sure to override the directive appropriately.