Server Fault is a question and answer site for system and network administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

When new php files are created and first uploaded to our apache server via FTP they show a 500 Internal Server Error when accessed through the browser.

The permissions of the file after upload are 644. I also tried changing it to 777 and no dice.

The only way I've been able to get around this was to upload via the cpanel file uploader and then it's accessible and I can do the rest of the editing via FTP. But that's a pain and annoying to expect other users on our server to do.

Is there some settings I'm missing?


migration rejected from Feb 23 at 14:04

This question came from our site for professional and enthusiast programmers. Votes, comments, and answers are locked due to the question being closed here, but it may be eligible for editing and reopening on the site where it originated.

closed as unclear what you're asking by HopelessN00b, kasperd, Ward, Jenny D, Roman Feb 23 at 14:04

Please clarify your specific problem or add additional details to highlight exactly what you need. As it's currently written, it’s hard to tell exactly what you're asking. See the How to Ask page for help clarifying this question.If this question can be reworded to fit the rules in the help center, please edit the question.

If you have access to SSH, run the following command which lists all the files in the current directory and lists the attributes:

ls -als

This will return something as follow:

4 -rw-r--r-- 1 root root 176 Jan 6 2007 .bashrc

4 -rw-r--r-- 1 root root 100 Jan 6 2007 .cshrc

make sure the root root is the same as your user and group, respecitively. Otherwise, you wont be able to modify the permissions on that file, which is where your problems are coming into play (I suspect)

To fix this, you would then need to login on as the super user (su) and run this command

chown your_user.your_group your_folder_name

Take from here:

Here's a screenshot of results of ls -als... comparing the file uploaded via FTP and the one via cPanel uploader: – Susan Aug 28 '09 at 5:55
The only thing different I can see is an extra Write permissions, which shouldn't make a difference.... You might try changing the permissions a folder up? – Jefe Aug 30 '09 at 7:26

How about the permissions of the directory they're in?


I found this webpage. It says the explanation is often a malformed PHP CGI file.

Did you say something about editing the PHP file in cpanel? What kind of editing is necessary? Were you fixing the malformed PHP file? (damn, I can't see your post while I'm editing my answer).

[quick look later]

What was 'the rest of the editing' you referred to?

It happens with all directories. For this specific test case there are many other php files which run from the directory with no problem. – Susan Aug 28 '09 at 5:53

Your best bet is to have a look at the Apache logs; they'll tell what the error is about. They can usually be found from /var/log/apache2/ (in case of Apace 2).

Done't see /var/log/apache2/ tailing /etc/httpd/logs/error_logs and not seeing anything of relevance when hitting the script in question. Is that the right – Susan Aug 28 '09 at 6:43
The exact location of the logs of course depends on the system in question. Etc/http/logs/error_logs sounds good, though. Have a look at the timestamps in the logs, and the modification times of the logfiles themselves, to convince yourself whether they're the right or not. – mad-j Aug 28 '09 at 6:53

Compare the file uploaded through cpanel to the one via ftp. Find out how they are different. I suspect it may be the owner or the group that differs.

Edit: Okay, try setting the permissions to match the working one (664 vs 644). Some web servers insist on particular settings and may try to "protect" you from setting too many permissions.

If that doesn't work, maybe cpanel modifies some other permissions list. Maybe in .htaccess, but I'm grasping at straws. Something has to be different, though.

Owner and group is the same of the working and non working file. Posted screenshot to jefe's post. – Susan Aug 28 '09 at 5:56
up vote -1 down vote accepted

The problem was narrowed down not to permissions but the encoding of the file and how it was uploaded. Not exactly sure of how to correct it but switching FTP programs from Fetch to Cyberduck has been our temp fix.


Not the answer you're looking for? Browse other questions tagged or ask your own question.