5

I'm on Ubuntu 12.10 with LAMP setup. I copied a subdirectory which has project files (php, html, css) from xampp/htdocs on my Windows PC into /var/www/ of my ubuntu. However, when I access those files from browser (I can see the directory listing), I get 403 Forbidden on all files within that directory. So I create new dummy php files within that directory just to see if I can access, and it works. Any idea what might be the problem?

clouddreams
  • 622
  • 1
  • 4
  • 13
  • 1
    ownership and rights on the files and subdirectories may be an issue. `ls -l` and check the difference between the newly created file and the copied files - maybe add that output to your question. – fvu Feb 21 '13 at 01:06
  • `/var/www` is only for localhost access. Doesn't explain your problem (and we can't look into it sans access or more description / debug infos). But anyway, make a new vhost and put your files there. – mario Feb 21 '13 at 01:11
  • @fvu yes, only thing different is for other group users, so it ccan't be the problem – clouddreams Feb 21 '13 at 01:23
  • @fvu Sorry, it was the problem. Changing permission to read-only for Other worked. This confuses me since I'm the owner and I already have read/write permission on those files. I'm not sure why Other group also needs permission. – clouddreams Feb 21 '13 at 01:36
  • 1
    @lovetostrike on normal well administered systems the webserver runs under a dedicated, low privilege user in a special group - no idea whether this user+group is standardized, have a look at the apache configuration file. That's why you had to `chmod o+r` to make it work if you're the owner. – fvu Feb 21 '13 at 11:12

2 Answers2

4

may be a ownership problem. try do chmod -R 775 /var/www/folder and/or chown -R domain:www-data /var/www/folder - where domain is the user of that particular virtualhost or www-data

for directory listing you may want to modify in /etc/apache2/sites-available/default

+Indexes

see http://www.cyberciti.biz/faq/enabling-apache-file-directory-indexing/

  • Thanks. It solves the problem but I don't understand what is going on here. I already had read/write permission for all users and after this command, it made the files executables. The dummy file I created didn't have x attribute, however I still could access it. Why could that be? – clouddreams Feb 21 '13 at 01:26
  • @lovetostrike I also have this problem, when I create files myself it works but when I copy files into my /var/www apache can't read them. – Tijme Aug 18 '14 at 18:26
2

This is how I solved the issue:

sudo su
chmod a+rwx /var/www/html/
Zoe
  • 27,060
  • 21
  • 118
  • 148