You can provide each user or domain its own php.ini file. There are two basic ways to provide each user a php.ini file:
a) Setup chrooted jail for each domain and user will get /etc/php.ini inside each jail
b) Setup individual fastcgi instance for each domain along with php.ini
Let us say you have two domains as follows
- theos.in php.ini location /home/lighttpd/theos.in/php.ini
- cyberciti.biz php.ini location /home/lighttpd/cyberciti.biz/php.ini
- /etc/php.ini - generic file for the rest of all domains
You need to add following directives to lighttpd.conf file:
$HTTP["host"] =~ "(^|\.)theos\.in$" {
server.document-root = "/home/lighttpd/theos.in/http/"
accesslog.filename = "/var/log/lighttpd/theos.in/access.log"
server.error-handler-404 = "/index.php?error=404"
fastcgi.server = ( ".php" =>
((
"bin-path" => "/usr/bin/php-cgi -c /home/lighttpd/theos.in/php.ini",
"socket" => "/home/lighttpd/theos.in/php-cgi.socket",
))
)
}
$HTTP["host"] =~ "(^|\.)cyberciti\.biz$" {
server.document-root = "/home/lighttpd/cyberciti.biz/http/"
accesslog.filename = "/var/log/lighttpd/theos.in/access.log"
server.error-handler-404 = "/index.php?error=404"
fastcgi.server = ( ".php" =>
((
"bin-path" => "/usr/bin/php-cgi -c /home/lighttpd/cyberciti.biz/php.ini",
"socket" => "/home/lighttpd/cyberciti.biz/php-cgi.socket",
))
)
}
Note option -c /path/to/my/custom/php.ini passed to /usr/bin/php-cgi. It will force php to Look for php.ini file in the directory path specified by us.
Now end users can modify php.ini as per requirements.
Pitfalls
- Although a user can make changes to php.ini file, you still need to restart a web server using root or equivalent privileges
- This may also open your box to new security issue such as wrong php.ini settings or user can load any custom php modules
You can apply same settings to Apache web server using jail or lighttpd fastcgi as a proxy.
- Email this to a friend
- Printable version
- Rss Feed
- Last Updated: Jul/16/2007

{ 0 comments… add one now }