Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Getting a 500 Internal Server Error on Laravel 5+ Ubuntu 14.04

I have installed Laravel many times on Windows OS but never had this problem.

However, on Ubuntu 14.04 I am getting a 500 Internal Server Error, and messages like this in my logs:

[Wed Jul 22 10:20:19.569063 2015] [:error] [pid 1376] [client 127.0.0.1:52636] PHP Fatal error: require(): Failed opening required '/var/www/html/laravel_blog/../bootstrap/autoload.php' (include_path='.:/usr/share/php:/usr/share/pear') in /var/www/html/laravel_blog/index.php on line 22

Previously I've had problems when mod_rewrite was not installed or set up properly, but I have installed it and it is not working. Changed .htaccess as well from original to this.

    +FollowSymLinks
RewriteEngine On

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

I've given access to all my folders and files inside i.e.

/var/www/html/laravel_project

I have all the necessary extensions needed for Laravel 5+ as well. Is there something left that I didn't do?

like image 276
DpEN Avatar asked Jul 21 '15 15:07

DpEN


People also ask

How do I fix 500 Internal server error in Ubuntu?

When the webserver has no permissions to access the site files, it may throw an HTTP 500 error. The solution to this issue is to change the website file's permissions recursively .


4 Answers

Finally Overcame the problem

  • It was not the .htaccess file that was the problem nor the index.php. The problem was on accessing the files and requiring permissions.

For solving the problem i ran the following commands through terminal.

sudo chmod -R 755 laravel_blog

and then type below to allow laravel to write file to storage folder

chmod -R o+w laravel_blog/storage

This two commands solved the problem.

like image 141
DpEN Avatar answered Oct 09 '22 21:10

DpEN


Create the .env file and also run :

php artisan key:generate

This worked for me after pulling a git project.

After creating .env file and generating the key, run the code below:

php artisan cache:clear 
php artisan config:clear
like image 40
Goodlife Avatar answered Oct 09 '22 22:10

Goodlife


After installing run below command

sudo chmod 755 -R laravel
chmod -R o+w laravel/storage

here "laravel" is the name of directory where laravel installed

like image 30
Sujendra Kumar Avatar answered Oct 09 '22 20:10

Sujendra Kumar


Try to check if you have .env file.

Mostly this thing can cause something like that. Try to create a file then copy everything from .env.example, paste it to your created file and name it .env. or jsut simply rename the .env.example file to .env and run php artisan key:generate

like image 30
Lesther Avatar answered Oct 09 '22 22:10

Lesther