# Adding Virtual Host for Zoneminder (Apache Configuration)

## rawbeefman

Great reference here:  https://forums.gentoo.org/viewtopic-t-993482-highlight-apache.html

However, since I configured Apache last, it seems to have changed.  So at some point, I would like to access this externally.  And I would like to follow the appropriate steps to configure an endpoint (I think in the past, I used a common host with many website, eg. 192.168.1.100/mysite_1).

So, looking into setting up a virtual host, here:  http://wiki.gentoo.org/wiki/Apache#Configuration

 .... But the syntax seems to differ from the sample config file that shipped with Zoneminder:  

```

ScriptAlias /cgi-bin/zms "/usr/libexec/zoneminder/cgi-bin/zms"

ScriptAlias /cgi-bin/nph-zms "/usr/libexec/zoneminder/cgi-bin/nph-zms"

<Directory "/usr/libexec/zoneminder/cgi-bin">

  AllowOverride All

  Options ExecCGI

  Order allow,deny

  Allow from all

</Directory>

Alias /zoneminder "/usr/share/zoneminder/www"

<Directory "/usr/share/zoneminder/www">

  Options -Indexes MultiViews FollowSymLinks

  AllowOverride All

  Order allow,deny

  Allow from all

</Directory>

```

I just copied that to /etc/apache2/vhosts.d and gave the apache user ownership rights.

If I attempt to browse to 192.168.1.100/Zoneminder, I get a Not Found.

Browsing to 192.168.1.100 gives me a 'It works!'

Hopefully an Apache expert can tell me what I am doing wrong.

Thanks again, everyone, for your help!

This is probably beneficial:

```

tuxServer ~ # tail /var/log/apache2/error_log

[Thu Oct 23 04:08:29 2014] [error] [client 192.168.1.12] File does not exist: /var/www/localhost/htdocs/zoneminder

[Thu Oct 23 04:09:42 2014] [notice] caught SIGTERM, shutting down

[Thu Oct 23 04:09:44 2014] [notice] Apache/2.2.27 (Unix) mod_ssl/2.2.27 OpenSSL/1.0.1j configured -- resuming normal operations

[Thu Oct 23 04:10:02 2014] [error] [client 192.168.1.12] Directory index forbidden by Options directive: /usr/share/zoneminder/www/

[Thu Oct 23 04:14:24 2014] [error] [client 192.168.1.12] Directory index forbidden by Options directive: /usr/share/zoneminder/www/

[Thu Oct 23 04:40:36 2014] [error] [client 192.168.1.12] File does not exist: /var/www/localhost/htdocs/Zoneminder

[Thu Oct 23 04:41:42 2014] [notice] caught SIGTERM, shutting down

[Thu Oct 23 04:41:45 2014] [notice] Apache/2.2.27 (Unix) mod_ssl/2.2.27 OpenSSL/1.0.1j configured -- resuming normal operations

[Thu Oct 23 04:41:52 2014] [error] [client 192.168.1.12] File does not exist: /var/www/localhost/htdocs/Zoneminder

[Thu Oct 23 04:42:21 2014] [error] [client 192.168.1.12] File does not exist: /var/www/localhost/htdocs/Zoneminder

```

----------

## katfish

It looks like the apache user cannot access /usr/libexec/zoneminder/* - make sure it can r+x in that directory.

----------

## rawbeefman

Thank you, yes; this was ultimately a permissions error.

----------

## WWWW

 *katfish wrote:*   

> It looks like the apache user cannot access /usr/libexec/zoneminder/* - make sure it can r+x in that directory.

 

How?

Do you mean doing:

```
chown -R apache:apache /usr/libexec/zoneminder/
```

I never understood why the folder /usr/libexec/zoneminder/cgi-bin[/b. My crude solution was to copy both [b]zms and nph-zms into:

```
/var/www/localhost/cgi-bin/
```

And assumed that virtual host supplied by zoneminder was broken.

Alright, to confirm that apache works, (I am not an expert in apache or web servers), the syntax in virtual host is perfectly legal?

```

ScriptAlias /cgi-bin/zms "/usr/libexec/zoneminder/cgi-bin/zms"

ScriptAlias /cgi-bin/nph-zms "/usr/libexec/zoneminder/cgi-bin/nph-zms"

<Directory "/usr/libexec/zoneminder/cgi-bin"> 
```

Because now I have a mixed of things that are confusing in order to understand how falls into place. As aboved mentioned my virtual host points to a different place but apache is still able to use /var/www/localhost/cgi-bin/. How is this possible?

Moreover, both directories seem to have identical permissions.

danke schon!

PS: if so much work and fixing needs to be done after install, isn't this the job of the ebuild?

----------

## WWWW

Anyone?

----------

## WWWW

I would love if somebody could give a hint. I am not an apache expert.

----------

