dongyong3223 2012-09-07 17:44
浏览 59
已采纳

apache + fastcgi + fpm为什么需要suexec?

So I have the following WORKING virtualhost:

<VirtualHost 192.168.128.20:80> 
        ServerName euclid.domain.tld 

        #LogLevel debug 
        ErrorLog /var/www/euclid/logs/error_log 

        SuexecUserGroup fastcgi www_euclid 
        FastCgiExternalServer /var/www/euclid/htdocs/cgi-bin -socket /var/run/php-fpm/euclid.sock -user fastcgi -group www_euclid 
        AddHandler php-fastcgi .php 
        Action php-fastcgi /cgi-bin 
        Alias /cgi-bin /var/www/euclid/htdocs/cgi-bin 

        <Location /cgi-bin> 
                Order Deny,Allow 
                Deny from All 
                # Prevent accessing this path directly 
                Allow from env=REDIRECT_STATUS 

                Options +ExecCGI +FollowSymLInks +SymLinksIfOwnerMatch 
        </Location> 

        DocumentRoot /var/www/euclid/htdocs 
        <Directory /var/www/euclid/htdocs> 
                AllowOverride all 
                Order allow,deny 
                Allow from all 
        </Directory> 
</VirtualHost>

What I cant seem to figure out is why I need to have either/both SuexecUserGroup fastcgi www_euclid and FastCgiExternalServer with the -user fastcgi -group www_euclid flags. FPM has pooling enabled and each pool is running under its own user/group. This works correctly, no issue. If i remove SuexecUserGroup and/or the -user fastcgi -group www_euclid arguments, I get the following error and I have no idea why. Additionally what uid and gid is used to access the socket file by fastcgi? Its certainly not fastcgi:ww_euclid.

(13)Permission denied: FastCGI: failed to connect to server
"/var/www/euclid/htdocs/cgi-bin": connect() failed  FastCGI:
incomplete headers (0 bytes) received from server
"/var/www/euclid/htdocs/cgi-bin"
  • 写回答

2条回答 默认 最新

  • dongyi6845 2012-09-07 22:31
    关注

    Ok I believe I have figured out what the problem was. The simple answer is; mod_fastcgi sucks. Its old, unmaintained and poorly documented. Why it keeps coming up when looking up how to run php-fpm is beyond me. Save your self the headache and just don't use it!

    The real solution is rather simple:

    <VirtualHost 192.168.128.20:80> 
            ServerName euclid.domain.tld 
    
            #LogLevel debug 
            ErrorLog /var/www/euclid/logs/error_log 
    
            <IfDefine PROXY>
                    #If you want to use mod_proxy (Probably the best option)
                    ProxyPassMatch ^/(.*\.php(/.*)?)$ fcgi://localhost:9000/var/www/euclid/htdocs/$1
            </IfDefine>
    
            <IfDefine FASTCGI_HANDLER>
                    #If you want to use mod_fastcgi_handler (3rd party)
                    AddHandler fcgi:/var/run/php-fpm-euclid.sock .php
            </IfDefine>
    
    
            DocumentRoot /var/www/euclid/htdocs 
            <Directory /var/www/euclid/htdocs> 
                    AllowOverride all 
                    Order allow,deny 
                    Allow from all 
            </Directory> 
    </VirtualHost>
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?

悬赏问题

  • ¥15 装 pytorch 的时候出了好多问题,遇到这种情况怎么处理?
  • ¥20 IOS游览器某宝手机网页版自动立即购买JavaScript脚本
  • ¥15 手机接入宽带网线,如何释放宽带全部速度
  • ¥30 关于#r语言#的问题:如何对R语言中mfgarch包中构建的garch-midas模型进行样本内长期波动率预测和样本外长期波动率预测
  • ¥15 ETLCloud 处理json多层级问题
  • ¥15 matlab中使用gurobi时报错
  • ¥15 这个主板怎么能扩出一两个sata口
  • ¥15 不是,这到底错哪儿了😭
  • ¥15 2020长安杯与连接网探
  • ¥15 关于#matlab#的问题:在模糊控制器中选出线路信息,在simulink中根据线路信息生成速度时间目标曲线(初速度为20m/s,15秒后减为0的速度时间图像)我想问线路信息是什么