Configuring PHP - setting the inlcude_path...

Need help installing PHP, configuring a script, or configuring a server? Then come on in and post your questions! We'll try to help the best we can!

Moderator: General Moderators

Post Reply
JDW884
Forum Newbie
Posts: 3
Joined: Fri Nov 02, 2007 1:17 pm
Location: Independence, MO USA

Configuring PHP - setting the inlcude_path...

Post by JDW884 »

Hi,

I'm brand new to PHP, but have been doing other web development for 3+ years now.

I read somewhere that you can increase the security of PHP applications that access a database by specifying an include directory that is not directly accessible from a browser -- and I would like to implement this.

I have two questions:

1. How do I configure the php.ini file? (Obviously, I cannot just edit the text file in something like "nano" and save it -- I've tried that already...)

2. What is the correct syntax for specifying a directory that is parallel to the html directory? (I'm assuming that something like "../include/" will work, but I'd rather ask someone who knows than spend the time tinkering with it.)

Thank you,
Julie

PS. PHP V5.0.4, Apache V2.0.54 (In case these make a difference...)
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

Actually you can just edit the file. But you need to restart Apache afterward to get PHP to update the settings.

Alternately, you can use an .htaccess file to simply deny all requests to the directory.
JDW884
Forum Newbie
Posts: 3
Joined: Fri Nov 02, 2007 1:17 pm
Location: Independence, MO USA

Post by JDW884 »

Hmm... I should have known that... :oops: Ok, so now I know how to get my changes to the php.ini file to take effect. (Thank you, feyd.)

Since my last post, I've done some googling / reading on the include_path settings -- plus I tested my stated assumption... (I now know that my original assumption on the syntax for the include path was erroneous.)

All of the posts / FAQs I came across tell how to change the settings, but do not specify the syntax. Is the path directly related to the server -- or to the website? (This may sound like a strange question, but I am dealing with a server with 20+ websites on it. I need to know if I can set a single path, which will then go to the appropriate "include" directory for the website that is calling it -- or if I need to set a separate include path for each website -- or if I have to put the include files for all 20 websites <<assuming they will all eventually use PHP to some degree>> in one directory. I am hoping for the first -- and afraid that it is one of the latter two...)

Would someone please either point me to clear documentation -- or give me the benefit of their experience? (I hate "guess-n-check" and am already behind schedule on this project...)

Thank you,
Julie
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

Is the "appropriate" directory for the websites technically different from each other? I don't believe this (#1) is generally possible unless maybe Apache is run under their user and therefore has access to their home/user directory.

Provided the scripts are the same across board you could make a readonly directory for PHP to load generically.

The path syntax various from server operating system to operating system. i.e. it is dependent of the server. It is a reference to the server's file system, not the website structure.

You can check what your server will use as a path separator by echoing PATH_SEPARATOR, a PHP constant.
JDW884
Forum Newbie
Posts: 3
Joined: Fri Nov 02, 2007 1:17 pm
Location: Independence, MO USA

[Resolved] Configuring PHP - setting the inlcude_path...

Post by JDW884 »

In my other web development environment -- fs[ix] nPX -- option #1 is not only possible, but the preferred implementation. It can be very handy when running multiple, unrelated websites on a single web-server. (I guess I am just slightly "spoiled"...)

Anyway, I got the PHP includes working by setting a complete directory path from the server's root directory.

I appreciate the assistance!

Regards,
Julie
Post Reply