跳至主要内容

install god dame fastgci and fpm on our server.

first of all, need to create a child process of CGI which located in /etc/init.d/php-common-Perso.sh

prefix="/opt/php-5.3.6-full";
exec_prefix=${prefix};

php_fpm_BIN="${exec_prefix}/sbin/php-fpm";
php_fpm_CONF="/home/siteadm/common/php/Perso.conf";
php_fpm_PID="/home/siteadm/common/php/Perso.pid";
php_fpm_INI="/home/siteadm/common/php/Perso.ini";
PHP_INI_SCAN_DIR="/home/siteadm/common/php/vhost";

php_opts="--fpm-config $php_fpm_CONF -c $php_fpm_INI"

export PHP_INI_SCAN_DIR;

. /home/siteadm_admin/template/php/php-fpm-init.sh

the PHP_INI_SCAN_DIR include all specification of fpm for each virtual host of apache:
[HOST=main.addepi.fr]
open_basedir = "/data/admin/"
doc_root = "/data/admin/web"
mail.log = "/data/admin/app/logs/php.mail.error.log"
short_open_tag = 1
error_log = "/data/admin/app/logs/php.error.log"
default_charset = "utf-8"

and some other package loader like imagick.ini
; configuration for php imagick module
extension=imagick.so

In fact, Perso.conf is still another php.ini for php-fpm, it contains only three lines:
pid = /home/siteadm/common/php/Perso.pid
error_log = /home/siteadm/common/log/php-Perso_error.log
include=/home/siteadm/common/php/Perso/*.conf
which is all the child fastcgi defination, here i add a /home/siteadm/common/php/Perso/main-php-default.conf file with:
[main-default]

catch_workers_output            = yes

listen                                          = /home/siteadm/common/php/Perso/main-php-default.sock
listen.owner                            = root
listen.group                            = hosts
listen.mode                                     = 0660

user                                            = www-data ; normalement nobody
group                                           = hosts

;chroot                                         = /data/admin

pm                                                      = dynamic

pm.max_children                         = 10
pm.start_servers                        = 1
pm.min_spare_servers            = 1
pm.max_spare_servers            = 2
pm.max_requests                         = 500

pm.status_path                          = /fpm-status
ping.path                                       = /fpm-ping
ping.response                           = pong

;slowlog                                                = {LOG_ROOT}/php-main_slow.log
;request_slowlog_timeout                = 5s

; Variables d'environnement
env[TMP]                                        = /data/temp
env[TMPDIR]                                     = /data/temp
env[TEMP]                                       = /data/temp

; Directives de configuration bloquées
;php_admin_flag[param1] = on
php_admin_value[open_basedir] = "/data/admin"
php_admin_value[error_log] = "/data/admin/app/logs/php.error.log"
php_admin_value[mail.log] = "/data/admin/app/logs/php.mail.error.log"
php_admin_value[upload_tmp_dir] = "/data/temp"
php_admin_value[session.save_path] = "/data/temp"
php_admin_value[apc.stat] = "0"
php_admin_value[apc.lazy_functions] = "0"
php_admin_value[apc.lazy_classes] = "0"


in this file, we define all the parameter of this child fastcgi process parameter. include his sock file, user, group temp folder etc. After we done this, need to launch the php-common-Perso.sh, which is also launching /home/siteadm_admin/template/php/php-fpm-init.sh contained by this .sh
wait_for_pid () {
        try=0

        while test $try -lt 35 ; do

                case "$1" in
                        'created')
                        if [ -f "$2" ] ; then
                                try=''
                                break
                        fi
                        ;;

                        'removed')
                        if [ ! -f "$2" ] ; then
                                try=''
                                break
                        fi
                        ;;
                esac

                echo -n .
                try=`expr $try + 1`
                sleep 1

        done

}

case "$1" in
        start)
                echo -n "Starting php-fpm "

                $php_fpm_BIN $php_opts

                if [ "$?" != 0 ] ; then
                        echo " failed"
                        exit 1
                fi

                wait_for_pid created $php_fpm_PID

                if [ -n "$try" ] ; then
                        echo " failed"
                        exit 1
                else
                        echo " done"
                fi
        ;;

        stop)
                echo -n "Gracefully shutting down php-fpm "

                if [ ! -r $php_fpm_PID ] ; then
                        echo "warning, no pid file found - php-fpm is not running ?"
                        exit 1
                fi

                kill -QUIT `cat $php_fpm_PID`

                wait_for_pid removed $php_fpm_PID

                if [ -n "$try" ] ; then
                        echo " failed. Use force-exit"
                        exit 1
                else
                        echo " done"
                fi
        ;;

        force-quit)
                echo -n "Terminating php-fpm "

                if [ ! -r $php_fpm_PID ] ; then
                        echo "warning, no pid file found - php-fpm is not running ?"
                        exit 1
                fi

                kill -TERM `cat $php_fpm_PID`

                wait_for_pid removed $php_fpm_PID
                if [ -n "$try" ] ; then
                        echo " failed"
                        exit 1
                else
                        echo " done"
                fi
        ;;

        restart)
                $0 stop
                $0 start
        ;;

        reload)

                echo -n "Reload service php-fpm "

                if [ ! -r $php_fpm_PID ] ; then
                        echo "warning, no pid file found - php-fpm is not running ?"
                        exit 1
                fi

                kill -USR2 `cat $php_fpm_PID`

                echo " done"
        ;;

        *)
                echo "Usage: $0 {start|stop|force-quit|restart|reload}"
                exit 1
        ;;

esac

So , we can start our fpm main and child process. and if we type: ps aux | grep main, we should see :
www-data 24417  0.0  0.9 346424 76508 ?        S    Dec03   0:03 php-fpm: pool main-default 
Well, from now we can use this as an external fastcgi socket. so i create an vhost like this: /etc/apache2/sites-available/main
FastCGIExternalServer /data/admin/cgi-bin/php-default -socket /home/siteadm/common/php/Perso/main-php-default.sock -pass-header Authorization

        DocumentRoot "/data/admin/web"
        ServerName main.addepi.fr
        ServerAlias main.addepi.fr
        ServerAdmin webmaster@addepi.fr
        CustomLog /data/admin/app/logs/apache.access.log combined
        ErrorLog /data/admin/app/logs/apache.error.log
        ScriptAlias /cgi-bin/ /data/admin/cgi-bin/
        Action php-fpm /cgi-bin/php-default

       order allow,deny
       allow from all
       DirectoryIndex app.php
       AddHandler php-fpm .php
       Options -Indexes


        Order allow,deny
        Allow from env=REDIRECT_STATUS




well, you really do not need a file name: /data/admin/cgi-bin/php-default this is an alias of the socket name.
relaunch the apache2, we can visit main.addepi.fr now.

评论

此博客中的热门博文

My childhood

"Each person's life is like a book; some people prefer to savor it slowly, while others like to gradually forget it. Looking back, I want to see if I can discern the trajectory of the world from my seemingly insignificant life. I am a child from the countryside, and perhaps most people cannot understand what my so-called countryside looks like. Indeed, the impressions of the countryside can be very different depending on the country, and moreover, more than 40 years have passed, during these 40 years of rapid development in China. A phrase suddenly comes to mind, 'I see him building tall buildings, I see him feasting, I see everything collapsing.' The place where I was born is a small town in the southwest of China, a town so small that it only has one street, and the widest part is only 3 meters. Paved with stone slabs, worn by many years of use, the slabs are not flat but rather filled with small bumps and hollows, yet strangely smooth. At the end of the street is a ...

对于GFW的看法

谈到这个问题的人很多,讲的也非常详细,但我窃以为大多数人对此都不够重视。在这一点上来讲,国民党堪称楷模,我想台湾能有今日,很大程度上是因为他们最终也没有建立一个可以堪比中国的新闻审查制度。从权利集中的角度来讲,中国共产党并不比任何一个封建王朝差,从执行力度上来讲,那也和历史上最严酷的王朝可以评分秋色。至少,国民党还是讲点道德,尊重文化的。 如果说计划生育阉割了中国人的人口,那么GFW,和新闻出版署以及文化部阉割了中国人的精神。也许乐观的人说我们总可以翻墙,我们总可以通过这样那样的方法来获得信息。但是悲观的我并不这么认为,这种限制创造的是一种环境,是空气,你固然可以戴着口罩,但是你永远无法自由的呼吸,当大家都在这样的空气中活着的时候,戴着口罩的你是会被人另眼相看的。其实群体意识在掌握了所有媒体的政府面前就是一个面团,想怎么捏就怎么捏,本来就是信息不对称的更何况还是受到随意控制的。这是无解的,中国亟待提高公民意识,哲学思想,文化水平,等等,政府做的不过是又一轮的愚民罢了。鲁迅先生为之殚精极虑,奋斗一生的东西,过了一个世纪依然没有什么本质的改变,阿Q在国人里占的比例是在太大了。就好比是我以诚待国人,以心侍之,以身献之,奈何国人谓之以“傻逼”。你却又待何如?这样的文化封锁,信息封锁导致的唯一结果就是,你振臂一呼之时,便是阿Q们结队去看你被看头之日。 其实,中国政府早已脱离了共产主义这个哲学思想了。换句话说,这个哲学思想本身是没什么对错的,只是一旦应用起来就满不是那么回事了,几乎可以说,共产主义的集权必然导致共产主义的被抛弃。

chrome extension Error: attempting to use a disconnected prot object

if you get this error: Port error: Could not establish connection. Receiving end does not exist. miscellaneous_bindings:236 chromeHidden.Port.dispatchOnDisconnect miscellaneous_bindings:236 Uncaught Error: Attempting to use a disconnected port object miscellaneous_bindings:58 PortImpl.postMessage miscellaneous_bindings:58 responseCallback miscellaneous_bindings:143 xhr.onreadystatechange That means you have make some mistake as this discussed: This is caused when a connection get closed. For example if you open a tab that has the content_script injected, it opens a connection, the tab is closed, and then the background_page tries to pass a message. It will fail because the tab is no longer active to receive the message. In your case I would guess that as tabs close and new tabs open you are attempting to post messages with the old tabId instead of creating a new connection to the new tab. I would recommend reading through the  long-lived connectio...