How Does PHP 7 and Magento Work?
Magento 2 is the updated version of world’s famous e-commerce framework Magento, It has various benefits as compared to its predecessor like easier site maintenance, better scalability and improved conversions. The most important improvements in respect to business point of view are the streamlined checkout and the much- enhanced Admin Panel. In Magento 2 performance is improved by implementing separate database for order processing which results in reduced amounts of code, increased browser rendering , better image compression and static content caching.
PHP7 is the updated version of PHP Scripting language. It introduced the zend Engine 3.0 which improve 2X performance and 50% better memory consumption than PHP 5.6 still its not officially released for production, so we suggest you to try this in your development environment not in the production environment.
Follow these steps to test Magento2 on PHP7.
Install LAMP stack on your server.
sudo apt–get install lamp–server^
Build Dependencies for php5.
sudo apt–get build–dep php5
Install missing packages required.
sudo apt–get install build–essential libt1–dev bison libbz2–dev libjpeg62–dev libpng12–dev libfreetype6–dev libgmp3–dev libmcrypt–dev libmysqlclient–dev libpspell–dev librecode–dev apache2–dev git
Symlink the gmp.h file into /usr/include/ so the makefile can find it.
ln –s /usr/include/x86_64–linux–gnu/gmp.h /usr/include/gmp.h
Install Mysql Server 5.6 Required for Magento 2
sudo apt–get install mysql–server–5.6
Download the php7.0.0 source code.
mv php–src–PHP–7.0.0 php7
Now run the builconf
Now we have to configure the php7 source code according to Magento 2 Requirements.
After configuring and testing the source code lets build the code .
Now force php to use new php, even replace the php5 binary with new php.
mv php5 php5.orig
mv phpize5 phpize5.orig
mv php–config5 php–config5.orig
ln –s php php5
ln –s phpize phpize5
ln –s php–config php–config5
We need a php7.conf file into our apache mods, its better to replace the php5.conf file.
cp /etc/apache2/mods–enabled/php5.conf /etc/apache2/mods–enabled/php7.conf
Disable php5 in apache, we can’t have php5 and php7 enabled after that restart the apache
Create a symlink by creating directory /etc/php7 with respect to /etc/php5
cd /etc/ && ln –s php5 php7
Now check the php version.
After this create a file phpinfo.php into the document root directory of apache and copy the following content into that file to check the version of php integrated with apache.
Note–: If you get the php version 7 in both version checks congratulations you are ready to install Magento 2 on php7.
Now Download Magento 2 and unzip the content into Apache document root directory /var/www/html/
Change the ownership of /var/www/html directory from root to www-data by following command
chown –R www–data:www–data /var/www/html/
change AllowOverride None to AllowOverride All in apache2.conf for Apache Document root directory.
Options Indexes FollowSymLinks
Require all granted
Now enable the rewrite module by following command.
Now hit the URL or IP of that Apache Server on your browser and follow the Instructions to successfully install Magento2