Solved

path issue on new server

Posted on 2009-05-17
6
183 Views
Last Modified: 2012-05-07
I'm moving my sites to a new server, and finding that many of my scripts are breaking.

By experimenting, I have found that:

$histfile=fopen('daily_tih.inc', 'w');
fwrite($histfile, $hist);
fclose ($histfile);

writes the file to root, ie: /

On my old server, it would write it to the directory that the script was located in.

Is there a php.ini, apache, or some other setting that I need to change to fix this?
0
Comment
Question by:St_Aug_Beach_Bum
  • 3
  • 2
6 Comments
 
LVL 15

Accepted Solution

by:
babuno5 earned 250 total points
ID: 24406840
i think this can help
http://in2.php.net/manual/en/ini.sect.safe-mode.php#ini.open-basedir


>>The special value .  indicates that the working directory of the script will be used as the base-directory.
0
 

Author Comment

by:St_Aug_Beach_Bum
ID: 24407360
Thank you babuno5,

In php.ini, with both my old server and my new, this line is commented out,

;open_basedir =

and I don't see any mention of basedir in httpd.conf (on either server), nor in .htaccess.

So I tried

open_basedir =.

and rebooted apache.  It hasn't made any difference though, it's still writing to root.

If it was just one script, I'd just fix it there, but there are a variety of sites.  It sure seems like it would be related to basedir, just from what I read on that page. hmmm
0
 

Author Comment

by:St_Aug_Beach_Bum
ID: 24407413
OK, let me back this up a bit.

I was running the command from root, which I guess it causing it to put that file in root. If I cd to that directory, it places the file in that directory.

Which brings me to another question.  On my old server, I ran the script via cron, along with scripts in various other directories.   Does cron make things run as it it were being run from inside that directory?

I plan to run them from cron again on this new server, but was testing and making sure they work by doing it by hand.  May have caused myself unneeded headaches :)

0
Ransomware-A Revenue Bonanza for Service Providers

Ransomware – malware that gets on your customers’ computers, encrypts their data, and extorts a hefty ransom for the decryption keys – is a surging new threat.  The purpose of this eBook is to educate the reader about ransomware attacks.

 
LVL 109

Assisted Solution

by:Ray Paseur
Ray Paseur earned 250 total points
ID: 24408009
You might want to consider using getcwd() something like this...

$my_file = getcwd() . '/' . important.txt';

On my server, I run cron jobs out of lower-level directories and the output from the cron goes into the current directory without much ado.  I use this for generating RSS feeds.  For example,...

HTH, ~Ray
$rss_feed_file = 'rss_feed.xml';
file_put_contents($rss_feed_file, $rss_text);

Open in new window

0
 

Author Comment

by:St_Aug_Beach_Bum
ID: 24408479
Thank you both, been testing more and apparently when I cron something it does run in that dir.

I appreciate your comments and I learned something and got the answer by following up on what you suggested.  It's working now by cron, which is what I needed in the end :)
0
 
LVL 109

Expert Comment

by:Ray Paseur
ID: 24416279
Cool!  Thanks for the points, ~Ray
0

Featured Post

PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

It is possible to boost certain documents at query time in Solr. Query time boosting can be a powerful resource for finding the most relevant and "best" content. Of course the more information you index, the more fields you will be able to use for y…
Password hashing is better than message digests or encryption, and you should be using it instead of message digests or encryption.  Find out why and how in this article, which supplements the original article on PHP Client Registration, Login, Logo…
The viewer will learn how to dynamically set the form action using jQuery.
The viewer will learn how to create a basic form using some HTML5 and PHP for later processing. Set up your basic HTML file. Open your form tag and set the method and action attributes.: (CODE) Set up your first few inputs one for the name and …

785 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