How to install Magento 2 with PHP7 on localhost

Magento 2 is the new version of Magento framework which has many changes and advantages as compared to previous versions like site maintenance, easy to handle dashboard, obviously fast performance etc. The main and important aspects are the enhanced Admin Panel, separate tables for order processing, better image compression by default, static content caching etc.

PHP7 is an improved version of PHP Scripting Language which is ready for development and production environment. It has 2x faster performance and more than 50% lower memory consumption than previous PHP 5.6 version.

In this tutorial, we are going to use EasyPHP DevServer v16.1 (you can also use the latest version if it has been released) which includes Apache 2.4.17, PHP v7.0.1, PhpMyAdmin v4.5.2 and MySQL v5.7.9. Download and install it and make sure to set the path of PHP.EXE and PHP.INI in the Environment Variable. Also we are going to install Composer. Magento is now using Composer for dependency management. Composer enables Magento 2 to manage its components and dependencies. Download Composer via this link and install it.

We selected EasyPHP DevServer on the basis of official system requirements of Magento 2. Here are the official Magento 2 system requirements:

Web servers:

Apache 2.4 or 2.2 (In addition, the apache mod_rewrite module must be enabled. mod_rewrite enables the server to perform URL rewriting)

OR

nginx 1.8 (or latest mainline version)

Database:

MySQL 5.7.x

OR

MySQL 5.6.x

PHP:

7.0.x

OR

5.6.x

OR

5.5.x (Magento no longer supports PHP 5.4.x)

Before you begin Magento 2 installation on your localhost, you should know that Magento 2 requires some extensions support for PHP7. Make sure you have the following PHP7 extensions installed and enabled on your EasyPHP DevServer:

For more information about Magento 2 system requirements, visit Magento official website.

We are now ready to install Magento 2 on our local server. Here are the steps to follow:

Step 1

Download Magento 2 zip file from official download page.

Step 2

Start your EasyPHP DevServer. Right click on EasyPHP DevServer icon in Taskbar and click Open Dashboard.

Start your EasyPHP DevServer

Start your EasyPHP DevServer

Step 3

On Dashboard, click start button below HTTP Server, Choose Apache as Server, Select PHP v7.0.1, Port 8888 and press start button.

Configure the server

Step 4

Return to Dashboard, now click start button below DATABASE Server, choose MySQL as Server and press start button.

Choose database

Step 5

Return to your Dashboard and click on Portable Directory Link to explore the directory here we have to extract/unzip Magento 2 files and folders from the downloaded zip file. This is also known as ROOT Directory of your local server and in the rest of this article, we’ll refer to this directory as “ROOT.

Set database

Step 6

Create a new folder magento2 in ROOT and extract all the files and folders from the zip file to this directory using 7-Zip file archiver.

Magento 2

Magento 2

Step 7

Go to your EasyPHP DevServer Dashboard, open PhpMyAdmin and create a new database – “magento2”.

Create database for Magento 2

Create database for Magento 2

Step 8

Now we are ready to install Magento 2 on our local server. To access Magento installation/setup, enter your Magento 2 URL http://127.0.0.1:8888/magento2/ in your favorite web browser and hit enter. You’ll be automatically landed on the start page of Magento Setup, then click “Agree and Setup Magento”.

Agree and setup Magento 2 on localhost

Starting the Magento 2 Browser Installer

In this step, Magento will perform Readiness Check on your environment which includes PHP Version Check, PHP Settings Check, PHP Extension Check and File Permission Check. If you get any errors, you must resolve them in order to continue the setup.

Magento 2 Installer

Magento 2 installer, localhost

In this step, Magento will ask you for some database details. Enter database server host “127.0.0.1”, username “root” and an already created database name “magento2”.

Magento 2 localhost database

Step 3 will ask for web configurations where you have to enter your Store Address and Admin URL. Change your Store Address to “http://127.0.0.1:8888/magento2/” (it may be set by default), and admin URL depends on what you wish.

Magento 2 localhost config

In this “Customize Your Store” section, you can select your timezone, currency and language of the future test Magento 2 store.

Magento 2 localhost details

Enter Username, Email Address and Passwords to setup your Admin Panel’s credentials.

Magento 2 credentials on localhost

Are you ready to install Magento 2 on your local server? Click “Install Now” and wait for a few mins.

NB: Do not close your browser until the setup is done and a success page appears!

Install Magento 2 on localhost with php7

Magento 2 installing on localhost

A “Success” message will appear which will indicate the successful installation of Magento 2 on your local server but wait, it’s not over yet. Do not open your store address or admin panel URL. There are a few more things to do.

Magento 2 successfully iinstalled on localhost

Now we are going to verify composer installation, deploy static content, clear/flush Magento cache and reindex the Magento 2 blocks by using Magento 2 CLI Commands. If you need to know more about it, read this article. To perform all the actions mentioned above, press WINDOWS KEY + R to open RUN dialog and type “cmd” to open Command Prompt.

Open console

 

Type “cd PATH_TO_YOUR_MAGENTO2_FILES” to enter the Magento 2 ROOT directory.

Path to Magento 2 files

Now, to verify Composer installation in the directory mentioned above, type “composer install”.

NB: If you get any error in this step, please double check your Composer installation.

Magento 2 composer install on localhost

In this step, we are setting up static content to deploy on our Magento store. To perform this, type “php bin/magento setup:static-content:deploy”.

NB: If you get any error, check your PHP.EXE and PHP.INI Environment Variable.

Magento 2 static content deploy

Clear/Flush Magento 2 cache by typing “php bin/magento cache:flush” in the CMD.

Flush Magento 2 cache on localhost

And finally, to Reindex Magento Static Blocks type “php bin/magento indexer:reindex”.

Reindex Magento 2 static blocks on localhost

Please visit your store address http://127.0.0.1:8888/magento2/ to access Frontend and your admin panel URL (my URL is http://127.0.0.1:8888/magento2/admin_cloudways) to access Admin Panel of your Magento 2 store.

We are done with Magento 2 setup and installation on your localhost. If you faced any problem, feel free to share it and comment below. Enjoy using Magento 2 with PHP7 configuration and discover the exclusive features of the new platform!