6

I signed up and setup a small ubuntu VPS slice during the week and everything is going great so far, except one small problem.

I have two virtual hosts setup but cannot access the javascript folder for each. If i navigate to www.domain1.com/javascript or www.domain2.com/javascript i get the following message...

You don't have permission to access /javascript/ on this server.

If I rename the directory to anything else (eg: js) I can access the contents no problem. It seems to be a reserved keyword or something, even without a javascript folder i get the same message rather than a 404 message.

I removed the .htaccess files just incase that was causing it. Nope... Any idea whats going on here?

9

Ubuntu Apache configuration already has Alias /javascript /usr/share/javascript/, see /etc/apache2/conf.d/javascript-common.conf. You could change this alias or remove this file altogether but I don't know if this breaks something else.

  • Does it? Wow I never knew that, probably cuz most of our servers are RHEL but is there any reason why they have this? Is it to hold standard library's like jQuery etc. or does it serve some other purpose? – Smudge May 27 '11 at 9:50
  • Yes, under ubuntu /usr/share/javascript/ contains jQuery & Prototype libraries provided by libjs-jquery & libjs-prototype packages. – AlexD May 27 '11 at 10:33
  • Thanks man, that fixed it... Was that an extra package i installed or is apache setup like that? – John Burke May 27 '11 at 18:57
  • AFAIK, this is default Apache configuration under Ubuntu. – AlexD May 27 '11 at 19:07
  • I have been like 5 hours changing permissions and setting things, crazy apache! o.O – Tomás Ramírez Sep 9 '14 at 10:58
4

The issue:

Web applications that use JavaScript need to distribute it through HTTP. Using a common path for every script avoids the need to enable this path in the HTTP server for every package.

This is the package that creates /usr/share/javascript alias and enables it in the Apache webserver.

Recommended fix

And that's it, you won't have any other problem with javascript directories. Another fix could be to rename /usr/share/javascript/ to /usr/share/javascript-common/, then adjust the Alias in javascript-common.conf to point to the renamed dir. Still not sure if this will affect any future update.

Another Fix:

Go to /etc/apache2/conf-available/javascript-common.conf, you will find this:

Alias /javascript /usr/share/javascript/
<Directory "/usr/share/javascript/">
     Options FollowSymLinks MultiViews
</Directory>

So you just have to comment this lines (with the # char) (is not recommend to edit directly the file in conf-enabled) to avoid the forbidden error. After that, do this:

a2disconf javascript-common
a2enconf javascript-common
1

Apache has an option called 'DirectoryIndexes', when you visit a raw path to a folder without an index document (index.html,index.php etc.) it will display a list of files and folders in that directory like a normal file browser. However if DirectoryIndexes is disabled it will throw a 403 (Access denied) error when it tries to show the folder.

Create a .htaccess file in the /javascript/ directory with the following

Options +Indexes

And try looking at the directory again, you should then get a list of all the files in the directory.

  • Access defined is 403. >500 errors range is for internal server errors. – AlexD May 27 '11 at 9:21
  • @AlexD Yeah sorry about that =) I wrote that answer at 1AM this morning – Smudge May 27 '11 at 9:49
-2

The simplest is just to override /javascript in your config to reflect what you want: Alias /javascript /mycustomdir

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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