Solved

path issue on new server

Posted on 2009-05-17
6
180 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
Enabling OSINT in Activity Based Intelligence

Activity based intelligence (ABI) requires access to all available sources of data. Recorded Future allows analysts to observe structured data on the open, deep, and dark web.

 
LVL 108

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 108

Expert Comment

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

Featured Post

Threat Intelligence Starter Resources

Integrating threat intelligence can be challenging, and not all companies are ready. These resources can help you build awareness and prepare for defense.

Join & Write a Comment

Generating table dynamically is the most common issue faced by php developers.... So it seems there is a need of an article that explains the basic concept of generating tables dynamically. It just requires a basic knowledge of html and little maths…
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 create and use a small PHP class to apply a watermark to an image. This video shows the viewer the setup for the PHP watermark as well as important coding language. Continue to Part 2 to learn the core code used in creat…
This tutorial will teach you the core code needed to finalize the addition of a watermark to your image. The viewer will use a small PHP class to learn and create a watermark.

747 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

12 Experts available now in Live!

Get 1:1 Help Now