【发布时间】:2015-02-04 09:18:27
【问题描述】:
我正在 NGINX 上部署 Laravel 应用程序
我在 routes.php 中指定了一个路由,用于处理非刀片 php 文件以及我的一些刀片 php 文件
Route::any('/{pagephp}.php',function($pagephp) {
return View::make($pagephp); //This will handle .PHP as well as blades
});
但每当我尝试访问诸如 terms.blade.php 之类的文件时,我都会收到 No Input File specified 错误 请注意,当我访问指定的路线时,我不会收到错误消息。例如我有我有的signin.blade.php
Route::get('/signin',function() {
return View::make('signin');
});
查看错误日志时,我看到了
[error] 969#0: *91 FastCGI sent in stderr: "Unable to open primary script:
/var/www/xxxx/public/terms.php (No such file or directory)" while reading response
header from upstream, client: xxxxxxxx, server: xxxx, request: "GET /terms.php HTTP/1.1",
upstream: "fastcgi://unix:/var/run/php5-fpm.sock:", host:
根据错误,NGINX 正在尝试在公共目录中查找 terms.php,而不是将其发送到 route.php 有没有办法解决这个问题?
我的 NGINX 配置文件如下
server {
# Port that the web server will listen on.
listen 80;
# Host that will serve this project.
server_name xxxx;
# Useful logs for debug.
access_log /var/www/xxxx/app/storage/logs/access.log;
error_log /var/www/xxxx/app/storage/logs/error.log;
rewrite_log on;
# The location of our projects public directory.
root /var/www/xxxx/public;
# Point index to the Laravel front controller.
index index.php;
location / {
# URLs to attempt, including pretty ones.
try_files $uri $uri/ /index.php?$query_string;
}
# Remove trailing slash to please routing system.
if (!-d $request_filename) {
rewrite ^/(.+)/$ /$1 permanent;
}
# PHP FPM configuration.
location ~* \.php$ {
fastcgi_pass unix:/var/run/php5-fpm.sock;
fastcgi_index index.php;
fastcgi_split_path_info ^(.+\.php)(.*)$;
include /etc/nginx/fastcgi_params;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
}
# We don't need .ht files with nginx.
location ~ /\.ht {
deny all;
}
# Set header expirations on per-project basis
location ~* \.(?:ico|css|js|jpe?g|JPG|png|svg|woff)$ {
expires 365d;
}
}
【问题讨论】: