Reputation: 29
Im new to Vagrant and Chef technologies and im having some issues.
I manage to insert into my newly created Vagrant machine this virtualhost template:
File: chef repo/cookbooks/apache2/templates/default/default.conf.erb
<VirtualHost *:<%= node['apache']['listen_ports'] %> >
DocumentRoot <%= node['apache']['docroot_dir'] %>
<Directory <%= node['apache']['docroot_dir'] %> >
Options FollowSymLinks
AllowOverride All
Order allow,deny
Allow from all
</Directory>
</VirtualHost>
where the port is 80 and my docroot_dir is /vagrant/web1_docroot. This /vagrant dir is the shared folder between my host machine and my vagrant machine.
The actual virtualhost in the Vagrant machine ends up like this:
<VirtualHost *:80 >
DocumentRoot /vagrant/web1_docroot/
<Directory /vagrant/web1_docroot/ >
Options FollowSymLinks
AllowOverride All
Order allow,deny
Allow from all
</Directory>
</VirtualHost>
I am encountering 2 issues:
1) Even tho the default.conf file is rightly included in my Vagrant machine, its not activated by apache, so i have to manually use "a2ensite default.conf" in order to activate it.
2) The second one is that after activation, when i go to my localhost i encounter en error, it says "you don't have permission to access / on this server. solucion apache"
<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML 2.0//EN">
<html><head>
<title>403 Forbidden</title>
</head><body>
<h1>Forbidden</h1>
<p>You don't have permission to access /
on this server.<br />
</p>
<hr>
<address>Apache/2.4.10 (Debian) Server at localhost Port 80</address>
</body></html>
The problem is on the DocumentRoot line, the moment I change the path to the regular one (var/www/html) it works again. So maybe thats the issue? why it cannot access the dir?
Has anyone had this issue or know how to solve it? thank you very much
Upvotes: 0
Views: 76
Reputation: 54221
We generally don't bother with the sites-available
folder anymore in modern config management layouts. That whole system was built for humans hand-editing files on artisinal systems. These days if you want to "disable" a vhost, you just delete the config file since it is stored in both your config management system and version control anyway. So change your template
resource to render the file directly into the conf.d
or sites-enabled
folder.
Upvotes: 0