4

Laravel 5 deployment getting :

Internal Server Error

The server encountered an internal error or misconfiguration and was unable to complete your request

My file structure:

|
|-pub                           -> from laravel folder public
|-my_apps
     |- my_first_app            -> all other files from laravel project
           |- app
           |- bootstrap
           |- config
           |- database
           |- resources
           |- storage
           |- ...

I have set storage folder permission to be:

user::rwx

group::rwx

other::rwx

This is my .htaccess file in directory /pub

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

    RewriteEngine On
    RewriteBase /  <-------- I added this line

    # Redirect Trailing Slashes If Not A Folder...
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteRule ^(.*)/$ /$1 [L,R=301]

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

I also change path in \pub\index.php

<?php

//updated path
require __DIR__.'/../my_apps/my_first_app/bootstrap/autoload.php';

//updated path
$app = require_once __DIR__.'/../my_apps/my_first_app/bootstrap/app.php';

$kernel = $app->make(Illuminate\Contracts\Http\Kernel::class);

$response = $kernel->handle(
    $request = Illuminate\Http\Request::capture()
);

$response->send();

$kernel->terminate($request, $response);

PHP on my local machine is PHP 5.6, it is PHP 5.5. I tried to add

AddHandler application/x-httpd-php55 .php

in .htaccess after RewriteEngine On line.

update

The server runs PHP 5.5.0, so I downgraded my Laravel 5.1 to 5.0, and it works on homestead now. And I'm following https://medium.com/laravel-news/the-simple-guide-to-deploy-laravel-5-application-on-shared-hosting-1a8d0aee923e#.50q2s8wer for deployment at this moment. Downgrade actually failed when I check version of laravel

4
  • 1
    Check laravel and apache logs for more information about nature of the error. Commented Nov 28, 2015 at 18:15
  • Check for the php version Commented Nov 29, 2015 at 7:55
  • php version 5.5.0 on the server and I used php 5.6 on homestead for developing Commented Nov 29, 2015 at 18:45
  • Downgrading to laravel 5 with the changes you made in the default codes is working correctly? What do you mean by: "and it works on homestead now." Commented Dec 2, 2015 at 20:22

4 Answers 4

1

Laravel 5.1 requires PHP 5.5.9, per packagist.

Laravel 5.0 has no bound PHP version requirement, per packagist, however anything less than PHP 5.5 is Not A Good Idea.

Since your server runs 5.5.0 (per comment), then I'm guessing you installed this outside of composer. Downgrade your Laravel environment or upgrade your PHP environment. Upgrading PHP is A Good Idea.

Sign up to request clarification or add additional context in comments.

2 Comments

I already downgraded my laravel to 5.0, still getting Internal Server Error. I don't have permission to upgrade PHP on server
Alright. "Internal Server Error" usually (but not exclusively) means Laravel emitted an uncaught exception (eg, bad configuration) or PHP encountered a Fatal Error (eg, syntax error). Check your Apache, PHP, and Laravel logs and post the results as an update. Apache logs are often in /var/log/httpd/ or /var/log/apache. PHP error logs are often in /var/log/messages, but php -i | grep error will tell more. Laravel logs are often in your application directory under storage/logs. More here
1

"Internal Server Errors" maybe caused by many reason. Library is not installed, misconfiguration, version conflicted.

So please check the apache errors in /var/log/apache or /var/log/httpd, Laravel errors for more detail about the error. If you cannot see error, be sure that you turned on php display error in php.ini file.

Comments

1

If you could check the logs in /var/log/apache2 or /var/log/httpd for errors, it would be much helpful. But, since you said that your server is running PHP 5.5.0 and

Downgrade actually failed when I check version of laravel

so, clearly the most probable reason is that your server is trying to run laravel 5.1 with PHP 5.5.0 which is not supported. The solution for you now is to create a fresh project with laravel 5.0 and then copy code files you have created from current project to the new project and update them accordingly so that they work with laravel 5.0.

Comments

0

In my case it was as simple as a case-sensitivity typo in one of my includes. I develop on a Windows machine, which doesn't care about case-sensitivity in file paths. After deploying to a Linux server however I got the infamous Internal Server error.

Checking laravels php_errors.log quickly made it clear what was wrong.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.