Problems with the /var/www folder
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:
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.
Related videos on Youtube
Fort Nox
Updated on September 18, 2022Comments
-
Fort Nox over 1 year
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? -
Fort Nox over 10 yearsActually 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..
-
Olli over 10 yearsYou don't have to add yourself to that group.
root
is just fine as owner of those files - actually it's better thanwww-data
, because then apache do not have permission to modify or remove those files.