Vagrant,nginx 404 – 在stderr中发送的fastcgi无法打开主脚本

谷歌很多,并没有find解决scheme。 在这里find了几个接受的答案在stackoverflow,但他们没有帮助我。

我正在使用stream浪者发展,或者至less试图使用它。 有没有安装它的问题,但是当我尝试运行一个网站,我越来越404,我的猜测是,这是更多的Nginx问题,而不是stream浪问题。

我已经添加到我的Windows主机127.0.0.1 lara.dev

这是我的nginx网站configuration如下:

server { listen 80; server_name lara.dev; root C:/xampp/htdocs/lara/public; index index.html index.htm index.php; charset utf-8; location / { try_files $uri $uri/ /index.php?$query_string; } location = /favicon.ico { access_log off; log_not_found off; } location = /robots.txt { access_log off; log_not_found off; } access_log off; error_log /var/log/nginx/lara.dev-error.log error; error_page 404 /index.php; sendfile off; location ~ \.php$ { fastcgi_split_path_info ^(.+\.php)(/.+)$; fastcgi_pass unix:/var/run/php5-fpm.sock; fastcgi_index index.php; include fastcgi_params; fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; fastcgi_intercept_errors on; fastcgi_buffer_size 16k; fastcgi_buffers 4 16k; } location ~ /\.ht { deny all; } } 

在日志文件中,我得到这个:

 FastCGI sent in stderr: "Unable to open primary script: /usr/share/nginx/C:/xampp/htdocs/lara/public/index.php (No such file or directory)" while reading response header from upstream, client: 10.0.2.2, server: lara.dev, request: "GET / HTTP/1.1", upstream: "fastcgi://unix:/var/run/php5-fpm.sock:", host: "lara.dev:8000" 

和我的家园档案

 --- ip: "192.168.10.10" memory: 2048 cpus: 1 authorize: C:/Users/Tim/.ssh/general.pub keys: - C:/Users/Tim/.ssh/general folders: - map: C:/xampp/htdocs/ to: /home/vagrant/html sites: - map: lara.dev to: /home/vagrant/html/lara/public/ databases: - homestead variables: - key: APPLICATION_ENV value: env-localhost 

stream氓文件:

 require 'json' require 'yaml' VAGRANTFILE_API_VERSION = "2" homesteadYamlPath = File.expand_path("~/.homestead/Homestead.yaml") afterScriptPath = File.expand_path("~/.homestead/after.sh") aliasesPath = File.expand_path("~/.homestead/aliases") require_relative 'scripts/homestead.rb' Vagrant.configure(VAGRANTFILE_API_VERSION) do |config| if File.exists? aliasesPath then config.vm.provision "file", source: aliasesPath, destination: "~/.bash_aliases" end Homestead.configure(config, YAML::load(File.read(homesteadYamlPath))) if File.exists? afterScriptPath then config.vm.provision "shell", path: afterScriptPath 

末端

这更可能是php5-fpm的configuration有问题。 但是,我不知道。 Tnx提前。

根据输出:

无法打开主脚本:/usr/share/nginx/C:/xampp/htdocs/lara/public/index.php(没有这样的文件或目录)

看起来你正在引用Windows风格的path( C:/ ),但在Linux虚拟机上运行nginx( /usr/share/nginx )。 默认情况下,Vagrant 只共享一个文件夹 ,它是主机上的项目文件夹(Windows)和客人机器上的/vagrant (Linux)。

您的访客机器无法访问非共享文件夹,因此nginx也不能访问。

大多数基于Vagrant的项目将应用程序的内容放在项目文件夹的根目录下,在这种情况下,您可以将root指令更改为:

 root /vagrant 

如果您的项目存在于名为app的文件夹中:

 root /vagrant/app 

您也可以select映射更多的文件夹,方法是编辑您的Vagrantfile文件,重新启动客机,然后在root使用新的同步文件夹。