Page 1 of 2 12 LastLast
Results 1 to 15 of 23

Thread: Fastcgi (Fcgid) and php.ini per user

  1. #1
    Registered Member
    Join Date
    May 2003
    Location
    Acequias :: Granada :: España
    Posts
    220
    cPanel/WHM Access Level

    DataCenter Provider

    Question Fastcgi (Fcgid) and php.ini per user

    Hello.

    The issue of implementing a user php.ini by using FastCGI (Fcgid) in this Cpanel me back a little bit crazy.

    The question is that following the manual and the post is in these forums, not that it is applied using a php.ini per user.

    According manual y use /usr/local/apache/conf/userdata/std/2/<user>/<domain>/*.conf and this work because if put any directive for managed php values, fails reload apache. Also Apache read config file put in this folder.

    Weel, on this folder i put a file named php.conf with several test. On last according FCgid, put
    DefaultInitEnv PHPRC=/home/censo/php

    Nothing.

    Imposible for me that apache read php.ini on user home.


    Any ideas?

  2. #2
    Registered Member cPanel Partner NOC Badge
    Join Date
    Feb 2003
    Location
    Gothenburg, Sweden
    Posts
    329
    cPanel/WHM Access Level

    DataCenter Provider

    Default

    Running fcgid on one of our servers to test it out. So far it has significantly lowered the load on the machine but we're unable to use custom php.ini 's.

    Is there anyone who know's how to use custom php.ini's with fcgid, eaccelerator? We've tried both using a wrapper (even if fcgid is running as the default php option) and using php.ini in each folder where php executes. Nothing seems to be helping.

    Anyone?

    twitter: oderland_david

  3. #3
    Registered Member
    Join Date
    Oct 2008
    Posts
    16

    Default

    Hi, I just tried a few modifications for fcgi as apache handler and thereby I found something that might be interesting for you.

    For giving every account its own php.ini, I made the following.

    1. Make a backup of your files

    2. Within the accounts public_html folder put a .htaccess file with the following lines in it:
    PHP Code:
    AddHandler php5-fastcgi .html
    Action php5
    -fastcgi /cgi-bin/php5.fcgi 
    3. Move to the cgi-bin folder within your accounts public_html folder and add two files.

    --First one is the copy of your php.ini with your modifications

    --The second file name php5.fcgi and add the following lines in it:

    PHP Code:
    #!/bin/sh
    export PHP_FCGI_CHILDREN=1
    export PHP_FCGI_MAX_REQUESTS
    =10
    exec 
    /usr/local/cpanel/cgi-sys/php5 
    4.Go to usr/local/apache/conf/php.conf and put the following lines in that file:

    PHP Code:
    # This file was automatically generated by the Cpanel PHP Configuration system
    # If you wish to change the way PHP is being handled by Apache on your system,
    # use the /usr/local/cpanel/bin/rebuild_phpconf script or the WHM interface.
    #
    # Manual edits of this file will be lost when Apache is updated.

    # This file was automatically generated by the Cpanel PHP Configuration system
    # If you wish to change the way PHP is being handled by Apache on your system,
    # use the /usr/local/cpanel/bin/rebuild_phpconf script or the WHM interface.
    #
    # Manual edits of this file will be lost when Apache is updated.
     
    # Fastcgi configuration for PHP5
    LoadModule fcgid_module modules/mod_fcgid.so
    MaxRequestsPerProcess 500
    MaxProcessCount 1000
    DefaultMaxClassProcessCount 100
    IPCConnectTimeout 60
    IPCCommTimeout 60
    PHP_Fix_Pathinfo_Enable 1
    IdleTimeout 900
    IdleScanInterval 120
    BusyTimeout 300
    BusyScanInterval 120
    ErrorScanInterval 9
    ZombieScanInterval 9
    ProcessLifeTime 3600
     
    AddHandler php5
    -fastcgi .php
    Action php5
    -fastcgi /cgi-bin/php5.fcgi
    AddType application
    /x-httpd-php .php
     
    # End of autogenerated PHP configuration. 
    So thats it and works fine for me. All you have to do is to add that files to all you accounts to make it work.

    Also be careful of the chmod you are giving to the php.ini for example. Depending if you wish to make your customers able to change it or if you just want to be the only one to administrate it.

    Only be careful, if you recompile or update your apache, the php.conf file will be overwritten and you have to rework it.

    Hope it helps.
    Last edited by mikesta; 01-28-2009 at 04:25 AM.

  4. #4
    Registered Member cPanel Partner NOC Badge
    Join Date
    Feb 2003
    Location
    Gothenburg, Sweden
    Posts
    329
    cPanel/WHM Access Level

    DataCenter Provider

    Default

    Thanks Mikesta, gonna have a go at it now.
    You can probably add those changes to:

    /usr/local/apache/conf/includes/pre_virtualhost_global.conf

    to keep them between easyapache updates. So leave the default info in php.conf and add your other stuff in that file.

    I'll get back to you with my results

    twitter: oderland_david

  5. #5
    Registered Member cPanel Partner NOC Badge
    Join Date
    Feb 2003
    Location
    Gothenburg, Sweden
    Posts
    329
    cPanel/WHM Access Level

    DataCenter Provider

    Default

    Made a few changes:

    2.
    Code:
    AddHandler php5-fastcgi .php
    Action php5-fastcgi /cgi-bin/php5.fcgi
    I didnt want my .html files to be treated like php.

    4. Left php.conf as it was default and added:

    Code:
    MaxProcessCount 1000
    DefaultMaxClassProcessCount 100
    IPCConnectTimeout 60
    IPCCommTimeout 60
    PHP_Fix_Pathinfo_Enable 1
    IdleTimeout 900
    IdleScanInterval 120
    BusyTimeout 300
    BusyScanInterval 120
    ErrorScanInterval 9
    ZombieScanInterval 9
    ProcessLifeTime 3600
    to /usr/local/apache/conf/includes/pre_virtualhost_global.conf and restarted apache.

    This makes it possible for users to choose through .htaccess if they want to use custom php.ini or not instead of enforcing it on them.

    Have one issue though. Custom php.ini with eaccelerator enabled in it will result in core dumps. Any idea why this happens?

    twitter: oderland_david

  6. #6
    Registered Member cPanel Partner NOC Badge
    Join Date
    Feb 2003
    Location
    Gothenburg, Sweden
    Posts
    329
    cPanel/WHM Access Level

    DataCenter Provider

    Default

    Found my old thread. The core dumps were because of mpm-worker being multithreaded and eaccelerator not. Switched to prefork instead for now - might switch back to worker later and use APC as an accelerator instead. (Magento got hooks for APC etc)

    twitter: oderland_david

  7. #7
    Registered User
    Join Date
    Apr 2005
    Posts
    2

    Default

    mikesta and internetfab. Thanks for this, it helped a lot.

  8. #8
    Registered Member cPanel Partner NOC Badge
    Join Date
    Feb 2003
    Location
    Gothenburg, Sweden
    Posts
    329
    cPanel/WHM Access Level

    DataCenter Provider

    Default

    Just a heads up - easyapache comments out

    Code:
    AddHandler php5-fastcgi .php
    from .htaccess when it's done upgrading. Just noticed this a week ago and haven't had the time to play around with it (well, except using find and replace..).

    If anyone know a workaround to this "feature" let me know.

    twitter: oderland_david

  9. #9
    Registered Member
    Join Date
    Feb 2008
    Location
    Ukraine
    Posts
    13

    Default

    Quote Originally Posted by mikesta View Post
    Hi, I just tried a few modifications for fcgi as apache handler and thereby I found something that might be interesting for you.

    For giving every account its own php.ini, I made the following.

    1. Make a backup of your files

    2. Within the accounts public_html folder put a .htaccess file with the following lines in it:
    PHP Code:
    AddHandler php5-fastcgi .html
    Action php5
    -fastcgi /cgi-bin/php5.fcgi 
    3. Move to the cgi-bin folder within your accounts public_html folder and add two files.

    --First one is the copy of your php.ini with your modifications

    --The second file name php5.fcgi and add the following lines in it:

    PHP Code:
    #!/bin/sh
    export PHP_FCGI_CHILDREN=1
    export PHP_FCGI_MAX_REQUESTS
    =10
    exec 
    /usr/local/cpanel/cgi-sys/php5 
    4.Go to usr/local/apache/conf/php.conf and put the following lines in that file:

    PHP Code:
    # This file was automatically generated by the Cpanel PHP Configuration system
    # If you wish to change the way PHP is being handled by Apache on your system,
    # use the /usr/local/cpanel/bin/rebuild_phpconf script or the WHM interface.
    #
    # Manual edits of this file will be lost when Apache is updated.

    # This file was automatically generated by the Cpanel PHP Configuration system
    # If you wish to change the way PHP is being handled by Apache on your system,
    # use the /usr/local/cpanel/bin/rebuild_phpconf script or the WHM interface.
    #
    # Manual edits of this file will be lost when Apache is updated.
     
    # Fastcgi configuration for PHP5
    LoadModule fcgid_module modules/mod_fcgid.so
    MaxRequestsPerProcess 500
    MaxProcessCount 1000
    DefaultMaxClassProcessCount 100
    IPCConnectTimeout 60
    IPCCommTimeout 60
    PHP_Fix_Pathinfo_Enable 1
    IdleTimeout 900
    IdleScanInterval 120
    BusyTimeout 300
    BusyScanInterval 120
    ErrorScanInterval 9
    ZombieScanInterval 9
    ProcessLifeTime 3600
     
    AddHandler php5
    -fastcgi .php
    Action php5
    -fastcgi /cgi-bin/php5.fcgi
    AddType application
    /x-httpd-php .php
     
    # End of autogenerated PHP configuration. 
    So thats it and works fine for me. All you have to do is to add that files to all you accounts to make it work.

    Also be careful of the chmod you are giving to the php.ini for example. Depending if you wish to make your customers able to change it or if you just want to be the only one to administrate it.

    Only be careful, if you recompile or update your apache, the php.conf file will be overwritten and you have to rework it.

    Hope it helps.




    php works as suPHP on my server, but I need to enable fcgi-php handler for one account. Can I use this guide? I can't find /usr/local/cpanel/cgi-sys/php5 file, please help......

  10. #10
    Registered User
    Join Date
    Jun 2010
    Posts
    3

    Default

    I hope someone is still following this thread. I've been trying to figure this out for a few days now without success.

    I am running php5 with fastcgi, following this guide and using its configuration I am running in a problem when inserting the changes in my .htaccess.

    Code:
    AddHandler php5-fastcgi .php
    Action php5-fastcgi /home/usrname/public_html/cgi-bin/php5.fcgi
    Everytime I enter the changes, the website where I am testing this returns a 500 error.

    I've been reading over the logs and googling without success of what could be the issue.

    The error_log reports these entries when I get the 500 errors are:

    Code:
    [Tue Jun 22 04:11:43 2010] [warn] [client 190.166.162.190] (104)Connection reset by peer: mod_fcgid: error reading data from FastCGI server
    [Tue Jun 22 04:11:43 2010] [warn] [client 190.166.162.190] (104)Connection reset by peer: mod_fcgid: ap_pass_brigade failed in handle_request function

    Note in the path:
    Action php5-fastcgi /home/usrname/public_html/cgi-bin/php5.fcgi

    I am using the full path to the file, if I do not use the full path, then I get this error:

    Code:
    Not Found
    
    The requested URL /cgi-bin/php5.fcgi/index.php was not found on this server.
    
    Additionally, a 404 Not Found error was encountered while trying to use an ErrorDocument to handle the request.
    I hope someone is still looking at this and is able to provide some orientation.

  11. #11
    Registered User
    Join Date
    Jul 2011
    Posts
    2

    Default Re: Fastcgi (Fcgid) and php.ini per user

    Quote Originally Posted by momon View Post
    I hope someone is still following this thread. I've been trying to figure this out for a few days now without success.

    I am running php5 with fastcgi, following this guide and using its configuration I am running in a problem when inserting the changes in my .htaccess.

    Code:
    AddHandler php5-fastcgi .php
    Action php5-fastcgi /home/usrname/public_html/cgi-bin/php5.fcgi
    Everytime I enter the changes, the website where I am testing this returns a 500 error.

    I've been reading over the logs and googling without success of what could be the issue.

    The error_log reports these entries when I get the 500 errors are:

    Code:
    [Tue Jun 22 04:11:43 2010] [warn] [client 190.166.162.190] (104)Connection reset by peer: mod_fcgid: error reading data from FastCGI server
    [Tue Jun 22 04:11:43 2010] [warn] [client 190.166.162.190] (104)Connection reset by peer: mod_fcgid: ap_pass_brigade failed in handle_request function

    Note in the path:
    Action php5-fastcgi /home/usrname/public_html/cgi-bin/php5.fcgi

    I am using the full path to the file, if I do not use the full path, then I get this error:

    Code:
    Not Found
    
    The requested URL /cgi-bin/php5.fcgi/index.php was not found on this server.
    
    Additionally, a 404 Not Found error was encountered while trying to use an ErrorDocument to handle the request.
    I hope someone is still looking at this and is able to provide some orientation.
    Exactly the same problem here. Did you figure it out at all ?

  12. #12
    Registered Member cPanel Partner NOC Badge
    Join Date
    Feb 2003
    Location
    Gothenburg, Sweden
    Posts
    329
    cPanel/WHM Access Level

    DataCenter Provider

    Post Re: Fastcgi (Fcgid) and php.ini per user

    By request I'm posting an internal bash script we have used to be able to have per virtual host php.ini.
    Be adviced, script is provided as-it-is so use at your own risk.

    https://www.oderland.se/clients/downloads/5/Scripts

    Useage:
    Put the php5.fcgi file in the cgi-bin folder of the domain / addondomain.
    If there is no cgi-bin folder, make sure you create one.
    Place the php.ini file you want to be used there as well.

    Unpack the setup_fcgid.sh file into /root or any other folder and run it.
    ./setup_fcgid.sh

    Insert customer's username.
    Select All or One virtual host.

    If All, make sure you put the php5.fcgi in all of the virtual hosts cgi-bin folders (or made symbolic links).

    If One, insert the virtual host. Be aware that for addon domains, the virtual host is the subdomain associated with it, like: subdomain.maindomain.

    You might need to restart Apache to reload the current php processes or at least kill them for the user.

    Good luck, post here if there are any questions.
    (awaiting php-fpm here..)

    twitter: oderland_david

  13. #13
    Registered User
    Join Date
    Aug 2011
    Posts
    2

    Default Re: Fastcgi (Fcgid) and php.ini per user

    Getting an error:

    Code:
    -bash-3.2$ ./setup_fcgid.sh
    Insert username : domain-user
    You chose: domain-user Is that Correct? [Y/N]:Y
    Set Wrapper for ALL of user's virtual hosts or for One [A/1] : 1
    You chose: 1
    
    Insert domain : my-domain.com
    You chose: my-domain.com Is that Correct? [Y/N]:Y
    mkdir: cannot create directory `/usr/local/apache/conf/userdata/ssl/2/domain-user': Permission denied
    ./setup_fcgid.sh: line 47: /usr/local/apache/conf/userdata/ssl/2/domain-user/my-domain.com/fcgid.conf: No such file or directory
    ./setup_fcgid.sh: line 48: /usr/local/apache/conf/userdata/ssl/2/domain-user/my-domain.com/fcgid.conf: No such file or directory
    ./setup_fcgid.sh: line 49: /usr/local/apache/conf/userdata/ssl/2/domain-user/my-domain.com/fcgid.conf: No such file or directory
    ./setup_fcgid.sh: line 50: /usr/local/apache/conf/userdata/ssl/2/domain-user/my-domain.com/fcgid.conf: No such file or directory
    mkdir: cannot create directory `/usr/local/apache/conf/userdata/std/2/domain-user': Permission denied
    ./setup_fcgid.sh: line 53: /usr/local/apache/conf/userdata/std/2/domain-user/my-domain.com/fcgid.conf: No such file or directory
    ./setup_fcgid.sh: line 54: /usr/local/apache/conf/userdata/std/2/domain-user/my-domain.com/fcgid.conf: No such file or directory
    ./setup_fcgid.sh: line 55: /usr/local/apache/conf/userdata/std/2/domain-user/my-domain.com/fcgid.conf: No such file or directory
    ./setup_fcgid.sh: line 56: /usr/local/apache/conf/userdata/std/2/domain-user/my-domain.com/fcgid.conf: No such file or directory
    touch: cannot touch `/usr/local/apache/conf/_ensure_vhost_includes_vhostless_test_file.conf': Permission denied
    touch: cannot touch `/usr/local/apache/conf/_ensure_vhost_includes_vhostless_test_file.conf': Permission denied
    [2011-08-24 08:29:15 -0700] warn [verify_vhost_includes] Failed to create /usr/local/apache/conf/_ensure_vhost_includes_vhostless_test_file.conf: No such file or directory at /usr/local/cpanel/Cpanel/FileUtils/TouchFile.pm line 65
    	Cpanel::FileUtils::TouchFile::touchfile('/usr/local/apache/conf/_ensure_vhost_includes_vhostless_test_file.conf') called at /scripts/verify_vhost_includes line 52
    warn [verify_vhost_includes] Failed to create /usr/local/apache/conf/_ensure_vhost_includes_vhostless_test_file.conf: No such file or directory
    Use of uninitialized value in string ne at /scripts/verify_vhost_includes line 56.
    Use of uninitialized value in string ne at /scripts/verify_vhost_includes line 60.
    Default symlink for test failed at /scripts/verify_vhost_includes line 61.
    [2011-08-24 08:29:16 -0700] info [ensure_vhost_includes] Unable to read /etc/userdomains, permission denied
    info [ensure_vhost_includes] Unable to read /etc/userdomains, permission denied
    [2011-08-24 08:29:16 -0700] info [ensure_vhost_includes] Unable to read /etc/userdomains, permission denied
    info [ensure_vhost_includes] Unable to read /etc/userdomains, permission denied
    Invalid user: domain-user
    No valid --user arguments given at /scripts/ensure_vhost_includes line 232.

  14. #14
    Registered Member cPanel Partner NOC Badge
    Join Date
    Feb 2003
    Location
    Gothenburg, Sweden
    Posts
    329
    cPanel/WHM Access Level

    DataCenter Provider

    Default Re: Fastcgi (Fcgid) and php.ini per user

    You seem to be using an invalid username (domain-user). Please use the linux username for that cpanel account (max 8 characters).

    Quote Originally Posted by ponch9 View Post
    Getting an error:

    Code:
    -bash-3.2$ ./setup_fcgid.sh
    Insert username : domain-user
    You chose: domain-user Is that Correct? [Y/N]:Y
    Set Wrapper for ALL of user's virtual hosts or for One [A/1] : 1
    You chose: 1
    
    Insert domain : my-domain.com
    You chose: my-domain.com Is that Correct? [Y/N]:Y
    mkdir: cannot create directory `/usr/local/apache/conf/userdata/ssl/2/domain-user': Permission denied
    ./setup_fcgid.sh: line 47: /usr/local/apache/conf/userdata/ssl/2/domain-user/my-domain.com/fcgid.conf: No such file or directory
    ./setup_fcgid.sh: line 48: /usr/local/apache/conf/userdata/ssl/2/domain-user/my-domain.com/fcgid.conf: No such file or directory
    ./setup_fcgid.sh: line 49: /usr/local/apache/conf/userdata/ssl/2/domain-user/my-domain.com/fcgid.conf: No such file or directory
    ./setup_fcgid.sh: line 50: /usr/local/apache/conf/userdata/ssl/2/domain-user/my-domain.com/fcgid.conf: No such file or directory
    mkdir: cannot create directory `/usr/local/apache/conf/userdata/std/2/domain-user': Permission denied
    ./setup_fcgid.sh: line 53: /usr/local/apache/conf/userdata/std/2/domain-user/my-domain.com/fcgid.conf: No such file or directory
    ./setup_fcgid.sh: line 54: /usr/local/apache/conf/userdata/std/2/domain-user/my-domain.com/fcgid.conf: No such file or directory
    ./setup_fcgid.sh: line 55: /usr/local/apache/conf/userdata/std/2/domain-user/my-domain.com/fcgid.conf: No such file or directory
    ./setup_fcgid.sh: line 56: /usr/local/apache/conf/userdata/std/2/domain-user/my-domain.com/fcgid.conf: No such file or directory
    touch: cannot touch `/usr/local/apache/conf/_ensure_vhost_includes_vhostless_test_file.conf': Permission denied
    touch: cannot touch `/usr/local/apache/conf/_ensure_vhost_includes_vhostless_test_file.conf': Permission denied
    [2011-08-24 08:29:15 -0700] warn [verify_vhost_includes] Failed to create /usr/local/apache/conf/_ensure_vhost_includes_vhostless_test_file.conf: No such file or directory at /usr/local/cpanel/Cpanel/FileUtils/TouchFile.pm line 65
    	Cpanel::FileUtils::TouchFile::touchfile('/usr/local/apache/conf/_ensure_vhost_includes_vhostless_test_file.conf') called at /scripts/verify_vhost_includes line 52
    warn [verify_vhost_includes] Failed to create /usr/local/apache/conf/_ensure_vhost_includes_vhostless_test_file.conf: No such file or directory
    Use of uninitialized value in string ne at /scripts/verify_vhost_includes line 56.
    Use of uninitialized value in string ne at /scripts/verify_vhost_includes line 60.
    Default symlink for test failed at /scripts/verify_vhost_includes line 61.
    [2011-08-24 08:29:16 -0700] info [ensure_vhost_includes] Unable to read /etc/userdomains, permission denied
    info [ensure_vhost_includes] Unable to read /etc/userdomains, permission denied
    [2011-08-24 08:29:16 -0700] info [ensure_vhost_includes] Unable to read /etc/userdomains, permission denied
    info [ensure_vhost_includes] Unable to read /etc/userdomains, permission denied
    Invalid user: domain-user
    No valid --user arguments given at /scripts/ensure_vhost_includes line 232.

    twitter: oderland_david

  15. #15
    Registered Member
    Join Date
    Oct 2006
    Posts
    17

    Default Re: Fastcgi (Fcgid) and php.ini per user

    Quote Originally Posted by gfxpixeldesigns View Post
    Exactly the same problem here. Did you figure it out at all ?
    Not Found

    The requested URL /cgi-bin/php5.fcgi/index.php was not found on this server.

    Additionally, a 404 Not Found error was encountered while trying to use an ErrorDocument to handle the request.
    - Make sure the host have cgi execution in the Hosting Plan in WHM.
    - Check if the virtualhost for the domain have an ScriptAlias in /usr/local/apache/conf/httpd.conf

    It should be something like:
    ScriptAlias /cgi-bin/ /home/fundacio/public_html/cgi-bin/
    --

Page 1 of 2 12 LastLast

Similar Threads

  1. Replies: 8
    Last Post: 04-30-2012, 12:30 AM
  2. Replies: 1
    Last Post: 07-11-2011, 06:54 PM
  3. php-fcgid+eaccelerator+custom php.ini+apache2-mpm-worker= segfault?
    By internetfab in forum cPanel & WHM Discussions
    Replies: 2
    Last Post: 01-30-2011, 04:25 PM
  4. fcgid (FastCGI) and APC shared cache
    By larwilliams in forum cPanel & WHM Discussions
    Replies: 0
    Last Post: 11-05-2009, 01:21 PM
  5. 'Mod FCGID' was changed to '1' by 'Fastcgi'
    By garingas in forum cPanel & WHM Discussions
    Replies: 6
    Last Post: 11-12-2007, 08:22 AM

Tags for this Thread

bargain