PDA

View Full Version : setting include_path



ali
10-13-2004, 04:10 PM
Hi.
How can I set the include_path for my php include files on westhost?I heard that it is set either in the php.ini file or it in the httpd.conf file.But I dont know which directory these files are in.Can someone give me the path to the files and tell me how to change the setting?

torrin
10-13-2004, 04:18 PM
It looks like include_path is in /etc/php.ini. Just search in that file for include_path and you'll find it. You're probably going to want to backup the file before you make any changes to it. As for how to change it, I would assume that you can just make the change with a regular editor since php.ini is just a text file. I suppose I'm not exactly sure what you're asking. You might have to restart apache. I'm not sure how to do that.

Oh and for completeness, httpd.conf is in /etc/httpd/conf.

FZ
10-13-2004, 05:20 PM
Restarting Apache:


restart

in an SSH session, or "Restart VPS" in the Site Manager (Site Management > Site Parameters).

wildjokerdesign
10-13-2004, 06:01 PM
The only thing I can think about in modifying the include path in your php.ini is that some of WH supplied php stuff may be reliant on where it is currently set. Not sure of this but thought I would mention it in case you change it and find problems with other things.

ali
10-15-2004, 07:02 PM
The only thing I can think about in modifying the include path in your php.ini is that some of WH supplied php stuff may be reliant on where it is currently set. Not sure of this but thought I would mention it in case you change it and find problems with other things.

I opened a ticket and asked this question.They told me I can add as many 'additional' paths as I need.Right now I'm a little stuck on how to change the settings.The previous settings in my php.ini file were:



include_path = ./:/usr/local/lib/php


I wanted to change it so it looks for files in the folder "var/www/html/my_dir/inc/".So I changed it and the current settings are:


include_path = ./:/usr/local/var/www/html/my_dir/inc/


But it doesnt seem to work.Did I change it the right way?

FZ
10-15-2004, 07:30 PM
I think the colon [:] is necessary to separate the entries. So, your include_path should read:


include_path = ./:/usr/local/:/var/www/html/my_dir/inc/

ali
10-15-2004, 07:47 PM
Thanks FZ.That worked but i have a small problem.All of my scripts contain reference to include files in the following format:



include ("dir/file.php");

assuming the include path is set to var/www/html/my_dirdir/inc/.As you can already guess,the folder "dir" is inside the directory "mydir/inc".But when I've uploaded the scripts they dont work,and I get the error:


Warning: main() [function.main]: Failed opening 'dir/script.php' for inclusion (include_path='./:/usr/local/:var/www/html/my_dir/inc/')

This setting worked fine on my local machine but I cant get it to work on West Host.How do you think I should change it?
I hope I wasnt too confusing :D

FZ
10-16-2004, 07:42 AM
Well, I've never used include_path before, so I'm not exactly sure. Maybe it needs you to reference just "file.php" instead of "dir/file.php" and therefore needs you to include the dir/ bit in your include_path. If I had to guess, currently the dir/file.php include is looking for that file relative to where your PHP file is (e.g. /var/www/html) and not relative to your include_path. Like I said, I've never used include_path so I might be wrong.

wildjokerdesign
10-16-2004, 08:52 AM
Don't you need the beginning slash on your new include path i.e.
/var/www/html/my_dir/inc/? Give that a try. Can you add the "dir" to your include_path setting or does that change? You could then just put the file name in the include() since I think what Fayez has to say is correct. I think that it looks in the include_paths you have set and if does not find it there then falls back on looking for it relative to the scritp that callse it.

I think if you add the beginning slash it'll take care of it.

FZ
10-16-2004, 08:58 AM
Thanks for catching the missing leading slash, Shawn. I've edited my original post and added it in.

ali
10-16-2004, 04:05 PM
EDIT: I had made a mistake in the path I wrote.I corrected it and now it works.Thanks for your help :lol: