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

PHP Fastcgi

Discussion in 'Plesk for Linux - 8.x and Older' started by blaich, Aug 3, 2008.

  1. blaich

    blaich Guest

    0
     
    Hi guys,

    i wish for the future an installation model with a php via fastcgi support.
    I think mod_php is outdated and has a lot of disadvantages i.e. php runs as an apache worker and users can't delete sometimes their datas via ftp, because they are owned by the webserver.... or the safe_mod problem.
    Nowadays every ISP without plesk has the fastcgi support.

    Thank you

    Greets chris
     
  2. ACID25

    ACID25 Guest

    0
     
    Hi

    it´s possible to do that....so you have to create some scripts and put it in /usr/local/psa/bin
    and use the event handler in the psa panel to "create" the files on "domain created"

    here are the scripts

    for create the vhost.file
    Code:
    touch /var/www/vhosts/${1}/conf/vhost.conf
    echo "<Directory /var/www/vhosts/${1}/httpdocs/>" > /var/www/vhosts/${1}/conf/vhost.conf
    echo "AddHandler fcgid-script .php" >> /var/www/vhosts/${1}/conf/vhost.conf
    echo "Options +ExecCGI +FollowSymLinks" >> /var/www/vhosts/${1}/conf/vhost.conf
    echo "FCGIWrapper /var/www/vhosts/${1}/bin/php.fcgi .php" >> /var/www/vhosts/${1}/conf/vhost.conf
    echo "</Directory>" >> /var/www/vhosts/${1}/conf/vhost.conf
    
    use this to create for every domain her own php.ini
    Code:
    #!/bin/bash
    cp /etc/php.ini.min /var/www/vhosts/${NEW_DOMAIN_NAME}/bin/php.ini
    chown ${NEW_SYSTEM_USER}:psacln /var/www/vhosts/${NEW_DOMAIN_NAME}/bin/
    chown ${NEW_SYSTEM_USER}:psacln /var/www/vhosts/${NEW_DOMAIN_NAME}/bin/php.ini
    cd /var/www/vhosts/${NEW_DOMAIN_NAME}/bin
    
    and the script for the php.fcgi
    Code:
    #!/bin/bash
    touch /var/www/vhosts/${NEW_DOMAIN_NAME}/bin/php.fcgi
    chown ${NEW_SYSTEM_USER}:psacln /var/www/vhosts/${NEW_DOMAIN_NAME}/bin/
    chown ${NEW_SYSTEM_USER}:psacln /var/www/vhosts/${NEW_DOMAIN_NAME}/bin/php.ini
    chown ${NEW_SYSTEM_USER}:psacln /var/www/vhosts/${NEW_DOMAIN_NAME}/bin/php.fcgi
    chmod 555  /var/www/vhosts/${NEW_DOMAIN_NAME}/bin/php.fcgi 
    echo '#!/bin/sh' >/var/www/vhosts/${NEW_DOMAIN_NAME}/bin/php.fcgi
    echo '' >> /var/www/vhosts/${NEW_DOMAIN_NAME}/bin/php.fcgi
    echo 'export PHP_FCGI_CHILDREN=4' >>/var/www/vhosts/${NEW_DOMAIN_NAME}/bin/php.fcgi
    echo 'export PHP_FCGI_MAX_REQUESTS=500'>>/var/www/vhosts/${NEW_DOMAIN_NAME}/bin/php.fcgi 
    echo 'exec /usr/bin/php-cgi -c /var/www/vhosts/'${NEW_DOMAIN_NAME}'/bin/php.ini $@'>>/var/www/vhosts/${NEW_DOMAIN_NAME}/bin/php.fcgi
    chmod 555 /var/www/vhosts/${NEW_DOMAIN_NAME}/bin/php.fcgi 
    
    then you change the suexec file with
    Code:
    cp /usr/local/psa/suexec/psa-suexec /usr/sbin/suexec
    
    at least activate the "FastCGI" checkbox under setup for the domain.
    This works for me perfect

    best regards
    ACID25
     
  3. breun

    breun Golden Pleskian

    29
     
    Joined:
    Jun 28, 2005
    Messages:
    1,647
    Likes Received:
    0
    Apparently suPHP also solves this problem:



    Would be nice if Plesk would integrate this.
     
  4. ACID25

    ACID25 Guest

    0
     
    yes but how long should be wait for this ;)....same with postfix :(
     
  5. blaich

    blaich Guest

    0
     
    Hi ACID25,

    i tested what u said.
    I created the folowing files, with exactly that what u said (copy/paste):
    Code:
    #
    /usr/local/psa/bin/create_vhost.sh 
    /usr/local/psa/bin/create_phpini.sh
    /usr/local/psa/bin/create_phpfcgi.sh
    /usr/local/psa/bin/mv_suexec.sh
    #
    
    After this, I created a new job -> domain created with the following commandline
    Code:
    #!/bin/bash
    #
    /usr/local/psa/bin/create_vhost.sh >> /tmp/log
    /usr/local/psa/bin/create_phpini.sh >> /tmp/log
    /usr/local/psa/bin/create_phpfcgi.sh >> /tmp/log
    /usr/local/psa/bin/mv_suexec.sh >> /tmp/log
    
    1. It doesn't work, there is no vhost.conf in the conf dir
    2. There is no entry in the log file
    3. There is no /etc/php.ini.min !?

    Thx for helping....
     
  6. ledj

    ledj Guest

    0
     
    Possibly what you are looking for...

    http://forum.swsoft.com/showthread.php?t=53864

    I must warn, that on very heavy loaded Plesk webservers we've experienced a LOT of memory usage (though this is normal for fastcgi vs. mod_php), and it will probably make your server crash.
     
  7. Amin Taheri

    Amin Taheri Golden Pleskian Plesk Certified Professional

    33
     
    Joined:
    Jul 5, 2007
    Messages:
    1,398
    Likes Received:
    1
    Location:
    Seattle Area
    how much memory is "a lot" ? How comporable to mod_suphp in features and memory use is this?
    Also, does the php-cgi process run as the ftp user or does it run as apache?
    So if you looked at lsof or top you would see the process running and the ftp user?
     
  8. poppsworld.com

    poppsworld.com Basic Pleskian

    23
    40%
    Joined:
    Aug 10, 2008
    Messages:
    27
    Likes Received:
    0
    Location:
    Stuttgart, Germany
    Hello,

    the php-cgi process is running at the user which owns the requested file (often the ftp-user).
    I'm sorry, but i have no comparison between mod_suphp and fastcgi memory usage.

    best regards
    Lars
     
  9. Jan.S

    Jan.S Guest

    0
     
    I don´t understand this.

    what must in the event Command line from the event handler?
    all the skripts?

    I need more information.

    which files must in this folder? -> /usr/local/psa/bin

    thx for help
     
  10. Amin Taheri

    Amin Taheri Golden Pleskian Plesk Certified Professional

    33
     
    Joined:
    Jul 5, 2007
    Messages:
    1,398
    Likes Received:
    1
    Location:
    Seattle Area
    What is the average memory usage of each php-cgi process?
     
  11. sunmacet

    sunmacet Guest

    0
     
    In my setup the average is about 12MB per php-cgi process.
     
  12. Amin Taheri

    Amin Taheri Golden Pleskian Plesk Certified Professional

    33
     
    Joined:
    Jul 5, 2007
    Messages:
    1,398
    Likes Received:
    1
    Location:
    Seattle Area
    Also, how much memory does your server have with how many clients/domains?
     
  13. ledj

    ledj Guest

    0
     
    In general you need 2-4 times more RAM in your server, when you use php-cgi. So don't load up the patch on a busy server you haven't upgraded with (enough) memory. If it's a clean server with no domains you can easily implement the patch, and see how the ongoing memory consumption behaves.
    But as always there's a risk with great flexibility.
     
  14. Amin Taheri

    Amin Taheri Golden Pleskian Plesk Certified Professional

    33
     
    Joined:
    Jul 5, 2007
    Messages:
    1,398
    Likes Received:
    1
    Location:
    Seattle Area
    Looks like this is no longer relevant as plesk 9.0 will natively include three different ways to run php, as a cgi, fcgi, and apache module.
     
Loading...