简体   繁体   English

Laravel返回404s

[英]Laravel Returning 404s

Ok, so I'm giving Laravel a go. 好的,所以我给Laravel一个机会。 Installed it, directories set up, everything good to go. 安装好它,建立目录,一切顺利。

Alas, when I add add,当我添加

Route::get('users' function() {
    return "users!";
});

to routes.php and attempt to navigate to /users in my browser, I'm kicked back with a 404... the requested url /users was not found on this server . 到routes.php并尝试在浏览器中导航到/ users,我被踢回了404 ... the requested url /users was not found on this server

I'm pretty sure it's a basic configuration thing, but I've got no idea what the exact cause is. 我很确定这是基本配置,但是我不知道确切原因是什么。

Any thoughts or pointers? 有什么想法或建议吗?

The issue was ultimately an apache configuration oops. 问题最终是apache配置问题。 When setting up for Laravel, make sure your VirtualHost file (in /etc/apache2/sites-available/) has something resembling the following: 设置Laravel时,请确保您的VirtualHost文件(在/ etc / apache2 / sites-available /中)具有类似于以下内容:

<VirtualHost *:80>
        DocumentRoot /var/www/vhosts/laravel/public
        ServerName laravel.HidingMyDomainName.com
        ServerAlias www.laravel.HidingMyDomainName.com
</VirtualHost>

It should not be necessary to add an AllowOverride since the included .htaccess in the public dir contains this already. 不必添加AllowOverride,因为公共目录中包含的.htaccess已包含此内容。

Also of note, if Laravel was installed by another user, you could potentially run into a permission denied error. 还要注意的是,如果Laravel由另一个用户安装,则可能会遇到权限被拒绝的错误。 To fix this, simply sudo chown -R www-data:www-data /path/to/laravel/* in your terminal of choice. 要解决此问题,只需在您选择的终端中使用sudo chown -R www-data:www-data /path/to/laravel/* Be aware of your default apache user, www-data is the default in Ubuntu server installations. 请注意您的默认apache用户,www-data是Ubuntu服务器安装中的默认用户。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM