# Problems getting apache running

## mreff555

I installed apache the other day, without a problem, however CGI wasn't enabled.

I tried a couple different things but one of the posts on gentoo.org stated that a line needed to be added to my make.conf followed by re-emerging

```

APACHE2_MODULES="cgi"

```

Now it won't start. I get this error.

```

dan@mojo ~ $ sudo /etc/init.d/apache2 start

Password: 

apache2          | * apache2 has detected an error in your setup:

apache2          |apache2: Syntax error on line 61 of /etc/apache2/httpd.conf: Cannot load /usr/lib64/apache2/modules/mod_actions.so into server: /usr/lib64/apache2/modules/mod_actions.so: cannot open shared object file: No such file or directory

apache2          | * ERROR: apache2 failed to start

```

it doesn't appear that the apache package installed this shared library. Do I need some other flag?

```

dan@mojo ~ $ equery f apache| grep .so

/usr/lib64/apache2/build/instdso.sh

/usr/lib64/apache2/modules/mod_authnz_ldap.so

/usr/lib64/apache2/modules/mod_cgi.so

/usr/lib64/apache2/modules/mod_ldap.so

/usr/lib64/apache2/modules/mod_ssl.so

/usr/share/apache2/icons/small/sound.gif

/usr/share/apache2/icons/small/sound.png

/usr/share/apache2/icons/small/sound2.gif

/usr/share/apache2/icons/small/sound2.png

/usr/share/apache2/icons/sound1.gif

/usr/share/apache2/icons/sound1.png

/usr/share/apache2/icons/sound2.gif

/usr/share/apache2/icons/sound2.png

```

----------

## Hu

Based solely on the name, you need APACHE2_MODULES=actions.  For me, this and many other modules, including cgi, defaulted to on.  Please remove your APACHE2_MODULES definition and then post the output of emerge --pretend --verbose www-servers/apache.  Also, please cite exactly what page told you to set APACHE2_MODULES.

----------

## mreff555

http://bpaste.net/show/482160/

This is where I saw the suggestion to add the entry to make.conf

https://forums.gentoo.org/viewtopic-t-852840-start-0.html

----------

## Hu

According to that output, following the advice from huuan was a mistake.  That output says you already had the cgi module enabled even without setting APACHE2_MODULES.  Also, I think you misunderstood the advice from huuan.  That post, which was a serious case of thread necromancy, was stating that if you had the cgi module enabled via APACHE2_MODULES, then only the configuration file change was required.  According to your output, you had the cgi module enabled via APACHE2_MODULES even before your change.  Rebuild Apache with APACHE2_MODULES not assigned via make.conf.

----------

## mreff555

I will try but I did that once before. The web server worked, but I wasn't able to get cgi working.

----------

## mreff555

So I'm back to where I started. Apache seems to work fine but no matter what I do I can't seem to enable CGI.

currently I'm looking at this tutorial

http://www.techrepublic.com/blog/diy-it-guy/diy-enable-cgi-on-your-apache-server/

I'm getting forbidden errors, but I don't think it should be an access issue. the test binary along with everything upstream has 755 permissions

----------

## Hu

What does the Apache error log report?

----------

## mreff555

access_log:

```

::1 - - [22/Jul/2014:19:27:03 -0400] "GET /cgi-bin/test.pl HTTP/1.1" 403 276

```

error_log:

```

[Tue Jul 22 19:27:03 2014] [error] [client ::1] client denied by server configuration: /var/www/localhost/cgi-bin

```

/etc/conf.d/apache2: (the uncommented parts)

```

APACHE2_OPTS="-D DEFAULT_VHOST -D INFO -D SSL -D SSL_DEFAULT_VHOST -D LANGUAGE"

```

/etc/apache2/httpd.conf:

http://bpaste.net/show/489432/

----------

## freke

 *mreff555 wrote:*   

> access_log:
> 
> error_log:
> 
> ```
> ...

 

In your httpd.conf it seems like you expect to have the scripts in /usr/lib/cgi-bin

Does it work if you change to:

```
ScriptAlias /cgi-bin/ /var/www/localhost/cgi-bin/     !!<- this might already be defined elsewhere?!!

<Directory "/var/www/localhost/cgi-bin">

AllowOverride None

Options +ExecCGI -MultiViews +SymLinksIfOwnerMatch

Order allow,deny

Allow from all

</Directory>

```

You might have a conf-file in /etc/apache2/modules.d/ which is messing with mod_cgi-settings, too?

----------

## mreff555

This is my virtual host entry. Intention is to have the index.html file at the default location "/var/www/localhost/htdocs/index.html

and have associated cgi scripts in /usr/lib/cgi-bin. From what I am told this is the best place to put these folders. Regardless, I think it's set up to

accomodate this. right?

```

<VirtualHost _default_:80>

    DocumentRoot /var/www/localhost

ScriptAlias /cgi-bin/ /usr/lib/cgi-bin/

<Directory "/usr/lib/cgi-bin">

AllowOverride None

Options +ExecCGI -MultiViews +SymLinksIfOwnerMatch

Order allow,deny

Allow from all

</Directory>

</VirtualHost>
```

----------

## freke

 *mreff555 wrote:*   

> This is my virtual host entry. Intention is to have the index.html file at the default location "/var/www/localhost/htdocs/index.html
> 
> and have associated cgi scripts in /usr/lib/cgi-bin. From what I am told this is the best place to put these folders. Regardless, I think it's set up to
> 
> accomodate this. right?
> ...

 

I'm not sure you're using that virtual host - I'd remove that from httpd.conf and edit the files found in /etc/apache2/vhosts.d.

ie.

/etc/apache2/vhosts.d/default_vhost.include and/or /etc/apache2/vhosts.d/00_default_vhost.conf

the conf-file is included from httpd.conf

```
Include /etc/apache2/vhosts.d/*.conf
```

and the conf-file includes the default_vhost.include-file

```
 Include /etc/apache2/vhosts.d/default_vhost.include
```

In the standard-configuration...

Also the default vhost seems to be *:80 - dunno if _default_:80 works, too?

----------

