• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 462
  • Last Modified:

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.
0
Schuyler Kuhl
Asked:
Schuyler Kuhl
  • 5
  • 3
2 Solutions
 
Ray PaseurCommented:
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.
0
 
Schuyler KuhlAuthor Commented:
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.
0
 
Ray PaseurCommented:
When things like file permissions suddenly stop working, there is almost always a server-wide issue in play.  Who is your hosting company?  Have you asked them about any recent updates?
0
Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

 
Schuyler KuhlAuthor Commented:
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
0
 
Ray PaseurCommented:
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.
0
 
Schuyler KuhlAuthor Commented:
Dear Ray,

Thank you very much.  I greatly appreciate your expertise.

Best regards,

Sky
0
 
LinuxGuruLinux Server AdministratorCommented:
Hi Sky,

Just a note:

If you are having cPanel server and have root access to server, you can configure php from you end. The problem seems to be related to php handler set on server. You can set the handler to suPHP from WHM >> Configure PHP. suPHP will keep the files under users ownership and you can write without using 777 permission. If not sure, better check with the server admin who manages your server. I believe the php handler got changed after the update.

You can use DSO handler as well. But make sure that Apache_ruid module is ON if you use DSO module. This can be set from WHM >> Configure PHP

Hope this helps.

Thank you!
0
 
Schuyler KuhlAuthor Commented:
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
0
 
Schuyler KuhlAuthor Commented:
Thank you very much for your help in this issue.
0

Featured Post

NEW Veeam Agent for Microsoft Windows

Backup and recover physical and cloud-based servers and workstations, as well as endpoint devices that belong to remote users. Avoid downtime and data loss quickly and easily for Windows-based physical or public cloud-based workloads!

  • 5
  • 3
Tackle projects and never again get stuck behind a technical roadblock.
Join Now