问题描述
我是无所事事的新手,并且遇到了无法正常工作的问题.端口转发运行良好,我可以访问它.但是,我无法使凉亭和口水正常工作.
I am new to vagrant and having issues getting working correctly. It is running fine with port forwarding and I can access it. However I am having trouble getting bower and gulp to work correctly.
该问题似乎源于www-data/www-data拥有的/var/www目录.即使将无业游民添加到www-data组后,该无业游民用户也不具有对任何目录的写权限.我什至无法使用sudo chmod
向任何文件添加写权限.
The issue seems to stem from the /var/www directory being owned by www-data/www-data. The vagrant user doesn't have write permissions to any of the directories even after adding vagrant to the www-data group. I am no even able to use sudo chmod
to add the write permission to any file.
每当我尝试运行bower,gulp甚至git时,都不会收到拒绝访问拒绝的错误.
I get no access permission denied errors any time I try to run bower, gulp or even git.
任何帮助将不胜感激.
流浪文件:
# -*- mode: ruby -*-
# vi: set ft=ruby :
VAGRANTFILE_API_VERSION = "2"
Vagrant.configure(VAGRANTFILE_API_VERSION) do |config|
config.vm.box = "hashicorp/precise32"
config.vm.network :forwarded_port, guest: 80, host: 8080, auto_correct: true
config.ssh.private_key_path = ['~/.vagrant.d/insecure_private_key', '~/.ssh/id_rsa.pub']
config.ssh.forward_agent = true
config.vm.synced_folder "/home/develop/b3c-dev", "/var/www", create: true, group: "vagrant", owner: "www-data"
config.vm.synced_folder "/home/vagrant/b3c_ee/provision", "/var/provision", create: true, group: "root", owner: "root"
config.vm.provider "virtualbox" do |v|
v.name = "B3C Expression Engine Dev Vagrant"
v.customize ["modifyvm", :id, "--memory", "1024"]
end
config.vm.provision "shell", path: "provision/setup.sh"
end
Nginx配置:
server {
listen 80;
server_name test.dev www.test.dev;
root /var/www/public/;
index index.php index.html;
access_log /var/log/nginx/b3c-dev-access.log;
error_log /var/log/nginx/b3c-dev-error.log info;
# Important for VirtualBox
# sendfile off;
location / {
index index.php;
try_files $uri $uri/ @ee;
}
location @ee {
rewrite ^(.*) /index.php?$1 last;
}
location ~* \.php {
include fastcgi_params;
fastcgi_pass unix:/var/run/php5-fpm.sock;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
fastcgi_cache off;
fastcgi_index index.php;
}
}
推荐答案
我将使用 vagrant作为所有者和组加载共享文件夹,然后将用户和组更改为/etc/php5/fpm/pool.d/www.conf
中的流浪汉.
I would load the shared folder with vagrant as the owner and the group and then change the user and the group to vagrant in /etc/php5/fpm/pool.d/www.conf
.
要在php-fpm的配置中更改用户和组,只需将它们添加到provision/setup.sh
末尾的行中即可:
To change the user and group in the php-fpm's config, just add these to lines to the end of provision/setup.sh
:
sed -i 's/user = www-data/user = vagrant/g' /etc/php5/fpm/pool.d/www.conf
sed -i 's/group = www-data/group = vagrant/g' /etc/php5/fpm/pool.d/www.conf
如果这没有帮助,请尝试递归增加/var/www
的权限.
If this does not help, try to increase the permission of /var/www
recursively.
这篇关于使用Nginx的Vagrant文件夹权限的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!