Advertisement
If you have a new account but are having problems posting or verifying your account, please email us on hello@boards.ie for help. Thanks :)
Hello all! Please ensure that you are posting a new thread or question in the appropriate forum. The Feedback forum is overwhelmed with questions that are having to be moved elsewhere. If you need help to verify your account contact hello@boards.ie

Apache & PHP Setup Help

Options
  • 22-08-2006 4:57pm
    #1
    Registered Users Posts: 677 ✭✭✭


    Hi all,
    Got the latest versions of Apache and PHP installed and running on Windows XP.

    Fired up the phpinfo script which confirmed that the Apache is indeed serving PHP pages correctly.

    Now the problem is whenever a script calls another script, it looses the relative directory and so the calling script can't find the target script. It always goes back to the root apache directory.

    E.g
    C:\Program Files\Apache Software Foundation\Apache2.2\htdocs\website.index.php

    wants to call another file such as config.php.. except it can't find it because the server looks under

    C:\Program Files\Apache Software Foundation\Apache2.2

    Same thing goes for outputting files; no matter where the script is called it ends up in the root Apache directory.

    Interestingly, running the php scripts through the cli (php.exe) outputs the target files in the right relative directory.
    Its only when the php is run through a browser that it always reverts to the root Apache directory for read and writes of php files.

    Any ideas?:confused:


Comments

  • Registered Users Posts: 7,541 ✭✭✭irlrobins


    Moving to programming forum

    (Toss up between it and Webmasters)


  • Registered Users Posts: 68,317 ✭✭✭✭seamus


    Off the top of my head:

    Check the php.ini file, and ensure that the doc_root directive points to the right directory.

    I've found Windows XP can be a bit touchy with PHP, so may need to reboot the machine after making this change. Restarting Apache may not be enough.


  • Closed Accounts Posts: 8,866 ✭✭✭Adam


    I cant really remember, its been a while since I set up a local server, but I think you have to correct that by setting your root directory in php.ini...??

    EDIT: Pipped to it, ha!


  • Registered Users Posts: 677 ✭✭✭Champ


    Thanks for the replies.
    This had really gotten me stumped. Looked through quite a few online guide about Apache & PhP and there's nothing amiss about my setup as far as i can tell. Looked through the config files for both php and apache again and again and no joy.

    I don't think its a doc_root / root document directory issue as e.g:
    C:\Program Files\Apache Software Foundation\Apache2.2\htdocs\website\index.php outputs to C:\Program Files\Apache Software Foundation\Apache2.2
    And
    C:\Program Files\Apache Software Foundation\Apache2.2\htdocs\DemoScript.php also outputs to C:\Program Files\Apache Software Foundation\Apache2.2

    Likewise for reads as well.
    Of course some of you might point out that dumping all the php files in the Apache webserver root would fix it:D; but obivously this wouldn't do for long term structured design.

    Please any more ideas before i start thumping my head against the table?:confused:


  • Registered Users Posts: 677 ✭✭✭Champ


    Problem solved!

    Seems to be a bug (tried looking it up amongst a huge bug base but no joy)with the PhP 5.x Apache module for the 2.2x series of Apache releases.

    Specifically the getcwd() or some other related function in the module.
    Just altered the config to instead run the cgi-provided binary and success!
    I know cgi... but there are steps to secure it;)


  • Advertisement
  • Registered Users Posts: 68,317 ✭✭✭✭seamus


    Ah. I had big trouble with Apache 2.2 and PHP 5. Ended up going back to Apache 2.0.

    Plenty of big hosts still use Apache 1.x because 2.x is yet to be proven :)


Advertisement