Ubuntu: Why is my Apache not working after upgrading to Ubuntu 14.04?



Question:

[aman@aman-Inspiron-1440:~$ apache2  [Mon Apr 21 17:36:38.019213 2014] [core:warn] [pid 4134] AH00111: Config variable ${APACHE_LOCK_DIR} is not defined  [Mon Apr 21 17:36:38.019345 2014] [core:warn] [pid 4134] AH00111: Config variable ${APACHE_PID_FILE} is not defined  [Mon Apr 21 17:36:38.019370 2014] [core:warn] [pid 4134] AH00111: Config variable ${APACHE_RUN_USER} is not defined  [Mon Apr 21 17:36:38.019385 2014] [core:warn] [pid 4134] AH00111: Config variable ${APACHE_RUN_GROUP} is not defined  [Mon Apr 21 17:36:38.019414 2014] [core:warn] [pid 4134] AH00111: Config variable ${APACHE_LOG_DIR} is not defined  [Mon Apr 21 17:36:38.028756 2014] [core:warn] [pid 4134] AH00111: Config variable ${APACHE_LOG_DIR} is not defined  [Mon Apr 21 17:36:38.029032 2014] [core:warn] [pid 4134] AH00111: Config variable ${APACHE_LOG_DIR} is not defined  [Mon Apr 21 17:36:38.029056 2014] [core:warn] [pid 4134] AH00111: Config variable ${APACHE_LOG_DIR} is not defined  AH00526: Syntax error on line 74 of /etc/apache2/apache2.conf:  Invalid Mutex directory in argument file:${APACHE_LOCK_DIR}  

This is the content of /etc/apache2/apache2.conf file.


Solution:1

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  


Solution:2

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").


Solution:3

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.


Solution:4

Looking closely at your problem, you are just running apache2. To start apache in Ubuntu, run the following command:

sudo apache2ctl start  

Apache configuration are split into multiple files, one of those files are environment variables. When you are running just apache2, these variables are not set.

The apache2ctl script will load the variables (and do some other stuff as well when needed) before starting apache with apache2 -k start.


Solution:5

Edit the configuration: sudo leafpad /etc/apache2/apache2.conf:

# Include the virtual host configurations:    #before upgrade =   IncludeOptional sites-enabled/*  #after upgrade =   /IncludeOptional sites-enabled/*.conf  

or remove file.


Solution:6

augustin's answer worked for me when all my virtual hosts disappeared following a server upgrade from 12.04 LTS to 14.04 LTS. I would upvote it if I had the reputation to do so.

The following command will add the .conf suffix to all symlinks in /etc/apache2/sites-enabled that don't already have it:

sudo find /etc/apache2/sites-enabled -type l ! -name '*.conf' -exec rename 's/$/.conf/' {} \;  

In addition, there has been a change from using the Allow from/Deny from syntax to Require in the mod_authz_host module (here is the link for the 2.2 documentation).

The following command will edit the common usage of Order allow, deny followed by Allow from all to be Require all granted instead:

perl -0777 -pi.bak -e 's/Order\s+allow\s*,\s*deny\s*\n\s*Allow\s+from\s+all/Require all granted/sg' /etc/apache2/sites-available/*   


Solution:7

In fact, the docroot does change between precise and trusty from /var/www to /var/www/html. It is poor that the do-release-upgrade script does not regress the docroot back.

A) Either is valid, but html is more conventional. CentOS is influential in this regard. The "it works" page is more mature now too.

B) You do not have to use /var/www/html, but if you do...

  • you need to migrate your content or alias it (not recommended).
  • you need to update anywhere the old location is referenced.
  • especially backup/restore/customisation scripts.

C) And it may be easier to build from the ground up and migrate.

D) This symptom will occur if you "sudo apache2 -k graceful" out of the box on Trusty, upgrade or not due to envvars not being in scope ?. Use "sudo apache2ctl start/stop/restart" instead.


Solution:8

In my case:

  • The html subfolder at /var/www/ already existed but still I was getting the error: AH00526: Syntax error on line 74 of /etc/apache2/apache2.conf
  • I had already decided to host my websites in my user root e.g. /home/{user}/sites/ instead of the default /var/www/html
  • I am using Apache 2.4.7 (You can check your version with apache2 -v)

How I solved the problem in five easy steps:

  1. In /etc/apache2/apache2.conf I added the following after line 169:

    <Directory /home/{user}/sites/>      Options Indexes FollowSymLinks      AllowOverride None      Require all granted  </Directory>  
  2. I made sure my Virtual Host configuration named website.conf at /etc/apache2/sites-available was copied from the default 000-default.conf, and looked like:

    <VirtualHost *:80>      ServerAdmin webmaster@localhost      ServerName website.dev      ServerAlias www.website.dev      DocumentRoot /home/{user}/sites/website  </VirtualHost>  
  3. I reloaded my site (sudo a2dissite website && sudo a2ensite website) and my server and the initial error was gone. WOOHOO! But a new one emerged: "AH00035: access to / denied (filesystem path '/home/{user}/sites') because search permissions are missing on a component of the path". This I solved in step 4.

  4. The new problem was due to permissions, so I just set each of the directories leading up to the website folder to chmod 755. Every single one! The home folder, the {user} folder, the sites folder, and even my website folder

  5. After refreshing my browser at website.dev everything loaded fine!

P.S. I had already setup website.dev in my /etc/hosts file.

Bonus Tip: To check permissions of a particular folder you can use the command stat -c %a /path/to/file/or/folder. To check permissions of every part of a directory use namei -m /path/to/final/folder.


Note:If u also have question or solution just comment us below or mail us on toontricks1994@gmail.com
Previous
Next Post »