I've got a problem with JavaScript under Ubuntu, that drives me crazy.

I'm using Gedit for my web sites since I'm an Ubuntu user. When I start a new website I create (usually with the gnome terminal) folder structure, and I copy the files I need into them.
The next step is creating an index.html where I build the design and basic JavaScript functionality. JavaScript is stored in a sub-folder of the project and when i try to load one using the tag in the header, my whole page body disappears. If the source contains a script tag with its own body, and its not the first its code wont run.

I've tried to solve the problem by setting chmod to 777 with sudo chmod -R 777 . but nothing changed.
CSS is loading correctly, but JS isn't.

I'm using the newest version of apache, no mod_rewrite stuff, but i get the same problem when I run the html from file (file:///...)

Do anyone know how to solve this problem?

  • No need for "777", also it's a security problem. If your work is tested through a web server, it's enough if only the user can read (and nor write, nor executable) your files the webserver run with. You can check the log of your webserver if file is requested at all which contain your javascript code. Also usually browsers has ability to run some debug/developer tools, so you can check out what's going on. – LGB Feb 16 '11 at 12:41

The issue may be with

file. Just change the alias in this line
Alias /javascript /usr/share/javascript/

I had a issue that not able to load javascript folder in ubuntu for my local projects. I changed the alias name, it worked for me.


Neither apache nor the browser need a javascript file to be executable. The apache user (www-data) must be able to read the files and execute the directory they are in. Usually the group or user would be set to www-data, or "other" is given read permissions. Check /var/log/apache2/error_log for file access errors.

However from the symptoms you describe it's most likely a problem with your javascript code. There's probably an error in which is stopping subsequent scripts from running.

Otherwise we'd need to know what browser are you using and if you have problems on other sites.


I had this exact problem. You mentioned copying files into the folder. When I did that I was moving files from my workstation into my server's home folder using scp and then using mv on the server to move the files to proper directory. Doing this would leave the file's owner as the current user executing the command, rather then the user apache needs them to be. You can use

ls -la

To check the ownership of the files. They need to be www-data. To change this for all the files in the current directory use

sudo chown -R www-data:www-data .



Means use recursively.


Changes the owner and the group to www-data.


Means to execute this command in the current directory.

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.