All files on UNIX (including Linux and other UNIX variants) machines have access permissions. In this way the operating system knows how to deal with requests to access the files. Incoreect values can cause the server to refuse to display your site and give you an INTERNEAL server (500) error.
There are three types of access:
Access types are set for three types of user group:
The web server needs to be able to read your web pages in order to be able to display them in a browser. The following permissions need to be set in order for your web site to function properly.
These should be set to the correct values when you upload your script, but some times depending on how you uploaded, they are set worng or you set a wrong value.
To change file or folder permissions:
LOG INTO CPANEL
Step 1: Open your File Manager and navigate to the file or folder that you need to change.
Step 2: Click on the name of the file or folder.
Step 3: Click on the Change Permissions link in the top menu of the File Manager page.
Step 4: Click on as many check boxes as you require to create the right permission. The permission numbers underneath the check boxes will update automatically.
Step 5: Click on the Change Permissions button when you are ready. The new permission level is saved and the display updated to show the modified file.
Checking permissions can take forever so, Save the following snippet as a php file (e.g. fix.php), and upload it to your site to the folder your having problems on.
It will try to make all directories and files to there correct values in a recursive fashion. If you put this in the root folder of your script installation and run it by going to http://www.yourdomain/your-folder/fix.php it should operate on all possible files within your install folder.
MAKE SURE THE FOLDER THAT YOU PUT THIS INTO HAS 0755 PERMISSIONS
Also please make a back-up of the folder first, just in case…….. any folders that you have been asked to change via your script installer will have to be changed again once you run this script.
< ?php
file_fix_directory(dirname(__FILE__));
function file_fix_directory($dir, $nomask = array(‘.’, ‘..’)) {
if (is_dir($dir)) {
// Try to make each directory 755.
if (@chmod($dir, 0755)) {
echo “
Made writable: ” . $dir . “
“;
}
}
if (is_dir($dir) && $handle = opendir($dir)) {
while (false !== ($file = readdir($handle))) {
if (!in_array($file, $nomask) && $file[0] != ‘.’) {
if (is_dir(“$dir/$file”)) {
// Recurse into subdirectories
file_fix_directory(“$dir/$file”, $nomask);
}
else {
$filename = “$dir/$file”;
// Try to make each file 644.
if (@chmod($filename, 0644)) {
echo “
Made writable: ” . $filename . “
“;
}
}
}
}
closedir($handle);
}
}
?>
|
« Previous
|
Next »
|
What are file permissions, and how do you set them? This tutorial explains it all. One of the hardest things for the beginner webmaster to ...
How to use cron to list all the files in your website on a Linux server, and how to interpret the directory listing This article ...
What is the difference between PHP as an Apache module and as CGI? A computer program is a list of instructions understandable by a computer ...
How to use Internet Explorer, Windows Explorer as an FTP client for viewing the files in your website. You can use an "FTP client" program ...
This tutorial will teach how to password protect a directory. Password protecting a directory will allow you to require a username and password to access ...