PHP.ini

PHP.ini

Posted by: dawmail333
Posted on: 2009-09-23 19:06:00

I've created a custom PHP.ini, at the default location, as per the wiki instructions. I now want to set it so only 1 folder (and it's subfolders) actually use the modified PHP.ini file. How do I have to modify the .htaccess to do this?

Re: PHP.ini

Posted by: sdayman
Posted on: 2009-09-23 19:49:00

The .htaccess file needs to go into that folder. When it's in the root folder of the domain, it applies to the domain and all its subfolders.

-Scott

Re: PHP.ini

Posted by: dawmail333
Posted on: 2009-09-23 21:08:00

But it doesn't work, and changing the location to include ../ thingies results in a 404.

Re: PHP.ini

Posted by: Atropos7
Posted on: 2009-09-23 23:06:00

In reply to:

But it doesn't work, and changing the location to include ../ thingies results in a 404.


Works for me!

Well let's try this again. I am assuming you are logging into a shell to do this ....

~ = shortcut for your home directory eg /home/username
domain = your domain name

1. mkdir ~/domain/cgi-bin
2. nano ~/domain/cgi-bin/dispatch.cgi
3. (paste contents of dispatch.cgi below and then press Ctrl-O, Enter, Ctrl-X)
4. chmod 755 dispatch.cgi
5. mkdir ~/domain/folder
6. nano ~/domain/folder/.htaccess
7. (past contents of .htaccess below and then press Ctrl-O, Enter, Ctrl-X)
8. nano ~/domain/folder/test.php
9. (past contents of test.php below and then press Ctrl-O, Enter, Ctrl-X)
10. (Copy your PHP.ini file to ~/domain/cgi-bin)
11. (Browse to http://domain/folder/test.php)
12. (Should show Loaded Configuration File: /home/.glob/username/domain/cgi-bin/PHP.ini )

dispatch.cgi

#!/bin/sh
export PHPRC=/home/username/domain/cgi-bin/PHP.ini
exec /dh/cgi-system/php5.cgi

.htaccess

AddHandler php5-cgi .php
Action php5-cgi /cgi-bin/dispatch.cgi

test.php

<?php phpinfo(); ?>

Note: This does not enable PHP FastCGI.Did you want FastCGI enabled?


Customer since 2000 cool openvein.org

Re: PHP.ini

Posted by: lividinstruments
Posted on: 2009-09-29 13:34:00

I did all this according to the dream host wiki and it doesn't work for me either. DH tells me that I have it still pointing to the DH cgi-bin, but I know I don't. Anyone else get it working?

Re: PHP.ini

Posted by: Atropos7
Posted on: 2009-09-29 14:24:00

In reply to:

DH tells me that I have it still pointing to the DH cgi-bin, but I know I don't.


So you are saying if you replace the disaptch.cgi script with:

#!/bin/sh
echo "Content-Type: text/plain"
echo ""
echo "Hello World!"


that when you browse to a PHP script you get "Hello World!" ?

$ curl --url http://example.com/file.php
Hello World!
$



Customer since 2000 cool openvein.org

Re: PHP.ini

Posted by: sXi
Posted on: 2009-09-30 19:41:00

In reply to:

But it doesn't work, and changing the location to include ../ thingies results in a 404.


If you mean that you're trying to use "../thingies" in your .htaccess file, then that isn't necessary. Just leave the .htaccess lines as they are.


In reply to:

DH tells me that I have it still pointing to the DH cgi-bin, but I know I don't. Anyone else get it working?


If you're using an exec method such as /dh/cgi-system/php5.cgi that Atropos7 mentions above, then that's correct.

Just leave all the cgi-bin stuff in place and only move the .htaccess file to those directories that you want to run under the custom php.ini.




How To Install PHP.INI / ionCube on DreamHost

Tags: inihtaccess