[Last Call] Learn about multicloud storage options and how to improve your company's cloud strategy. Register Now

x
?
Solved

path issue on new server

Posted on 2009-05-17
6
Medium Priority
?
188 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 2
6 Comments
 
LVL 15

Accepted Solution

by:
babuno5 earned 1000 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
VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

 
LVL 111

Assisted Solution

by:Ray Paseur
Ray Paseur earned 1000 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 111

Expert Comment

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

Featured Post

Veeam Disaster Recovery in Microsoft Azure

Veeam PN for Microsoft Azure is a FREE solution designed to simplify and automate the setup of a DR site in Microsoft Azure using lightweight software-defined networking. It reduces the complexity of VPN deployments and is designed for businesses of ALL sizes.

Question has a verified solution.

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

Since pre-biblical times, humans have sought ways to keep secrets, and share the secrets selectively.  This article explores the ways PHP can be used to hide and encrypt information.
There are times when I have encountered the need to decompress a response from a PHP request. This is how it's done, but you must have control of the request and you can set the Accept-Encoding header.
The viewer will learn how to dynamically set the form action using jQuery.
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…
Suggested Courses

650 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