Support Center » Knowledgebase » Unix Tips » Custom php.ini for Unix

Custom php.ini for Unix



On Unix, it is possible to use your own php.ini. Possible reasons for using your own php.ini:
  • If you need to use a certain php extension that isn't normally loaded by our default configuration
  • If you need to change php options that aren't normally changeable via the .htaccess or .user.ini mechanism

Disadvantages

There are some disadvantages when using your own php.ini: 
  • You lose the ability to select the php version via the control panel
  • Any changes we made on the global php.ini will not be reflected on your site
  • Changes you made to php.ini will not be applied instantly

Setup

1. Create a directory yourdomain.com/php
2. Create a php script wrapper: yourdomain.com/php/php-wrapper
#!/bin/sh
exec /hsphere/shared/php53/bin/php -c /hsphere/local/home/youracct/yourdomain.com/php.ini "$@"
Replace php53 with the corresponding version that you wish to use. For example, for php 5.5, use "php55".

If you just want to load a custom php extension, there's no need to go with the whole shebang of having your own php.ini. You can still use the global php.ini and only instruct php to additionally load your extension like this:
#!/bin/sh
exec /hsphere/shared/php53/bin/php -d extension=yourextension.so "$@"


3. Set the execute bit for this file chmod 755 yourdomain.com/php/php-wrapper

4. Create yourdomain.com/php/.htaccess
Options +ExecCGI
SetHandler fcgid-script
5. Create / edit yourdomain.com/.htaccess
RemoveHandler .php
AddType application/x-httpd-fastphp .php
Action application/x-httpd-fastphp /php/php-wrapper













Article Details
Article ID: 230
Created On: 21 Mar 2016 02:58 PM
 Back
 Login [Lost Password] 
Email:
Password:
Remember Me:
Please note that the login and password to the support area is NOT the same as your hosting control panel login and password
 
 Search
 Article Options
Home | Register | Submit a Ticket | Knowledgebase | Downloads | Control Panel User's Guide | Server Status
Language: