Solved

File permissions for move file error in php

Posted on 2014-01-21
9
448 Views
Last Modified: 2014-02-03
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
Comment
Question by:skykuhl
  • 5
  • 3
9 Comments
 
LVL 108

Expert Comment

by:Ray Paseur
ID: 39797223
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
 

Author Comment

by:skykuhl
ID: 39801418
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
 
LVL 108

Accepted Solution

by:
Ray Paseur earned 400 total points
ID: 39801569
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
 

Author Comment

by:skykuhl
ID: 39811763
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
How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

 
LVL 108

Expert Comment

by:Ray Paseur
ID: 39811857
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
 

Author Comment

by:skykuhl
ID: 39812119
Dear Ray,

Thank you very much.  I greatly appreciate your expertise.

Best regards,

Sky
0
 
LVL 13

Assisted Solution

by:LinuxGuru
LinuxGuru earned 100 total points
ID: 39814225
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
 

Author Comment

by:skykuhl
ID: 39831049
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
 

Author Closing Comment

by:skykuhl
ID: 39831057
Thank you very much for your help in this issue.
0

Featured Post

Maximize Your Threat Intelligence Reporting

Reporting is one of the most important and least talked about aspects of a world-class threat intelligence program. Here’s how to do it right.

Join & Write a Comment

Suggested Solutions

Deprecated and Headed for the Dustbin By now, you have probably heard that some PHP features, while convenient, can also cause PHP security problems.  This article discusses one of those, called register_globals.  It is a thing you do not want.  …
Developers of all skill levels should learn to use current best practices when developing websites. However many developers, new and old, fall into the trap of using deprecated features because this is what so many tutorials and books tell them to u…
The viewer will learn how to dynamically set the form action using jQuery.
The viewer will learn how to look for a specific file type in a local or remote server directory using PHP.

706 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

18 Experts available now in Live!

Get 1:1 Help Now