Solved

path issue on new server

Posted on 2009-05-17
6
185 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 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
What is SQL Server and how does it work?

The purpose of this paper is to provide you background on SQL Server. It’s your self-study guide for learning fundamentals. It includes both the history of SQL and its technical basics. Concepts and definitions will form the solid foundation of your future DBA expertise.

 
LVL 110

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 110

Expert Comment

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

Featured Post

What is SQL Server and how does it work?

The purpose of this paper is to provide you background on SQL Server. It’s your self-study guide for learning fundamentals. It includes both the history of SQL and its technical basics. Concepts and definitions will form the solid foundation of your future DBA expertise.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
PHP Web Development 6 63
Can't find an open element in HTML 5 49
Joomla Editing 3 17
sitemap.xml 3 23
Part of the Global Positioning System A geocode (https://developers.google.com/maps/documentation/geocoding/) is the major subset of a GPS coordinate (http://en.wikipedia.org/wiki/Global_Positioning_System), the other parts being the altitude and t…
This article discusses how to implement server side field validation and display customized error messages to the client.
The viewer will learn how to count occurrences of each item in an array.
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 …

739 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