?
Solved

path issue on new server

Posted on 2009-05-17
6
Medium Priority
?
187 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
Don't Cry: How Liquid Web is Ensuring Security

WannaCry is just the start. Read how Liquid Web is protecting itself and its customers against new threats.

 
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

Migrating Your Company's PCs

To keep pace with competitors, businesses must keep employees productive, and that means providing them with the latest technology. This document provides the tips and tricks you need to help you migrate an outdated PC fleet to new desktops, laptops, and tablets.

Question has a verified solution.

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

If your site has a few sections that need to be secure when data is transmitted between the server and local computer, such as a /order/ section for ordering or /customer/ which contains customer data, etc it would of course be recommended to secure…
Many old projects have bad code, but the budget doesn't exist to rewrite the codebase. You can update this code to be safer by introducing contemporary input validation, sanitation, and safer database queries.
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…
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 …
Suggested Courses

770 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