【问题标题】:.PHP specific Laravel route and NGINX issue.PHP 特定的 Laravel 路由和 NGINX 问题
【发布时间】: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;

}

}

【问题讨论】:

    标签: php laravel nginx routes


    【解决方案1】:

    如果这些文件不属于 laravel 框架,它们不应该在目录中,但是如果你想测试一个特定的 php 脚本,你可以把它放在公共文件夹中,并且可以通过 yourdomain.com/script 访问。 php

    【讨论】:

      猜你喜欢
      • 2015-04-22
      • 2012-08-16
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2017-04-17
      • 1970-01-01
      • 2014-02-28
      相关资源
      最近更新 更多