File permissions

I have a form with which I can upload images to my site. A permission problem made the upload impossible. Trying to make it work I changed some permissions and suddenly the entire site went down.

Tired of trying to get it back I just rightclicked the main folder and set it to 777 and the site came back.

My question is therefore. Which permission for which files?

I guess that my upload folder needs 777, but what about all the php files and other folders? What are the default permissions for php files, if there are any?

Is PHP setup using suexec or CGI? Or set as an Apache Module?
If you don’t know, you should ask your host. Along with how the web directories are setup.
Most host run Apache and PHP as the same user and all directories to be put online are under that same user.
This makes permissions pretty much pointless, you could set it as 777 and whatever.

Permissions are are not for web content they are for isolating multiple users on a server from one another.
However, if every single site is ran under the same user account as Apache, it won’t make a difference.

It’s a shared server.


Are you on a shared server? Or dedicated/virtual server?

Normally folders are given 755 permission and files are given 644 permsissions and you know well that upload folders will get 777 permissions.