• If you are still using CentOS 7.9, it's time to convert to Alma 8 with the free centos2alma tool by Plesk or Plesk Migrator. Please let us know your experiences or concerns in this thread:
    CentOS2Alma discussion

HOWTO: Custom php.ini files for each domain when using FastCGI

W

wiseguy

Guest
WARNING! FOLLOW THIS HOWTO ON YOUR OWN RISK! IT WORKED FOR ME, BUT I CAN'T GUARANTEE THAT IT WILL WORK FOR YOU!

I'm running Plesk Panel 9.2.2 on CentOS 5.3 with PHP 5.2.9 (installed from the AtomicRocketTurtle.com yum repository).

1. Move /usr/bin/php-cgi to /usr/bin/php-cgi.app

2. Create a new /usr/bin/php-cgi file and put the following lines in it:
Code:
#!/bin/sh
#
# Custom PHP FCGID wrapper for Plesk domains
#

PHPRC="/etc/php-ini.d/php-${UID}.ini"
[ -f ${PHPRC} ] || PHPRC="/etc/php.ini"

export PHPRC
exec /usr/bin/php-cgi.app

3. Create the directory /etc/php-ini.d/

4. Check domain/ftpuser UID for which you want to have a custom php.ini.
Example /etc/passwd:
icann:x:10001:2523::/home/httpd/vhosts/icann.org:/bin/false

4. Copy the original /etc/php.ini to /etc/php-ini.d/php-10001.ini

5. Make any changes you want to php-10001.ini

6. Run service httpd reload

Done!


This howto is based on this blog post: Plesk, PHP, FCGI, and the quest for the custom 'php.ini' per domain
I've done 2 small changes to the provided script.
 
Perfect!!!
I've just set the new /usr/bin/php-cgi file as 755 (otherwise it gives me error "file is writable by others" in suexec_log)

Just one question: What happens to others vhost? I'm i supposed to create a php-xxxxx.ini for each domain in plesk using fasrcgi?

thanks

Andrea
 
Perfect!!!
I've just set the new /usr/bin/php-cgi file as 755 (otherwise it gives me error "file is writable by others" in suexec_log)

Just one question: What happens to others vhost? I'm i supposed to create a php-xxxxx.ini for each domain in plesk using fasrcgi?

thanks

Andrea

If the php-cgi wrapper script can't find a php-[userid].ini file for the specific domain/userid, it will use the default /etc/php.ini instead. You can verify which php.ini is used with phpinfo.
 
In this situation I do not see how a domain owner can modify the php.ini for his own domain.
I still siggest that for the moment mod_suphp solution what we proposed work fine for most of the server owners.

Eash domain owner can modify his own php.ini and it is working.
 
Is this still the way to go in Plesk 9.3 for fastCGI or is there another method available. I am thinking to switch to this setup because I want to start using fastCGI and not being able to customize the php settings per domain is a major downside.

I have read something about this being changed already, or will change in PHP 5.3. We will then be able to just use the vhost.conf file for all this, or will this never be possible. Does anyone have any updates on this.
 
This feature does not work out of the box in Plesk 9.5 on Lenny amd64. For such a large vendor stuff like this should work out of the box - or at the very least disable the "safe mode" checkbox when FastCGI is used.
 
Please simplify :)

I've been trying to accomplish this feat for several days now and just can seem to come across a tutorial that makes this simple.

Forgive me, but I am a Noob to this and if it's possible could someone explain this in layman's terms?

I see the suggestions for mod_suphp. That's great, but doesn't fit my needs. I used this tutorial: http://wiki.mediatemple.net/w/DV:Run_PHP_as_FastCGI_and_resolve_Apache_permission_errors
to configure my PHP to run as FastCGI which is needed for the permissions issues that come up in building Joomla CMS websites.

Now I just need the ability to create php.ini files on a per domain basis. Could someone please help make this as easy as possible....I'm a fast learner, but I am still learning.

Putting a step by step would be great, especially if you could include the ssh commands.

If I do somehow figure this out before someone posts....I'll be sure to post my results :)
 
Back
Top