Magento is the best eCommerce software and solution for online services. Recently Magento team has released its new version Magento2 with lots of improvements changes and optimizations over Magento1. This tutorial will help you to install Magento2 on Ubuntu, Debian, and Linux Mint systems.
Below are the system requirements for the Magento installation.
- Apache 2.2 or 2.4 with mod_rewrite module (or) Nginx >= 1.8.
- PHP 5.5 or later version. PHP 7.0 also supported.
- Required PHP-Modules – PDO/MySQL, mbstring, mcrypt, mhash, SimpleXML, curl, xsl, gd, ImageMagick 6.3.7 (or later) or both, soap, intl, openssl.
- Composer and Git
1. Install Requirements
You can use following commands to install all requirements from default repositories.
sudo apt install apache2 git mysql-server sudo apt install php libapache2-mod-php php-mysql php-dom php-simplexml php-gd php-soap sudo apt install php-curl php-intl php-xsl php-mbstring php-zip php-xml php-mcrypt
Also install PHP composer on your system.
curl -sS https://getcomposer.org/installer | php mv composer.phar /usr/local/bin/composer chmod +x /usr/local/bin/composer
2. Setup Magento2
Magento2 code is available under the Github repository. Use the following command to clone the Magento2 repository on your system using git.
git clone https://github.com/magento/magento2.git
Now install all required modules for Magento2 using composer. Wait for the installation process completed.
cd magento2/ composer install
Now set the permissions on files and directories.
sudo chmod -R 755 /var/www/magento2/ sudo chmod -R 777 /var/www/magento2/{pub,var}
3. Create Database
Now login to your MySQL server with admin privileges and create a database and user for new magento2 installation.
mysql -u root -p mysql> CREATE DATABASE magento2_db; mysql> GRANT ALL ON magento2_db.* TO magento2_usr@'localhost' IDENTIFIED BY 'password'; mysql> FLUSH PRIVILEGES; mysql> quit
4. Configure Apache VirtualHost
Create Apache configuration file for your Magento website like /etc/apache2/sites-available/magento2.example.com.conf and add following content.
<VirtualHost *:80> DocumentRoot /var/www/magento2 ServerName magento2.example.com <Directory /var/www/magento2> Allowoverride all </Directory> </VirtualHost>
Now enable virtualhost using following command.
sudo a2ensite magento2.example.com
Also make sure to enable the Apache rewrite module, which is recommended by Magento.
sudo a2enmod rewrite
After doing all the above changes, make sure to restart the Apache server.
sudo systemctl restart apache2.service
5. Start Web Installer
Let’s begin the installation of Magento2 using a web installer. Access your magento2 directory on a web browser like below. It will redirect you to the installation page.
http://magento2.example.com/
On the first step agree with the License agreement and click on “Agree and Setup Magento”.
On Step 1 click on “Start Readiness Test”. Magento will check for system requirements here. On successful completion, you will see a screen like below then Just click Next. Fix issues if shows on this screen and click Try again.
Now follow the wizard steps 2, 3, 4, 5, 6 and on successful installation, you will get a screen like below.
Now login to your admin panel using created admin credentials in the above steps.
Congratulation! You have successfully deployed Magento2 on your system.
6. Schedule Magento2 Cronjobs
Finally schedule the backgound cronjobs for your magento2 installation. These cronjobs does some activities like, re-indexing, Newsletters, Update of currency rates, sending automatic emails and generating sitemaps etc. To schedule these jobs edit crontab file
crontab -e
and add following cronjobs at the end of file and save it.
*/1 * * * * www-data php /var/www/magento2/bin/magento cron:run */1 * * * * www-data php /var/www/magento2/update/cron.php */1 * * * * www-data php /var/www/magento2/bin/magento setup:cron:run
Here www-data is the user under which Apache is running and /var/www/html/magento2/ is the location of your Magento2 applications.
2 Comments
PHP soap is missing from the setup.
Use apt-get install php7.0-soap to install missing packet
I have tried to install Magento 2.1.5 on ubuntu 16.04 Lts on my own server and its the worst experience ever. i need a step by step manual to figure out what we are doing wrong because when we try an insatll any extension te whole sytem just freezes and we have to start over