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 关于#matlab#的问题:期望的系统闭环传递函数为G(s)=wn^2/s^2+2¢wn+wn^2阻尼系数¢=0.707,使系统具有较小的超调量
  • ¥15 FLUENT如何实现在堆积颗粒的上表面加载高斯热源
  • ¥30 截图中的mathematics程序转换成matlab
  • ¥15 动力学代码报错,维度不匹配
  • ¥15 Power query添加列问题
  • ¥50 Kubernetes&Fission&Eleasticsearch
  • ¥15 報錯:Person is not mapped,如何解決?
  • ¥15 c++头文件不能识别CDialog
  • ¥15 Excel发现不可读取的内容
  • ¥15 关于#stm32#的问题:CANOpen的PDO同步传输问题