Take the 2-minute tour ×
Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free, no registration required.

I am new to Ubuntu, I've installed 12.04. I used to use wamp server on Windows, and after changing OS I moved some files from www folder to /var/www on Ubuntu. But when I try to view that folder in a browser it doesn't display anything.

Probably there is a problem with permission issues. What are proper permissions for /var/www folder? Here are my /var folder permissions:

drwxrwxr-x  4 root root     1024 Feb  4 20:06 www

I have run

chmod -R 755 /var/www  
chown -R root /var/www

Right now that /var/www folder is empty, but how can I configure apache to show files under that folder in browser?

share|improve this question

2 Answers 2

up vote 0 down vote accepted

By default apache is configured to show following files instead of directory listing:

DirectoryIndex index.html index.cgi index.pl index.php index.xhtml index.htm

You can recursively list all these with this:

find /var/www -name 'index.*'

If your directory have any of those, apache will show it, instead of something like this:

Example of apache file listing

To fix that, delete or rename index.* files to something else. Alternatively, you can change DirectoryIndex directive and reload apache (/etc/init.d/apache2 reload).

By default, apache DocumentRoot is /var/www. Only files under that folder are displayed. Additionally, symlinks are followed only if destination is owned by same user. If you have files under /var/www, you don't have to care about that.

Apache does not list files that www-data user can not read. As long as there's r and x the last group (marked with ^ below), everything is fine:

drwxrwxr-x  4 user group     4014 Feb  4 23:16 filename
       ^ ^

Technically, you only need x for folders. Your commands for changing the permissions were correct:

chmod -R 755 /var/www  

If apache does not list any files even if you don't have any index files on your folder, use

tail -f /var/log/apache2/error.log

to see which errors apache encountered.

share|improve this answer

Install Apache using following command

sudo apt-get install apache2

Now, open /etc/apache2/sites-enabled/000-default file check if following line is present

DocumentRoot /var/www

If any other path is present, change it to /var/www

Now you can put any html file to view it in your browser. Also, if you add index.html to /var/www and visit http://localhost/ in browser, you will be able to see it.

share|improve this answer
    
Actually I've already install apache and all other elements, and yes that line is present.. I can view files that I created in the folder, but I can't view that specific folder that I copied from Windows, although it almost doesn't contain php code that could have an error. So there must be a permission issue, or may be I should change group to www-data?! ps I have added myself to that group.. –  Fort Nox Feb 4 at 19:09
    
You don't have to add yourself to that group. root is just fine as owner of those files - actually it's better than www-data, because then apache do not have permission to modify or remove those files. –  Olli Feb 4 at 20:07

Your Answer

 
discard

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.