Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

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?

share|improve this question

migrated from stackoverflow.com Aug 29 '09 at 20:17

This question came from our site for professional and enthusiast programmers.

5 Answers 5

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

EDIT:

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?

share|improve this answer
    
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).

share|improve this answer
    
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.

share|improve this answer
    
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

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: http://en.wikipedia.org/wiki/Chown

share|improve this answer
    
Here's a screenshot of results of ls -als... comparing the file uploaded via FTP and the one via cPanel uploader: tiny.cc/permissions –  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
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.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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