简体   繁体   中英

Laravel Returning 404s

Ok, so I'm giving Laravel a go. Installed it, directories set up, everything good to go.

Alas, when I 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 .

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. When setting up for Laravel, make sure your VirtualHost file (in /etc/apache2/sites-available/) has something resembling the following:

<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.

Also of note, if Laravel was installed by another user, you could potentially run into a permission denied error. To fix this, simply sudo chown -R www-data:www-data /path/to/laravel/* in your terminal of choice. Be aware of your default apache user, www-data is the default in Ubuntu server installations.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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