1. Please take a little time for this simple survey! Thank you for participating!
    Dismiss Notice
  2. Dear Pleskians, please read this carefully! New attachments and other rules Thank you!
    Dismiss Notice
  3. Dear Pleskians, I really hope that you will share your opinion in this Special topic for chatter about Plesk in the Clouds. Thank you!
    Dismiss Notice

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

Discussion in 'Plesk 9.x for Linux Issues, Fixes, How-To' started by wiseguy, Aug 11, 2009.

  1. wiseguy

    wiseguy Guest

    0
     
    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.
     
  2. unlo

    unlo New Pleskian

    22
    73%
    Joined:
    Jun 28, 2007
    Messages:
    24
    Likes Received:
    0
    So simple and great!! Thank u, works fine for me.
     
  3. cotus

    cotus New Pleskian

    22
    73%
    Joined:
    Sep 19, 2008
    Messages:
    10
    Likes Received:
    0
    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
     
  4. wiseguy

    wiseguy Guest

    0
     
    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.
     
  5. lvalics

    lvalics Silver Pleskian Plesk Guru

    36
    43%
    Joined:
    Jun 20, 2003
    Messages:
    965
    Likes Received:
    32
    Location:
    Romania
    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.
     
  6. Saif Bechan

    Saif Bechan Guest

    0
     
    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.
     
  7. thewolf

    thewolf Regular Pleskian

    25
    57%
    Joined:
    Mar 11, 2004
    Messages:
    231
    Likes Received:
    0
    Does anyone know if newer versions of Plesk support this feature out-of-the box?

    Thanks.
     
  8. Richard Maynard

    Richard Maynard New Pleskian

    19
    85%
    Joined:
    Feb 10, 2010
    Messages:
    23
    Likes Received:
    0
    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.
     
  9. jonnybravo

    jonnybravo Guest

    0
     
    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 :)
     
Loading...