I am trying to create files in my /var/www folder (debian), but the folder is read only. The only way I can create a file is to go into root and create it in the terminal. Then I have to edit the contents there too. How can I create files and folders inside the www directory, or make it not readonly but still be secure some how. I don't understand how this works... thanks
You could change ownership of
/var/www to your user or group, or create a subdirectory in
/var/www and give yourself ownership. If your user name is "david" then:
david$ su - root# chown david /var/www
david$ su - root# mkdir /var/www/david root# chown david /var/www/david
Then your user will be able to read and write inside of whichever directory you give yourself ownership of.
sudo chown `whoami` /var/www
That will set the owner of /var/www to the current user, which is what
You should really read up on permissions and ownership of files/directories in posix systems if you're going to be maintaining an apache instance.
This may not be the best link, but it was first on google for "understanding unix permissions" : http://www.perlfect.com/articles/chmod.shtml
In order to do what you want and at the same time don't mess with the web server perms you must add yourself and the web server' user or group to the files and directories ownerships.
You can do it like follows:
1: # chmod -R 775 /var/www/; 2: # chown -R your-user.webserver-group /var/www/
The first line gives the user and group read, write and execution perms in the web server directory.
The second line warranties that you are the user stated in the line 1, and the web server group is in the group in the web server directory.
In that way you will be able to create, modify or delete files and folders in the
/var/www/ directory and at the same time the web server can do its normal tasks.
You could save to /tmp, then use the ftp functions like PHP's ftp_fput() to push the temp file to its proper location. It seems crazy to have the server ftp "back to itself" but the files will then be owned by the ftp user and not the apache user. Be sure to delete the tmp file and secure the file that has the ftp password. us3.php.net/manual/en/function.ftp-fput.php