Link to home
Start Free TrialLog in
Avatar of Schuyler Kuhl
Schuyler Kuhl

asked on

File permissions for move file error in php

Greetings,

There is a page that lets the user upload a pdf and file it.  It has worked for at least 5 years but it stops working.

When I looked at it i tried to fix it quickly for one instance by uploading the file manually using the Dreamweaver ftp client.  But this failed with a permission error in the ftp log.

Through testing I found that the folder was owned by nobody with permissions 755.  The php script couldn't move a file into that folder.  And my ftp client couldn't.  Through messing with it I found that if I made the owner the "siteadminusername" and then made the permissions 777 the php page was able to work for that one instance.

So should I change the permissions of all the folders that exist (around 900) or change the php code to work properly with the original permissions.  As it did previously I assume.

I've been figuring it out via trial and error, but I'm not sure what to do next to resolve the issue.

Thank you.
Avatar of Ray Paseur
Ray Paseur
Flag of United States of America image

Permissions set to 644 should be adequate for PHP to write to files in the WWW root.  Depending on your hosting company, you may be able to write outside of the WWW root into other files controlled by your account.

This sounds like the host may have moved your PHP site to a new machine or upgraded PHP in some way that made it not work any more.  PHP running as "nobody" is a pretty standard practice.
Avatar of Schuyler Kuhl
Schuyler Kuhl

ASKER

Thank you.

Still I can't decide what to try to fix.  If I could make the script make the folder initially with owner 'domainadminusername' and permissions 777 then I think it would work fine.  I can see that the older folders have that owner and permissions.

Or if I could make it so the script would be allowed to move the file under the permissions owner nobody 755.  The fact that I also can't upload a file using an ftp client to the folder created by the script initially makes me think I should be looking at how to make the folder differently.

I guess it is likely that something has  changed with my php but I'm not sure what to look for in that way.

Thank you.
ASKER CERTIFIED SOLUTION
Avatar of Ray Paseur
Ray Paseur
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Hello,

Yes I have and I agree with you that it is server wide.  It is a cpanel server and updates do run on it regularly.  It is on a company called ServerTune and when I have asked them about it they have said that I need to update my scripts to keep up with changes in php.  But the tricky part is that I don't know what to change.

Last night I tried to install the local version of SlideShowPro Director.  That is usually a pretty straightforward task that I have done a few times.  The process is that it using ftp you upload a folder called slideshowpro with an index file in it.  Then you browse to that folder and it starts a process to download and install the application.

Initially it gave an error that it couldn't write to the directory. I had to change the permissions in a similar way as above.  Make it owned by domain admin account with permissions 777.  It woudn't work at all owned by nobody, even with permissions 777.  I think this is diagnostic in some way because php is running as nobody but it seems like nobody can never write a file in any directory.  I think if I could solve that dilemna things would return to normal.

Anyway after slideshowpro downloads its components the installer fails with a blank white screen.  In the error log are about 20 lines similar to this:

[27-Jan-2014 01:04:14 UTC] PHP Warning:  require() [<a href='function.require'>function.require</a>]: Unable to access /home/botticel/public_html/slideshowpro/app/cake/basics.php in /home/botticel/public_html/slideshowpro/index.php on line 52
[27-Jan-2014 01:04:14 UTC] PHP .....

I can't see the file it references "cake/basics.php" through ftp or putty so i'm not sure if this is part of the same issue or not.

This is very tricky.  Thanks very much for your guidance.

Best regards,

Sky
Sky, save yourself from this mess.  Just get another host.  Not to be flip, but this is an error on their part and they ought to have taken ownership of the problem.  It is not a PHP problem when the file paths suddenly stop working.

I use and am glad to recommend ChiHost.com.  They have excellent tech support.  I have also had good experiences with HostGator, Pair and LiquidWeb.  I have had poor support experiences with SiteGround and GoDaddy.
Dear Ray,

Thank you very much.  I greatly appreciate your expertise.

Best regards,

Sky
SOLUTION
Avatar of Linux Guru
Linux Guru
Flag of India image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Greetings,

I wanted to conclude this thread because the issue had been resolved.

In the end I believe that the issue was caused by "Safe Mode" being enabled in the php.ini file.  I really don't know anything about this but the way it was worked out was this.

During the investigation into the original issue I learned that (possibly unrelatedly) that on another domain some old slideshowpro pages were not displaying the photo galleries as they had in the past.  When I attempted to install the current version of slideshowpro it failed to install.  When I used its preparation tool to test the server I noticed that the server failed due to the fact that "safemode" was enabled in php.ini.

I made a tech support request to my host company to disable this and when they did pretty much all the current issues I have been having were resolved.

Arun SV, the info you posted is correct as far as I can tell.  I had submitted a support request to Cpanel support and they were giving me similar info to resolve the issue based on the file permissions symptoms and which user is the owner of the folders in question.  They had helped me re-compile apache to enable the configuration that you are describing but at the same time I was working on the track that resulted in the resolution that I described above so I didn't end up making those changes.

Thank you very much for your help in this issue.

Best regards,

Sky
Thank you very much for your help in this issue.