Lspoor
Lspoor

Reputation: 1

Laravel and Mamp Localhost Error 500 Mac

So after a fresh install of laravel (v5.4) and using Mamp as my local server I just get (in chrome)

The localhost page isn’t working

localhost is currently unable to handle this request.
HTTP ERROR 500

I've tried countless things like changing permissions on storage or everything within the laravel directory.

Done composer update/install in the directory.

I'm running PHP v7.0.12 on my Mac (10.11.6). Cant think of anything else that would be causing this?

If I create another directory which a simple index.php with '' it loads absolutely fine so what is causing an issue with laravel?

Here's pics of my mamp setup

https://i.sstatic.net/hg3lV.png
https://i.sstatic.net/uNUU1.png

Upvotes: 0

Views: 3046

Answers (2)

Peyman
Peyman

Reputation: 312

I just joined stackoverflow yesterday so I do not have enough reputation to comment. I write an answer here.

here is the short answer:

run :

PHP_VERSION=`ls /Applications/MAMP/bin/php/ | sort -n | tail -1`
echo "export PATH=/Applications/MAMP/bin/php/${PHP_VERSION}/bin:$PATH" >> .bash_profile
source ~/.bash_profile

check your php version by running php -v. close the terminal. Open another terminal and check php version again.if you see php 5 again then there are 2 possibilities: First: you added the /path/to/php7 after /path/to/php5 and php 5 is loaded first. Second: system loads another bash file first which your php 5 path is mentioned in it. I know that this sounds confusing having several bash file but it is. Please search for other files like bashrc or similars.

This is the long answer for anyone else:

first of all, if you are on mac, I highly suggest you to use valet to get rid of all these things.

But regarding the problem:

As you already noted that it is not a laravel issue. the php version that your machine uses is under the min required version by laravel. You have 2 versions of php at the moment. MacOs is shipped with php installed on that. I think it is the same php 5.5.36 that is making problem for you. Since Laravel 5.4, you need to use PHP >= 5.6.4. Although you have installed parallel php 7 on your machine, you need also to check which php your machine is reading from by running which php. after that remember to add your path to php 7 installed to bash_profile or other bash files on your mac(you can have 4 or 5 bash files). Considering you have only one bash file named as bash_profile and you are going to export the path to your php 7 to bash profile, If you run following command, that appends the path to the end of file

PHP_VERSION=`ls /Applications/MAMP/bin/php/ | sort -n | tail -1`
echo "export PATH=/Applications/MAMP/bin/php/${PHP_VERSION}/bin:$PATH" >> .bash_profile

remember to use source ~/.bash_profile in order to make changes effected. Alternatively you can open the bash_profile file in your text editor by running:

open -a /Applications/TextEdit.app ~/.bash_profile

and add the path manually before the /path/to/php5 path.

finally you must check your php version by running php -v. close the terminal. Open another terminal and check php version again. If you see php 7 then you are all fine. But if you see php 5 again then there are 2 possibilities: First: you added the /path/to/php7 after /path/to/php5 and php 5 is loaded first. Second: system loads another bash file first which your php 5 path is mentioned in it. I know that this sounds confusing having several bash file but it is. Please search for other files like bashrc or similars.

Upvotes: 0

Saurabh
Saurabh

Reputation: 2775

Open up terminal and type:

tail -n 20 /Applications/MAMP/logs/php_error.log

This may give you some clue as to what is going on.

Hope this helps, happy coding :)

Upvotes: 1

Related Questions