Laravel - 404未找到

时间:2017-07-28 08:19:16

标签: php laravel nginx

我刚开始使用Laravel过去几天,我在网址路由方面遇到问题,我的http://localhost:8017/laravel看起来不错,但http://localhost:8017/laravel/foo返回

  

404 Not Found

我的操作系统Ubuntu 16.04,Laravel 5.4

路由/ web.php

Route::get('/', function () {
    return view('welcome');    
});

// oedin
Route::get('foo', function () {
    return 'Hello World';
});

nginx配置

server {
    listen 8017 default_server;
    listen [::]:8017 default_server;

    # SSL configuration
    #
    # listen 443 ssl default_server;
    # listen [::]:443 ssl default_server;
    #
    # Note: You should disable gzip for SSL traffic.
    # See: https://bugs.debian.org/773332
    #
    # Read up on ssl_ciphers to ensure a secure configuration.
    # See: https://bugs.debian.org/765782
    #
    # Self signed certs generated by the ssl-cert package
    # Don't use them in a production server!
    #
    # include snippets/snakeoil.conf;

    #root /var/www/html;
    root /home/oedin/webdev;

    # Add index.php to the list if you are using PHP
    index index.php index.html index.htm;

    server_name localhost;

    location / {
        try_files $uri $uri/ /index.php?$query_string;
    }

    # pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000
    #
    location ~ \.php$ {
        include snippets/fastcgi-php.conf;
        #try_files $uri /index.php =404;
        #fastcgi_split_path_info ^(.+\.php)(/.+)$;
        fastcgi_pass unix:/run/php/php7.0-fpm.sock;
        #fastcgi_index index.php;
        #fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
        #include fastcgi_params;

    }

    # deny access to .htaccess files, if Apache's document root
    # concurs with nginx's one
    #
    #location ~ /\.ht {
    #   deny all;
    #}
}

5 个答案:

答案 0 :(得分:1)

如果你附加index.php,我认为它会起作用。

import pyarrow as pa
import pyarrow.parquet as pq
import pandas as pd

df = pd.DataFrame([data]) #data is dictionary
table = pa.Table.from_pandas(df)
pq.write_table(table, 'tmp/test.parquet', compression='snappy')
table = pq.read_table('tmp/test.parquet')
table.to_pandas()
print(table)

答案 1 :(得分:0)

问题与服务器有关,你需要像Apache中的模式覆盖一样。在nginx中,没有任何要求,但尝试这样的事情

How to convert Apache's `AllowOverride all` to nginx

答案 2 :(得分:0)

如果您想使用nginx为您的应用程序提供服务,建议您创建一个包含项目根文件夹的新nginx vhost配置。

然而php artisan serve的生活可能会更容易,此时不需要nginx服务器。

答案 3 :(得分:0)

你可以试试这个:

Route::group(['namespace' => 'Laravel', 'prefix' => 'laravel', 'middleware' => 'laravel'], function () {

    Route::get('/', function () {
        return view('welcome');    
    });

    // oedin
    Route::get('foo', function () {
        return 'Hello World';
    });
});

您应该在终端

中运行php artisan serv命令
your URL like http://localhost:8000/laravel/foo

希望这对你有用!!!

答案 4 :(得分:0)

这可能是由于查询错误,例如我的情况,试图显示带有错误报告的错误,日志中什么也没有,但是我尝试捕获错误查询中的异常,得到了SQL错误..

希望获得帮助,

在使用try-catch语句时包装希望捕获异常的代码行

enter code here

try
{
//write your codes here
}
catch(Exception $e)
{
   dd($e->getMessage());
}

不要忘记说出控制器顶部的Exception类

使用异常;