Server Fault is a question and answer site for system and network administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I've got a Ubuntu 10.04.4 LTS cloud server running the default LAMP stack.

My website is serving my PHP pages, the images and CSS to go with them, and most of my JS is loading, but there is a particular folder that is not loading the javascript files.

If I visit my site, then I get a 404. If I visit then the JS file loads.

This shows the permissions on the includes and javascript folder:

user@server~site/httpdocs$ ls -la | grep includes
drwxr-xr-x  5 user www-data    4096 Jun 14 23:53 includes

user@server~site/httpdocs$ ls -la includes | grep .js
-rwxr-xr-x  1 user www-data 20974 Mar  2 22:33 formvalidation.js

user@server~site/httpdocs$ ls -la | grep javascript
drwxr-xr-x  3 user www-data    4096 Jun  3 11:03 javascript

user@server~site/httpdocs$ ls -la javascript | grep .js
-rwxrw-r-x  1 user www-data  7276 Mar  2 22:33 calendar.js
-rwxrw-r-x  1 user www-data 33321 Jun  3 11:03 cookieControl-5.1.min.js
-rwxrw-r-x  1 user www-data 15552 Mar  2 22:33 image_display.js
-rwxrw-r-x  1 user www-data 21130 Mar  2 22:33 popcalendar.js
-rwxrw-r-x  1 user www-data 67956 Mar  2 22:33 search.js
-rwxrw-r-x  1 user www-data   555 Mar 31 00:15 sell.js
-rwxrw-r-x  1 user www-data   318 Mar 31 00:15 sign_in.js
-rwxrw-r-x  1 user www-data   142 Mar 31 00:15 update.js

So the file is uploaded, it has the same permissions as other files in includes, and the includes and javascript folder both have the same permission.

There's no .htaccess file, and this works fine locally on my Dev server, it's only when I push live I get a problem.

UPDATE: I made a file, test.js and put it at the root. This could be viewed at I moved that, `mv test.js javascript/* and visiting gives a 404

UPDATE: Checking /var/log/apache2/error.log shows File does not exist: /usr/share/javascript/search.js

UPDATE: I've searched for javscript in my /etc/apache2 folder and found this:

user@site:/etc/apache2$ grep -iR javascript ./       
./mods-available/deflate.conf: AddOutputFilterByType DEFLATE application/x-javascript application/javascript  application/ecmascript    
./mods-enabled/deflate.conf: AddOutputFilterByType DEFLATE application/x-javascript application/javascript application/ecmascript
./conf.d/javascript-common.conf:Alias /javascript /usr/share/javascript/
./conf.d/javascript-common.conf:<Directory "/usr/share/javascript/">
share|improve this question
What does the server log say? It should say where it's looking. – Nathan C Jul 8 '13 at 12:17
It's looking in /usr/share/javascript/search.js – Willshaw Media Jul 8 '13 at 12:26
What would cause the files from /javascript/ to be searched for there? Would it be an .htaccess or vhost.conf setting somewhere? I've not set up anything like that intentionally, but this is old legacy code that I've taken over – Willshaw Media Jul 8 '13 at 12:38
There has to be some weird vhost config that's causing the issue. /usr/share/ is common for some "installable" applications (webmin is one). – Nathan C Jul 8 '13 at 12:39
It seems to be the config in conf.d/javascript-common.conf that's the problem. I'd move that file to e.g. /tmp for the moment and restart apache to see if that will a) fix it and b) not break anything else. – Jenny D Jul 8 '13 at 12:55
up vote 1 down vote accepted

It looks like there was an alias in your ./conf.d/javascript-common.conf: file that was causing Apache to look in the wrong place. As you noted, deleting those entries fixed the problem and Apache was happy.

share|improve this answer

This worked for me

sudo a2disconf javascript-common

This removes the javascript-common.conf from conf-available and conf-enabled.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.