How to Install Laravel 5.7 with XAMPP on Mac

Requirements

  • PHP >= 7.0.0
  • OpenSSL PHP Extension
  • PDO PHP Extension
  • Mbstring PHP Extension
  • Tokenizer PHP Extension
  • XML PHP Extension

Laravel 5.7 requires PHP version 7.1.3 or more, and some other extensions. Since we are doing setup on XAMPP. Make sure to Install the XAMPP with version >= 7.2.0 .

Install XAMPP

First of all we need to download and install XAMPP. Download it from the apache friends official website. Download the XAMPP version > 7.2.0. Download the version for OSX (Mac).

Follow the steps to install the XAMPP. If you are on MAC, the install location for XAMPP will be /Applications/XAMPP.

Once the XAMPP is Installed, you should be able to access the XAMPP Console from where you can start or stop the necessary services.

XAMPP 7 for Laravel 5.5

If you XAMPP is installed correctly and if you have the apache service running under it, you should see the following page when you access localhost on your browser.

 

XAMPP Home Screen

 

 

Composer

After you have downloaded XAMPP, We need to install Composer.

Composer is a dependency management or package management tool which is integrated with Laravel Framework. Check by running composer command in your terminal if your system has composer already installed in it. If not you can install it by following the steps for OSX (Installing Composer on OSX )

Composer for Laravel 5.5

 

Install Laravel Framework

The default directory of XAMPP for installing or keeping PHP project is htdocs. Navigate to following directory in your terminal /Applications/XAMPP/htdocs and run following composer command to create a fresh Laravel 5.5 version

composer create-project laravel/laravel myProject "5.5.*"

 

After running this command composer should start downloading dependencies that are required to create the Laravel project.

 

–More downloading–

 

When it finishes it will create a Laravel 5.5 project with following data structure.

 

 

Modify Directory Permissions

In the newly created Laravel Project we need to modify the directory permissions of certain directory otherwise we will get following error on accessing the project

The stream or file “laravel.log” could not be opened: failed to open stream: Permission denied.

  • cd into your Laravel project.
  • sudo chmod -R 777 storage
  • sudo chmod -R 777 bootstrap/cache

 

XAMPP Virtual Host

We need to configure XAMPP Virtual Host to set the document root to correct directory of laravel project and to also assign a name to the project by which we will be accessing it in browser.

Navigate and open file /Applications/XAMPP/etc/httpd.conf file and uncomment the line that includes the virtual host file.


# Virtual hosts
Include etc/extra/httpd-vhosts.conf

Navigate and open file /Applications/XAMPP/etc/extra/httpd-vhosts.conf and include following Virtual host entry in this file.

# VirtualHost for LARAVEL.LOCAL

<VirtualHost laravel.local:80>
  DocumentRoot "C:\xampp\htdocs\myProject\public"
  ServerAdmin laravel.local
  <Directory "C:\xampp\htdocs\myProject">
        Options Indexes FollowSymLinks
        AllowOverride All
        Require all granted
  </Directory>
</VirtualHost>

With this entry our apache is listening to laravel.local, but we also have to edit our hosts file to include an entry for the new domain.

Edit file /etc/hosts and add following entry to that file.

127.0.0.1 laravel.local

Restart your apache and access laravel.local on your browser you should be able to see this screen.

 

 

Success !

Web Stuff Enthusiast.

Related Posts

3 comments On How to Install Laravel 5.7 with XAMPP on Mac

  • The virtualhost part is copied from a windows configuration. On mac it should be:

    DocumentRoot “/Applications/XAMPP/xamppfiles/htdocs/myProject/public”
    ServerAdmin laravel.local

    Options Indexes FollowSymLinks Includes execCGI
    AllowOverride All
    Require all granted

    ErrorLog “logs/laravel.local-error_log”

  • Hello, I followed all of these steps to the letter but when I try to navigate to “laravel.local” on safari I just get the message “safari can’t open the page “laravel.local” because the server unexpectedly dropped the connection.” I have the same issue with any browser I try to use to navigate to the laravel site. Could you please offer any advice?

  • Hi there I found perfect resources to start my learning in Laravel 5.
    Thanks Again………………………….

Leave a reply:

Your email address will not be published.

Site Footer