I'm trying to determine if there's a bug in Vagrant or in nginx.
I have the following Vagrantfile
:
Vagrant.configure("2") do |config|
config.vm.box = "hashicorp/precise32"
config.vm.network "private_network", ip: "10.0.1.7"
config.vm.network :forwarded_port, guest: 8080, host: 9005
end
So I run vagrant up && vagrant ssh
and the server provisions and spins up. I want to manually install nginx on my new VM, so (per the instructions for installing nginx on Ubuntu 14.04) I then run:
sudo apt-get update
sudo apt-get install nginx
nginx installs. I run mkdir ~/mysite
and then I change its /etc/nginx/nginx.conf
file to:
worker_processes 1;
events {
worker_connections 1024;
}
http {
include mime.types;
default_type application/octet-stream;
sendfile on;
keepalive_timeout 65;
server {
listen 8080;
server_name localhost;
location / {
root /home/vagrant/mysite;
index index.html index.htm;
}
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root html;
}
}
include servers/*;
}
And then I run nginx -s reload
. The error I receive is:
vagrant@precise32:~$ nginx -s reload
nginx: [alert] could not open error log file: open() "/var/log/nginx/error.log" failed (13: Permission denied)
2016/12/22 00:36:48 [notice] 1442#0: signal process started
2016/12/22 00:36:48 [alert] 1442#0: kill(890, 1) failed (1: Operation not permitted)
My understanding is that vagrant
should be a user on the VM with sudo access and root permissions. No? Can anyone reproduce this and figure out why I'm unable to reload nginx with my custom nginx.conf
file?
vagrant user has indeed
sudo
privilegies but its not because it has this right that he can run command as root. As you did runsudo apt-get update
with sudo, you need to run nginx with sudo :