1

That's really strange :So after i upload a folder with php files on another service,and try to execute them from a browser,i get 500 error.If i open a file in a text editor,save it with different name like file1.php,then erase the original,and rename the file1.php to the previous name,it works.

a44
  • 23
  • 3
  • What Webserver do you use? Apache/IIS? Is there anything in the error logs? – fab Mar 19 '11 at 20:33
  • That sounds like a cache issue. I would see if clearing the browser cache fixes it. – JOTN Mar 19 '11 at 20:37
  • @fab I use Apache and I found nothing in the error logs about those 500 errors. – a44 Mar 19 '11 at 20:43
  • @JOTN clearing cache doesn't help and I don't see how that can be related,because the browser gets 500 responce from the server every time. – a44 Mar 19 '11 at 20:44

2 Answers2

5

This sounds a lot like a permissions issue. When you save the "second" file, you're saving it with permissions 0644 by default, with your user/group, at least on *nix. If you want, post the the output of ls -l file1 file2 before you do the rename, and I can give you a better answer.

As for permissions, try changing the permissions on the original file by using chmod:

chmod 0644 <file>
Andrew M.
  • 10,982
  • 2
  • 34
  • 29
  • You are ...just prefectly right.Thanks ,and why the scripts didn't work with chmod 0664 – a44 Mar 19 '11 at 20:55
  • I'm glad it fixed it! I'm not actually sure why, but it sounds like a possible security feature. I.e., don't let Apache execute arbitrary scripts that are executable on the system (I.e., /bin/cat). But that's just a wild guess... :) – Andrew M. Mar 20 '11 at 03:08
2

The sequence "upload, fail, edit, save, rename, succeed" tells me that it's likely a line-ending issue. Try running:

dos2unix original-uploaded-file

to see if that fixes the problem.

Dennis Williamson
  • 60,515
  • 14
  • 113
  • 148
  • i thought that it MUST be something like that,but in the first place my developer environment is *nix and the hosting server is *nix and Redmumba was right-it has been a matter of permissions – a44 Mar 19 '11 at 20:58
  • But this is definitely one of the steps to take to debug future issues, of course! :) – Andrew M. Mar 20 '11 at 03:10