Apache Webserver - How to write to dir/files with permissions set at 755 instead of 777

apache, file, linux, permissions

Solution

You probably can't achieve this because the owner of the file is different than the user trying to perform an action on the file.

the permissions are:

owner-group-everyone

rwx-rwx-rwx

i.e.  111 = 7 which allows read/write and execute.  
101 = 5 which is just read and execute

you can't write to the file because your logged in user isn't part of the owner/group that has access to the file.

the final 7 (i.e. rwx-rwx-111(7)) means that globally, everyone has read/write access to that file.

how to fix this In Linux, you can use the chown or chgrp command to achieve your desired results.

Problem

I just learned to install Apache 2 on my ubuntu linux localhost for the first time. I'm making it work with PHP5. I noticed that anytime I want to write to a file or directory, I have to chmod 777 the destination. But from my experience working on 3rd party hosting solutions, I am generally allowed to write to files and dirs that have 755 permissions. What can I do on my localhost so that I can write to files and dirs with 755 permissions? If the answer to this is very long, can someone send me a link to a step by step guide to do this?

Original source