Ubuntu – Javascript 404 not found, but PHP and CSS loading

apache-2.2javascriptpermissionsUbuntu

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, site.com/javascript/search.js then I get a 404. If I visit site.com/includes/formvalidation.js 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 site.com/test.js. I moved that, `mv test.js javascript/* and visiting site.com/javascript/test.js 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/">

Best Answer

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.