Search code examples
apachepermissionsfastcgi

FastCGI using apache - not a script or wrong permission?


I compiled my fcgi for apache like this:

g++ fcgistart.c -lfcgi

I got a a.out and configure it for apache using

a2enmod fastcgi

Now i read the manual

Any program assigned to the handler fcgid-script is processed using the FastCGI protocol;

Does that mean the binary is a script? Wreid! Anyway I place the a.out to /var/www/html.

Because the handler (/etc/apache2/mods-enabled/fastcgi.conf) binds to .fcgi I copy a.out to a.fcgi. Now i browse to http://localhost/a.fcgi and a 403-forbidden occourse.

xx@xx:/var/www/html$ ls -la
drwxr-xr-x 2 root root  4096 Feb  6 13:44 .
drwxr-xr-x 3 root root  4096 Feb  6 12:56 ..
-rwxr-xr-x 1 root root  8696 Feb  6 13:44 a.fcgi
-rwxr-xr-x 1 root root  8696 Feb  6 13:16 a.out
-rw-r--r-- 1 root root 11321 Feb  6 12:57 index.html

What is wrong?


Solution

  • I got it:

    <VirtualHost *:80>
            ServerAdmin webmaster@localhost
            DocumentRoot /var/www/html
            ErrorLog ${APACHE_LOG_DIR}/error.log
            CustomLog ${APACHE_LOG_DIR}/access.log combined
    </VirtualHost>
    

    is wrong, I had to add the ExecCGI option:

    <VirtualHost *:80>
            ServerAdmin webmaster@localhost
            DocumentRoot /var/www/html
            ErrorLog ${APACHE_LOG_DIR}/error.log
            CustomLog ${APACHE_LOG_DIR}/access.log combined
            <Directory /var/www/html>
                    Options +ExecCGI
            </Directory>
    </VirtualHost>