# [SOLVED] Problem with virtual hosts in Apache

## spylinux

Hi everyione,

I made a clean install of Apache and PHP, and works fine.

In /etc/portage/make.conf i have set:

APACHE2_MPMS="prefork"

And in etc/portage/packages.use i set:

www-servers/apache mpm-prefork

app-admin/apache-tools

But i want to use virtualhosts, to access my sites like http://mysite.com not http://localhost/mysite

I have create a file in: /etc/apache2/vhosts.d/cakephp.io.conf with this content:

```
<VirtualHost *:80>

   ServerAdmin spylinux@openmailbox.org

   DocumentRoot /var/www/localhost/htdocs/cakephp

   ServerName cakephp.io

   ServerAlias www.cakephp.io

   LogLevel warn

   ErrorLog /var/www/localhost/htdocs/cakephp/logs/error.log

   CustomLog /var/www/localhost/htdocs/cakephp/logs/access.log combined

   <Directory /var/www/localhost/htdocs/cakephp.io>

      Options Indexes FollowSymLinks

      AllowOverride All

      Require all granted

      DirectoryIndex index.html index.php

   </Directory>

</VirtualHost>
```

And add this line in /etc/hosts

```
127.0.0.1       cakephp.io      www.cakephp.io
```

After restart Apache, when i try to access http://cakephp.io, i have 403 Error - Forbidden. And the Apache log have this:

```
[Tue Mar 15 12:41:04.011560 2016] [mpm_prefork:notice] [pid 4061] AH00163: Apache/2.4.18 (Unix) OpenSSL/1.0.2g PHP/5.6.18-pl0-gentoo configured -- resuming normal operations

[Tue Mar 15 12:41:04.011620 2016] [core:notice] [pid 4061] AH00094: Command line: '/usr/sbin/apache2 -D DEFAULT_VHOST -D INFO -D SSL -D SSL_DEFAULT_VHOST -D LANGUAGE -D PHP5 -d /usr/lib64/apache2 -f /etc/apache2/httpd.conf'
```

Anyone can tell me what i'm doing wrong, or how can i solve this problem about create Virtual Hosts on Gentoo?

Thanks for any help!

spylinux

----------

## kazdva

```
<Directory /var/www/localhost/htdocs/cakephp.io>
```

I think you had in mind  /var/www/localhost/htdocs/cakephp

----------

## spylinux

 *AdamScheller wrote:*   

> 
> 
> ```
> <Directory /var/www/localhost/htdocs/cakephp.io>
> ```
> ...

 

Thank you so much @AdamScheller,

I not see before my mistake in Path of directory. Now, works fine!

Again, thanks!   :Very Happy: 

Best regards

spylinux

----------

