Forum Moderators: coopster

Message Too Old, No Replies

Setting PHP Include Path

On a server running phpSuexec

         

MatthewHSE

4:26 pm on Dec 10, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



I've read a lot of posts here and other places explaining how to use .htaccess to set the include path for PHP include files. Upon trying it out, I found that adding the necessary line to my .htaccess file caused an Internal Server Error. I contacted my host, and found that the server is running phpSuexec, which my host says doesn't permit the use of .htaccess to set the php include path.

I'd like to be able to do something "on the server" that would set my include path, rather than using the

ini_set('include_path')
function on every PHP script I write. Does anyone know of anything that can be done that will allow this?

Incidentally, I'm on shared hosting on a Linux/Apache server. Would there be any possibility of my host being able to add the include path to my account's virtual host in his httpd.conf file?

Thanks for any ideas,

Matthew

ergophobe

9:50 pm on Dec 10, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



Actually, they would set it in php.ini.

There are three ways to change php settings
- runtime

- .htaccess

- php.ini

You don't want to do it at runtime, so that's out.

You can't do it via .htaccess, so that's out.

In theory, yes, your host could do it in php.ini. In practice, though, I would say that if they block you from making changes in .htaccess, there's a .0000000000001% chance that they would be willing make the change at the php.ini level.

If you read my post in the Best Practices thread (wait, you started that thread.. I hope you read it!) and you are putting a header file at the top of your script anyway, what's one more line in your config file?

MatthewHSE

3:26 pm on Dec 14, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Right, I read your post there, and that's what I'll be doing, but I'd really hoped to use .htaccess to set the include path. Maybe I'm paranoid, but I'd rather not reveal my include directory - even if it's a non-web directory - in case PHP were to stop on my server. But, then, if it's not web-accessible, that should be enough security I guess.

Hanu

3:57 pm on Dec 14, 2004 (gmt 0)

10+ Year Member



PHPSUEXEC doesn't see statements in .htaccess. Apache sees them but doesn't know what to do with them and produces an 500 error. Actually, this is good knews because it means that you *can* use .htaccess in general, just not for changing php settings.

PHP looks at environment variable PHPRC for a path to a custom php.ini. You might be able to set this environment variable using mod_rewrite or mod_env etc.

[httpd.apache.org...]

[edited by: jatar_k at 4:19 pm (utc) on Dec. 14, 2004]
[edit reason] replaced link with true apache url [/edit]