Most recent edit on 2008-05-29 11:50:08 by AndrewBoring
Additions:
Important: If you are using a CMS like Joomla, Drupal, Mambo, or blog like Wordpress, etc, be sure to follow their recommended installation and permissions instructions!
Oldest known version of this page was edited on 2008-05-29 11:48:20 by AndrewBoring []
Page view:
Understanding File Ownership and Permissions in PHP 4
At ASO, PHP 4 runs as an Apache module with the User ID of "nobody", which is the user ID that the webserver runs under.
That means, any files it creates will be
owned by user nobody, and will have default permissions of 644 (files) or 755 (directories).
Most files in your home directory (and all folders underneath) will be owned by your user ID. These files are (by default) writable only by the owner (you), and readable by everyone else.
For a php script to create a file in a directory, you'll need to ensure that the directory is writable by the webserver. Use an FTP client to "chmod" the folder to 777. You'll usually do this for a forum upload directory, a image gallery where the webserver creates thumbnails, or a cache directory (like wp-cache).
When the webserver creates files in a directory, they will be
owned by the webserver, and you will not be able to modify them or delete them through FTP. This also applies to themes and modules installed though a content management system such as Joomla, Mambo, etc.
There are two ways around this:
- Send in a support ticket asking to change the ownership of the files/folders to your User ID. You can then delete them through FTP.
- Write a small PHP script to delete the files of a certain directory. Since the script runs as the webserver ID, it can delete those pesky files owned by "nobody"
Keep in mind, Option 2 can be risky if you are not careful to protect the file. Malicious site visitors may run it and delete files if you don't have authentication in place. You can place it in a separate website directory and password-protect that directory through cPanel, if you desire.
Back to PHP
Back to Main