Drop Down MenusCSS Drop Down MenuPure CSS Dropdown Menu

Saturday, 18 March 2017

How To Configure Magento2 with Nginx on Ubuntu 14.04

How To Configure Magento2 with Nginx on Ubuntu 14.04


Q. What is Magento :

-- Magento is an e-commerce platform built on open source technology which provides online merchants with a flexible shopping cart system, as well as control over the look, content and functionality of their online store. Magento offers powerful marketing, search engine optimization, and catalog-management tools.

Step: 1. Set Host Name :

# hostname magento.domain.com
# vi /etc/hostname

magento.domain.com

-- Save & Quit (:wq)

Step: 2. Bind Hosts File :

# vi /etc/hosts

10.100.97.37    magento.domain.com        magento

-- Save & Quit (:wq)

Step: 3. Update the System :

# apt-get update
# apt-get -y upgrade

Step: 4. Install NTP Server For Time Synchronization :

# apt-get -y install ntp ntpdate
# service ntp restart
# ntpdate pool.ntp.org
# date

Step: 5. Install Nginx Server :

# apt-get -y install nginx

-- Verify that Nginx has been Installed Properly by Checking the Port :

# netstat -plntu | grep 80

Step: 6. Install PHP7 with PHP7-FPM :

# apt-get -y install language-pack-en-base
# LC_ALL=en_US.UTF-8 add-apt-repository ppa:ondrej/php
# apt-get update

# apt-get -y install php7.0 php7.0-fpm php7.0-mcrypt php7.0-curl php7.0-cli php7.0-mysql \
    php7.0-gd php7.0-xsl php7.0-json php7.0-intl php7.0-dev php7.0-common php7.0-mbstring \
    php7.0-zip php-pear php-soap libcurl3 curl wget

Step: 7. Modify PHP Settings For Magento :

# vi /etc/php/7.0/fpm/php.ini

memory_limit = 512M
max_execution_time = 1800
zlib.output_compression = On

-- Save & Quit (:wq)

# vi /etc/php/7.0/cli/php.ini

memory_limit = 512M
max_execution_time = 1800
zlib.output_compression = On

-- Save & Quit (:wq)

Step: 8. Restart the PHP7-FPM Service to Apply the Configuration Changes :
 
# service php7.0-fpm restart

Step: 9. Install MySQL Server :

# apt-get -y install mysql-server-5.6 mysql-client-5.6

New password for the MariaDB "root" user: redhat
Repeat password for the MariaDB "root" user: redhat

Step: 10. Create Database & DB User for Magento :

# mysql -u root -p
Enter the Password:

mysql> create database magentodb;
mysql> grant all privileges on magentodb.* to magento@localhost identified by 'password';
mysql> flush privileges;
mysql> \q

Step: 11. Install PHP Composer :

# cd ~/
# curl -sS https://getcomposer.org/installer | php
# mv composer.phar /usr/bin/composer

-- Now Verify that Composer Command is Working :

# composer -v

Step: 12. Download & Extract Magento 2 :

# mkdir /var/www/
# cd /var/www/
# wget https://github.com/magento/magento2/archive/2.0.7.tar.gz
# tar -zxvf 2.0.7.tar.gz
# mv magento2-2.0.7 magento2

Step: 13. Configure the Magento Key :

At 1st Register A Magento Account. Click on Below Link :

http://repo.magento.com/

-- Create An Account.
-- After Created the Account & Click on "My Account"
-- Click on "Developers"
-- Click on "Secure Keys"
-- Give A Name & Click on "Generate New". (It will Generate Random Public & Private Keys).

Step: 14. Install Third-Party Components for Magento :

# cd /var/www/magento2/
# composer install -v

Authentication required (repo.magento.com):
Username: 65500dc62bc7a48f09c36056df12bf03 (Use Public Key For User Name)
Password: 528d7b92a879cb673f18940322312e10 (Use Private Key For User Password)
     
-- Do you want to store credentials for repo.magento.com in /root/.config/composer/auth.json ?
     [Yn] Type "Y" & Press "Enter"

Step: 15. Configure the Nginx Virtualhost :

# vi /etc/nginx/sites-available/magento

-- Paste the below Configuration :

upstream fastcgi_backend {
        server  unix:/run/php/php7.0-fpm.sock;
}

server {

        listen 80;
        server_name magento.domain.com;
        set $MAGE_ROOT /var/www/magento2;
        set $MAGE_MODE developer;
        include /var/www/magento2/nginx.conf.sample;
}

-- Save & Quit (:wq)

# ln -s /etc/nginx/sites-available/magento /etc/nginx/sites-enabled/
# service nginx restart

Step: 16. Install Magento Through Command Line :

# cd /var/www/magento2
# bin/magento setup:install --backend-frontname="adminlogin" \
--key="65500dc62bc7a48f09c36056df12bf03" \
--db-host="localhost" \
--db-name="magentodb" \
--db-user="magento" \
--db-password="password" \
--language="en_US" \
--currency="INR" \
--timezone="Asia/Kolkata" \
--use-rewrites=1 \
--use-secure=0 \
--base-url="http://magento.domain.com" \
--base-url-secure="https://magento.domain.com" \
--admin-user=admin \
--admin-password=Passw0rd \
--admin-email=admin@domain.com \
--admin-firstname=Koushik \
--admin-lastname=Chatterjee \
--cleanup-database

IMPORTANT Note:

backend-frontname: The admin page for our magento site, we use 'adminlogin'.
Key: Magento Keys, we can generate it, or find it random on http://randomkeygen.com/.
Base-url: Make sure it is same with Virtualhost Configuration.

Step: 17. Set Appropriate Permission for Magento :

# cd /var/www/magento2/
# chmod 700 /var/www/magento2/app/etc
# chown -Rf www-data:www-data .

Step: 18. Restart the Nginx Server :

# service nginx restart

Step: 19. Access the Site & Admin Panel :

http://magento.domain.com

-- For Admin Access :

http://magento.oit.com/adminlogin
User: admin
Pass: Passw0rd

Note: If You get an Error about a Missing Magento indexer Cronjob, then you can Solve it by adding the Following Cronjob to Your Server.

# crontab -u www-data -e

-- Add the Following Lines:

* * * * * /usr/bin/php /var/www/magento2/bin/magento cron:run | grep -v "Ran jobs by schedule" >> /var/www/magento2/var/log/magento.cron.log
* * * * * /usr/bin/php /var/www/magento2/update/cron.php >> /var/www/magento2/var/log/update.cron.log
* * * * * /usr/bin/php /var/www/magento2/bin/magento setup:cron:run >> /var/www/magento2/var/log/setup.cron.log

-- Save & Quit (:wq)

# service cron restart

Thanks For Visiting on My Blog, For More Tutorials Keep Visiting My Blog


3 comments:

  1. Submit your blog or website now for inclusion in Google and 300+ search engines!

    Over 200,000 websites indexed!

    Submit NOW using I Need Hits!!!

    ReplyDelete
  2. Brilliant tutorial! everything went without dramas. After completing step 18, I was not able to access http://magento.domain.com and terminal showed the following Error message 'sudo: unable to resolve host '. This was fixed by running:

    #echo $(hostname -I | cut -d\ -f1) $(hostname) | sudo tee -a /etc/hosts

    ReplyDelete
  3. Hi.I just install magento2-2.0.7 with php 7.0.31 ,mysql 5.6.33 in nginx web server with ubuntu platform.After the step of 14 Install Third-Party Components for Magento. I am not getting the authentication required as shown in this blog.
    What could be the cause for this?

    ReplyDelete

Copyright © 2016 Kousik Chatterjee's Blog