How to install Magento 2 with PHP7 on localhost

Table of Content

How to install Magento 2 with PHP7 on localhost
Posted in: Magento 2 Guides

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.

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.

Step 4

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

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.

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.

Step 7

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

Step 8

Now we are ready to install Magento 2 on our local server. To access Magento installation/setup, enter your Magento 2 URL  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”.

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.

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”.

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

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

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

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!

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.

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.

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

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.

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.

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

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

Please visit your store address to access Frontend and your admin panel URL 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!

September 25, 2016
October 6, 2016
September 23, 2016
Comments
Marcel
May 12, 2016
Great tutorial. I get an error when typing the command: php bin/magento setup:static-content:deploy Error: PS C:\Program Files (x86)\EasyPHP-Devserver-16.1\eds-www\magento2> php bin/magento setup:static-content:deploy Requested languages: en_US Could not parse theme static file 'C:/Program Files (x86)/EasyPHP-Devserver-16.1/eds-www/magento2/vendor/magento/theme-frontend-blank/web/css/email-fonts.less'> I don't understand the error, the file does exist.
Reply
Fayyaz Khattak
May 18, 2016
I think this must be the error because of the corrupt file. Try downloading the Magento zip properly from official download center and extract it using different archive software. I tried the method again on my localhost and it is working great. I hope this would help you!
Stanislav Puffler
September 18, 2016
Strange, I have the same error. And also some error with Composer. Using Magento 1 for more than 5 years and Magento 2 seems to be extremely complicated for me. Just giving it a try, but actually every step of your tutorial brings some issues on my laptop :)
Ger
November 19, 2016
I have exactly the same issue. Downloaded Magento CE 2.1.2 from the official website, but it gives errors in the *.less-files If I remove the email-fonts.less, the next
Fayyaz Khattak
November 19, 2016
Hi Ger, As I had already explained it in below comment, still, new release of Magento 2 mostly comes up with different issues and Magento along with Community champs always try to fix them as soon as possible. Specifically, Magento 2.1.x has also some issues with PHP 7 releases as well, so I'll personally test Magento 2.1.2 on localhost with PHP 7 and then get back to you. Thanks.
Tom
June 6, 2016
Note that as of today there doesn't appear to be a native Image Magick 32-bit extension for PHP 7.
Reply
Tom
June 6, 2016
Never mind -- found it: https://pecl.php.net/package/imagick/3.4.1/windows
Kelson
September 12, 2016
Thank you!It helps a lot.
Reply
Fayyaz Khattak
November 10, 2016
Hi Kelson, Your most welcome.
Stanislav Puffler
September 18, 2016
As for composer, I´m getting this: C:\Program Files (x86)\EasyPHP-Devserver-16.1\eds-www\magento2>composer install ←[32mLoading composer repositories with package information←[39m ←[32mInstalling dependencies (including require-dev) from lock file←[39m Nothing to install or update ←[30;43mPackage fabpot/php-cs-fixer is abandoned, you should avoid using it. Use friendsofphp/php-cs-fixer instead.←[39;49m ←[32mGenerating autoload files←[39m Can you explain more deeply what do you mean by double check your Composer installation?
Reply
Fayyaz Khattak
November 10, 2016
Composer install command reads the composer.json file which helps to resolve the dependencies (if missing) and installs them back into the vendor folder. That's why, after the web installer, we are checking if everything is up to mark or not. Regarding the thing you are getting, PHP-CS-Fixer is a tool which automatically fixes your Magento 2 code. It's a dependency in Magento 2, and I think we can't do anything about it rather than just waiting.
Stanislav Puffler
October 21, 2016
Is there any progress with email-fonts.less error? Have bought EasyPHP Devserver just because this article and now it seems useless - no Magento 2 version is working like written in that article, even with different PHP versions (have tryied 7.0.2, 7.0.6 and 7.11). Thanks a lot for any help...
Reply
Ksenia Dobreva
October 21, 2016
Hey Stanislav, I've tried to contact with the author of the article, but no luck here =(
Fayyaz Khattak
November 10, 2016
Hi Stanislav, Different Magento 2 versions has different issues and still Magento trying to fix them with the help of Contributors and Community people. I would recommend if you use the same versions as described in the tutorial, you will successfully install the Magento 2 on PHP 7. Thanks.
Anna
November 4, 2016
This is one of the most amazing articles about Magento on the web! Detailed instructions and no missing codes. I just want to say that you saved me so many hours and I'm thankful for that.
Reply
Fayyaz Khattak
November 10, 2016
Hi Anna, Your most welcome.
Chandrakant Agrawal
November 17, 2017
Thank you so much, it saves my day
Reply
Shumaila
December 22, 2017
Great and eay tutorial! But I got this error after hitting store url for the first time. Installation was successful. 2017-12-22 12:01:35] main.CRITICAL: Exception: Warning: Invalid argument supplied for foreach() in C:\Program Files (x86)\EasyPHP-Devserver-16.1\eds-www\3footwear\vendor\magento\framework\App\ResourceConnection\Config.php on line 39 in C:\Program Files (x86)\EasyPHP-Devserver-16.1\eds-www\3footwear\vendor\magento\framework\App\ErrorHandler.php:61 Stack trace: #0 C:\Program Files (x86)\EasyPHP-Devserver-16.1\eds-www\3footwear\vendor\magento\framework\App\ResourceConnection\Config.php(39): Magento\Framework\App\ErrorHandler->handler(2, 'Invalid argumen...', 'C:\\Program File...', 39, Array) #1 C:\Program Files (x86)\EasyPHP-Devserver-16.1\eds-www\3footwear\vendor\magento\framework\ObjectManager\Factory\AbstractFactory.php(93): Magento\Framework\App\ResourceConnection\Config->__construct(Object(Magento\Framework\App\ResourceConnection\Config\Reader\Proxy), Object(Magento\Framework\Config\Scope), Object(Magento\Framework\App\Cache\Type\Config\Proxy), Object(Magento\Framework\App\DeploymentConfig), 'resourcesCache') #2 C:\Program Files (x86)\EasyPHP-Devserver-16.1\eds-www\3footwear\vendor\magento\framework\ObjectManager\Factory\Dynamic\Developer.php(89): Magento\Framework\ObjectManager\Factory\AbstractFactory->createObject('Magento\\Framewo...', Array) #3 C:\Program Files (x86)\EasyPHP-Devserver-16.1\eds-www\3footwear\vendor\magento\framework\ObjectManager\ObjectManager.php(71): Magento\Framework\ObjectManager\Factory\Dynamic\Developer->create('Magento\\Framewo...') #4 C:\Program Files (x86)\EasyPHP-Devserver-16.1\eds-www\3footwear\var\generation\Magento\Framework\App\ResourceConnection\Config\Proxy.php(84): Magento\Framework\ObjectManager\ObjectManager->get('Magento\\Framewo...') #5 C:\Program Files (x86)\EasyPHP-Devserver-16.1\eds-www\3footwear\var\generation\Magento\Framework\App\ResourceConnection\Config\Proxy.php(95): Magento\Framework\App\ResourceConnection\Config\Proxy->_getSubject() #6 C:\Program Files (x86)\EasyPHP-Devserver-16.1\eds-www\3footwear\vendor\magento\framework\App\ResourceConnection.php(91): Magento\Framework\App\ResourceConnection\Config\Proxy->getConnectionName('default') #7 C:\Program Files (x86)\EasyPHP-Devserver-16.1\eds-www\3footwear\vendor\magento\framework\Model\ResourceModel\Db\AbstractDb.php(322): Magento\Framework\App\ResourceConnection->getConnection('default') #8 C:\Program Files (x86)\EasyPHP-Devserver-16.1\eds-www\3footwear\vendor\magento\framework\Model\ResourceModel\Db\Collection\AbstractCollection.php(123): Magento\Framework\Model\ResourceModel\Db\AbstractDb->getConnection() #9 C:\Program Files (x86)\EasyPHP-Devserver-16.1\eds-www\3footwear\vendor\magento\module-store\Model\ResourceModel\Config\Collection\Scoped.php(48): Magento\Framework\Model\ResourceModel\Db\Collection\AbstractCollection->__construct(Object(Magento\Framework\Data\Collection\EntityFactory), Object(Magento\Framework\Logger\Monolog), Object(Magento\Framework\Data\Collection\Db\FetchStrategy\Query), Object(Magento\Framework\Event\Manager\Proxy), NULL, Object(Magento\Config\Model\ResourceModel\Config\Data)) #10 C:\Program Files (x86)\EasyPHP-Devserver-16.1\eds-www\3footwear\vendor\magento\framework\ObjectManager\Factory\AbstractFactory.php(93): Magento\Store\Model\ResourceModel\Config\Collection\Scoped->__construct(Object(Magento\Framework\Data\Collection\EntityFactory), Object(Magento\Framework\Logger\Monolog), Object(Magento\Framework\Data\Collection\Db\FetchStrategy\Query), Object(Magento\Framework\Event\Manager\Proxy), Object(Magento\Config\Model\ResourceModel\Config\Data), 'default', NULL, NULL) #11 C:\Program Files (x86)\EasyPHP-Devserver-16.1\eds-www\3footwear\vendor\magento\framework\ObjectManager\Factory\Dynamic\Developer.php(89): Magento\Framework\ObjectManager\Factory\AbstractFactory->createObject('Magento\\Store\\M...', Array) #12 C:\Program Files (x86)\EasyPHP-Devserver-16.1\eds-www\3footwear\vendor\magento\framework\ObjectManager\ObjectManager.php(57): Magento\Framework\ObjectManager\Factory\Dynamic\Developer->create('Magento\\Store\\M...', Array) #13 C:\Program Files (x86)\EasyPHP-Devserver-16.1\eds-www\3footwear\var\generation\Magento\Store\Model\ResourceModel\Config\Collection\ScopedFactory.php(43): Magento\Framework\ObjectManager\ObjectManager->create('Magento\\Store\\M...', Array) #14 C:\Program Files (x86)\EasyPHP-Devserver-16.1\eds-www\3footwear\vendor\magento\module-store\Model\Config\Reader\DefaultReader.php(62): Magento\Store\Model\ResourceModel\Config\Collection\ScopedFactory->create(Array) #15 C:\Program Files (x86)\EasyPHP-Devserver-16.1\eds-www\3footwear\vendor\magento\framework\App\Config\ScopePool.php(112): Magento\Store\Model\Config\Reader\DefaultReader->read() #16 C:\Program Files (x86)\EasyPHP-Devserver-16.1\eds-www\3footwear\vendor\magento\framework\App\Config.php(45): Magento\Framework\App\Config\ScopePool->getScope('default', NULL) #17 C:\Program Files (x86)\EasyPHP-Devserver-16.1\eds-www\3footwear\vendor\magento\framework\App\Config.php(58): Magento\Framework\App\Config->getValue('web/secure/use_...', 'default', NULL) #18 C:\Program Files (x86)\EasyPHP-Devserver-16.1\eds-www\3footwear\vendor\magento\module-store\Model\HeaderProvider\Hsts.php(48): Magento\Framework\App\Config->isSetFlag('web/secure/use_...') #19 C:\Program Files (x86)\EasyPHP-Devserver-16.1\eds-www\3footwear\vendor\magento\framework\App\Response\HeaderManager.php(41): Magento\Store\Model\HeaderProvider\Hsts->canApply() #20 C:\Program Files (x86)\EasyPHP-Devserver-16.1\eds-www\3footwear\vendor\magento\framework\Interception\Interceptor.php(123): Magento\Framework\App\Response\HeaderManager->beforeSendResponse(Object(Magento\Framework\App\Response\Http\Interceptor)) #21 C:\Program Files (x86)\EasyPHP-Devserver-16.1\eds-www\3footwear\var\generation\Magento\Framework\App\Response\Http\Interceptor.php(117): Magento\Framework\App\Response\Http\Interceptor->___callPlugins('sendResponse', Array, Array) #22 C:\Program Files (x86)\EasyPHP-Devserver-16.1\eds-www\3footwear\pub\errors\503.php(12): Magento\Framework\App\Response\Http\Interceptor->sendResponse() #23 C:\Program Files (x86)\EasyPHP-Devserver-16.1\eds-www\3footwear\vendor\magento\framework\App\Http.php(261): require('C:\\Program File...') #24 C:\Program Files (x86)\EasyPHP-Devserver-16.1\eds-www\3footwear\vendor\magento\framework\App\Http.php(157): Magento\Framework\App\Http->handleBootstrapErrors(Object(Magento\Framework\App\Bootstrap), Object(Exception)) #25 C:\Program Files (x86)\EasyPHP-Devserver-16.1\eds-www\3footwear\vendor\magento\framework\App\Bootstrap.php(263): Magento\Framework\App\Http->catchException(Object(Magento\Framework\App\Bootstrap), Object(Exception)) #26 C:\Program Files (x86)\EasyPHP-Devserver-16.1\eds-www\3footwear\index.php(39): Magento\Framework\App\Bootstrap->run(Object(Magento\Framework\App\Http)) #27 {main} [] []
Guest
October 29, 2019
0.5
Reply
Leave your comment

Your email address will not be published

This blog was created with Amasty Blog Pro

This blog was created with Amasty Blog Pro

© 2009-2024 Amasty. All Rights Reserved.