Sunday, May 5, 2024
 Popular · Latest · Hot · Upcoming
0
rated 0 times [  0] [ 0]  / answers: 1 / hits: 27567  / 1 Year ago, wed, march 15, 2023, 2:54:58

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?


More From » 12.04

 Answers
5

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.


[#27132] Thursday, March 16, 2023, 1 Year  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
ainsbeave

Total Points: 280
Total Questions: 98
Total Answers: 105

Location: Faroe Islands
Member since Sat, Aug 20, 2022
2 Years ago
;