Categories: Blog

Ubuntu Linux Apache2 javascript folder ‘404 file not found’ error? I’ve got the fix!

I’ve had the unexpected privilege of transferring some a web application over from a CentOS Plesk/HTTPD server environment over to an Ubuntu Apache2 VPS server. The web application contained your standard CSS, images and javascript folders.

However the most puzzling thing occurred where when I configured Apache2 to run the web application, the /javascript folder could not be read even though it was physically there and in the right place. After spending two hours attempting to remove .htaccess directives, modifying CHOWN/CHMOD permissions and double checking the Apache vhost.conf file, it came down to a .conf file configured in the default Apache2 setup that was rewriting the ‘Alias’ path of any folders beginning with /javascript.

To fix this, you will need to perform the following:

  1. Type vi /etc/apache2/conf.d/javascript-common
  2. Comment out the following line: Alias /javascript /usr/share/javascript/
  3. Save and restart Apache2 by typing /etc/init.d/apache2 restart

You may choose to rename or change the entry in point #2 above depending on whether you are sharing a javascript library across your whole Apache2 setup. Let me know if this worked for you.

Peter Tran

View Comments

  • Also for Ubuntu 14.04Lts the file you need to change as above is now /etc/apache2/conf-enabled/javascript-common.conf
    I commented out that one line, restarted Apache and BAM reversed stupid magic.

  • Anyone have any clue what causes this garbage to happen? I had a site working 100% perfectly fine on my test server running Ubuntu 14.04, the computer magically restarted itself as I walked up to it after getting something to eat. When it started back up my javascript files were all magically 404 It makes me want to punch the monitor when this idiot shit happens. I am wondering if there was some sort of update while I walked away.

    This makes no sense.

  • That worked for me. Thanks. I thought it was something with mime types and JS, so was fixating the search on JS. Thanks for the redirect.

  • Thanks - that would've been a tough one to figure out without this! I probably would've just ended up renaming the folder to 'js' or something :P Glad I didn't have to resort to that.

  • Thanks, that saved me. Weird that it worked for me before, but stopped when I installed php.

Share
Published by
Peter Tran

Recent Posts

Kubernetes Resources to Learn From

I have been fortunate in working a lot more with Kubernetes lately over the last few months so I've been…

1 year ago

WordPress Development using Docker

Building my portfolio site, I thought I'd show you how I set up my Wordpress development using Docker. Given the…

1 year ago

Blank images in Puppeteer screenshots solved!

Frustrated with getting blank images in Puppeteer Chrome screenshots, recently I was in a situation where I needed to migrate…

1 year ago

Plans Moving Forward – The Revamped Web and I

It has been six year since my last major revamp/redesign of my current petertran.com.au portfolio site. So what are my…

1 year ago

Bad owner or permissions on .ssh/config

This article helps to solve a Bad owner or permissions on .ssh/config issue occurring on a Windows 10 machine when…

1 year ago

Accept payments easily and effortlessly with Pin Payments integration

Only a few lines of code required is to implement a payment system, thanks to inline Pin Payments integration. Accepting…

6 years ago