pthurmond pthurmond - 1 year ago 108
PHP Question

Unable to get any routes to work in Laravel 4.2 on Ubuntu 14.04 with PHP 5.5

I am struggling to get Laravel 4.2 to work on my Digital Ocean server running Ubuntu 14.04 with PHP 5.5. I can get the screen that shows the Laravel logo where it says "You have arrived". I am tired and it is late, but I am getting very frustrated and I really have to get this working tonight.

My routes are as follows:

Route::get('/', function()
return View::make('hello');

Route::any('monkey', function()
return View::make('monkey');

Route::resource('search', 'SearchController');

I cannot get it to say "hello" or "monkey". What gives???

I have already gone into the apache.conf and changed the "AllowOverride" to "All" from none and restarted the Apache service.

My laravel.log file shows this:
production.ERROR: exception 'Symfony\Component\HttpKernel\Exception\MethodNotAllowedHttpException'

I just tried adding the following route with no change...

Route::any('test', function()
return 'Test This!!!';

Update 2:

Here is my .htaccess file under public:

<IfModule mod_rewrite.c>
<IfModule mod_negotiation.c>
Options -MultiViews

RewriteEngine On

# Redirect Trailing Slashes...
RewriteRule ^(.*)/$ /$1 [L,R=301]

# Handle Front Controller...
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^ index.php [L]

Answer Source

You need to enable mod_rewrite as it generally isn't enabled by default.

Run the following commands in terminal to enable it.

a2enmod rewrite

Then restart Apache:

service apache2 restart
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download