For per-domain php.ini under php-fastcgi see here
Under Plesk running php-fastcgi it is not possible to use php_admin_flag and php_admin_value directives in .htaccess files on a per-directory basis. Luckily this can be easily enabled with the htscanner extension.
All the information to get this working is out there, but as per usual, you have to piece it together from a variety of sources to get a complete picture. Here I shall provide a single complete set of instructions that have been proven to work on a CentOS5 box with Plesk 9 – although Plesk should be an irrelevance here, I mention it for completeness.
I am using PuTTY as my SSH client.
In order to install and use htscanner v1.0,0 , you must have the following things (aka dependancies):
PHP Version: PHP 5.1.0 or newer
PEAR Package: PEAR Installer 1.4.8 or newer
Odds of having >=PHP 5.1 without PEAR are slim to my knowledge, and installing it is beyond the scope of this post.
Got those? Ready to go!
To provide absolute clarity for inexperience bods, # is the SSH command prompt and shouldn’t be included in typed commands! And if you REALLY need your hand held, hit [enter] after each line. Just so you don’t sit there wondering why nothing is happening…
Download and extract htscanner
- SSH to your server with root access.
- Download the latest version of htaccess from http://pecl.php.net/package/htscanner currently 1.0.0
# wget http://pecl.php.net/get/htscanner-1.0.0.tgz
- Untar the file:
# tar -xvsf htscanner-1.0.0.tgz
Compile and run installation
- Change to the newly created directory:
# cd htscanner-1.0.0
- Run phpize:
- Run the configuration script with –enable-htscanner switch
# ./configure --enable-htscanner
- Run make to build the installer:
- Run make install to actually install the extension
# make install
Add htscanner settings
For systems that support it, you can simply copy htscanner.ini to your php conf.d directory. This is probably somwhere along the lines of /etc/php.d on CentOS 5 or perhaps for others /etc/httpd/conf.d but if you are having trouble finding it, run
# locate conf.d
You will find a bunch of them though, so make sure it’s the right one. You can also try simply googling your *nix distribution name and conf.d – for example “centos 5 conf.d”
If you are running SuSE or another flavour of Linux which doesn’t support this, you can add the contents of htscanner.ini to your php.ini file. To locate yours try the tips above for finding the php conf.d directory
The htscanner.ini file currently looks like this:
[htscanner]extension="htscanner.so"; The configuration file htscanner needs to scan for php_* directivesconfig_file=".htaccess"; The fallback docroot when htscanner can't determine the current docrootdefault_docroot="/"default_ttl=300; Stop when an error occured in RINIT (no document root, cannot get path_translated,...)stop_on_error = 0; Warn when an option cannot be setverbose = 0
You should check the contents of your htscanner.ini file though, to be safe.
This is simple enough, but for the sake of completeness and for any poor n00bs out there, to do this, and then add to php.ini using ‘vi’ text editor:
- Open htscanner.ini:
# vi docs/htscanner.ini
- Highlight all text to copy to the clipboard
- Exit vi by simply typing
and hitting [Enter]
- Open php.ini:
# vi /etc/php.ini
- Scroll to the bottom of the file with [pgdn] key
- Enter editing mode by hitting [i] key
- Press [->] Left arrow key to ensure you are at the end of the last line
- Hit [Enter] to start a new line
- Right-click the mouse to paste the htscanner.ini contents
- Exit editing mode by hitting [Esc] key
- Save and quit vi:
and hit [Enter]
On CentOS 5 and similar distros:
# service httpd restart
For other *nix versions, y’know, google it. Why not, sounds like fun to me?
And voila. You should now be up and running with per directory php_admin directives in your .htaccess files.