Answer the question
In order to leave comments, you need to log in
How to setup synced folder Vagrant on macOS?
I connect a folder (which is registered as a folder for a virtual host) to the guest machine through vagrant, but when I try to open a site from this folder, it says that I do not have access.
For example, the virtual host in the guest machine is /var/www/domains/ovz1.host and without a folder from the outside (without synchronization with the folder where the files of the site being developed are located in my host machine on OS X), everything starts fine. But when this folder is replaced by a vagrant, when the site is accessed, it says that there is no access to the site files - it writes 403 Forbidden
You don't have permission to access / on this server.
Even if you register the owner and group apache on the guest machine and give all rights 777 (not full rights on the screen, but I tried to give full ones - it didn’t help) on the host machine.
Googled, read the official documentation - it seems to be enough to indicate the owner and group in the config.
Maybe somehow the built-in firewall of macOS is interfering? How to set up - I don’t even know how to ask in Google ((((
Host machine - macOS Mojave 10.14.1 (18B75)
Guest machine - https://app.vagrantup.com/generic/boxes/centos7
Answer the question
In order to leave comments, you need to log in
This is how it works for me
Here is the complete Vagrant file that I useconfig.vm.synced_folder "www", "/var/www
Vagrant.configure("2") do |config|
config.vm.define "web" do |web|
#Ubuntu 12.04 LTS 64bit
web.vm.box = "hashicorp/precise64"
#ssh port 4022 => 22
web.vm.network :forwarded_port, id: "ssh", guest: 22, host: 4022
#apache2
web.vm.synced_folder "www", "/var/www"
web.vm.provision "shell", inline: <<-SHELL
export DEBIAN_FRONTEND=noninteractive
mkdir -p /etc/apache2/conf.d/
echo "ServerName localhost" > /etc/apache2/conf.d/servername.conf
apt-get update
apt-get install -y apache2
a2ensite default-ssl
a2enmod ssl
make-ssl-cert generate-default-snakeoil --force-overwrite
service apache2 restart
SHELL
web.vm.network :forwarded_port, guest: 80, host: 4080
web.vm.network :forwarded_port, guest: 443, host: 4443
end
end
Anton Kokarev greetings from Adler))) Thank you for your reply! This option without prescribing the owner and group does not work for me either. Forwarded ports - did not help. I don't see any major differences.
1. What system do you use your vagrant setup for? Mac or Linux?
2. Where did you learn how to set up a vagrant so well?
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question