403 Forbidden error with fcgid and PHP

5,629

The 403 error message is misleading, but correct. Looking at /etc/apache2/conf-enabled/serve-cgi-bin.conf I have:

<IfModule mod_alias.c>
    <IfModule mod_cgi.c>
        Define ENABLE_USR_LIB_CGI_BIN
    </IfModule>

    <IfModule mod_cgid.c>
        Define ENABLE_USR_LIB_CGI_BIN
    </IfModule>

    <IfDefine ENABLE_USR_LIB_CGI_BIN>
        ScriptAlias /cgi-bin/ /usr/lib/cgi-bin/
        <Directory "/usr/lib/cgi-bin">
            AllowOverride None
            Options +ExecCGI -MultiViews +SymLinksIfOwnerMatch
            Require all granted
        </Directory>
    </IfDefine>
</IfModule>

Following the code flow, the "Require all granted" on /usr/lib/cgi-bin gets executed only if mod_cgi and/or mod_cgid are enabled. In my case they were both disabled (because they are disabled by default in Debian).

# a2enmod cgi ; a2enmod cgid ; service apache2 restart

solved the problem.

Share:
5,629

Related videos on Youtube

Lucio Crusca
Author by

Lucio Crusca

Updated on September 18, 2022

Comments

  • Lucio Crusca
    Lucio Crusca over 1 year

    I'm trying to configure php and mod_spdy on Apache 2.4, Debian jessie, x64. I've followed this guide and configured Apache following this other guide and installed these packages:

    libapache2-mod-fcgid
    php-cgi
    php5-fpm
    

    I now have problems with php applications: when I try to open them I get a 403 Forbidden. Here is my /etc/apache2/conf-enabled/fcgid.conf

    <Location />
      AddHandler fcgid-script .php
      Options +ExecCGI
      FcgidWrapper /usr/bin/php-cgi .php
    </Location>
    

    And the error I get in /var/log/apache2/error.log

    AH01630: client denied by server configuration: /usr/lib/cgi-bin/php5
    

    I've tried adding

    Order allow,deny
    Allow from all
    

    to the in the PHP application VirtualHost, but the result is just the same. Why am I getting the 403?