• Call: +1 (858) 429-9131

Archive for September, 2015

Install Magento2 in Nginx Server Using Command Line

Magento-2-Banner

 

Installing magento2 in Ubuntu 14.04 with Nginx web server.

Prerequisites:

 1.PHP:

Version 5.5.X or more

Required PHP extensions:

PDO/MySQL

mbstring

mcrypt

mhash

simplexml

curl

ext-xsl

gd2, ImageMagick 6.3.7 (or later) or both

soap

intl

2.Mysql 5.6.X

3.Nginx.

 Create basic nginx configuration file for magento2.

# vim /etc/nginx/sites-available/magantositename

Add the following configuration files in nginx,

 

##########################

server {

listen 80;

 root /var/www/magento2; #Use you mangeto2 location

index index.php index.html index.htm;

 server_name yuor_magento.siteurl;

#location / {

#try_files $uri $uri/ /index.php?q=$uri&$args;

#}

   location /setup {

       try_files $uri $uri/ @setuphandler;

   }

# Rewrite Setup’s Internal Requests

   location @setuphandler {

       rewrite /setup /setup/index.php;

   }

    location / {

       index index.php index.html;

       try_files $uri $uri/ @handler;

   }

    # Rewrite Internal Requests

    location @handler {

       rewrite / /index.php;

    }

     location /pub/static {

         try_files $uri $uri/ @static;

    }

     location @static {

          rewrite ^/pub/static/(.*)$ /pub/static.php?resource=$1? last;

    }

 error_page 404 /404.html;

 error_page 500 502 503 504 /50x.html;

location = /50x.html {

root /usr/share/nginx/www;

}

#pass the PHP scripts to f stcgi socket

location ~ \.php$ {

               try_files $uri =404;

               fastcgi_pass unix:/var/run/php5-fpm.sock;

               fastcgi_index index.php;

               fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;

               include fastcgi_params;

               fastcgi_read_timeout 900s;

#Magento 2 Developer Mode

               fastcgi_param MAGE_MODE “developer”;

      } 

}

 

#########################

 

create a symlink in /etc/nginx/sites-enable/magantositename

 # ln -s /etc/nginx/sites-available/magantositename /etc/nginx/sites-enable/magantositename

 

Restart PHP handler php5-fpm and nginx

 #  service php5-fpm restart

 # service nginx restart 

Create database and database user for magento2

login to mysql using root user and password:

#  mysql -u root -p

## mysql> CREATE DATABASE <magentodbname>;

## mysql>  GRANT ALL ON <magentodbname>.* FROM magentodb@localhost IDENTIFIED BY <magentodbpasswd>;

 

Steps to install Magento2

 Change the directory where to download and install Magento2.

 # cd /var/www/

 Download the magento2 zip file from github

 # wget https://github.com/magento/magento2/archive/develop.zip

 # unzip develop.zip

# mv magento2-develop magento2

 Change the ownership to your webserver user name. Typically it is www-data

 # chown -R www-data:www-data magento2

 # cd magento2

Change the permissions as follows,

 # find . -type d -exec chmod 700 {} \;

# find . -type f -exec chmod 600 {} \;

make the file magento file executable  in the directory bin

# chmod +x bin/magento

Install magento using command line,

# ./bin/magento setup:install –base-url “http://your_site_url/” –db-name “magentodbname” –db-user “magentodb” –db-password “magentodbpasswd” –admin-firstname “yourname” –admin-lastname “yourlastname” –admin-email “your_email” –admin-user “magenoadmi” –admin-password “magentoadminpasswd” –language “en_US” –currency “USD” –timezone “America/Chicago” –use-sample-data –use-rewrites=1

 

Here you will get your Language, Currency and Time zone using the following magento command.

Language:

# ./bim/magento info:language:list

Currency:

# ./bim/magento info:currency:list

Time Zone:

# ./bim/php magento info:timezone:list

 Once the installation is completed you will get the SUCCESS message at the end of installation.

You can access the magento admin interface using the random  generated URL while installing Magento2.

You can check the URL using magento command line.

# ./bin/magento info:adminuri

 You will get the admin URI as,

Admin URI: /admin_8mdvzn

You can  change the the Admin URI in <your Magento install dir>/app/etc/env.php.

Then you can access admin page as http://yuor_site_url/admin_8mdvzn/

 

magento-admin

 

You can access the magento2 home page at the installed URL as http://yuor_site_url.

It will look as below,

magento-2-home