{"id":659,"date":"2016-09-14T07:34:10","date_gmt":"2016-09-14T07:34:10","guid":{"rendered":"https:\/\/blog.ngocha.biz\/?p=659"},"modified":"2016-09-14T07:34:10","modified_gmt":"2016-09-14T07:34:10","slug":"setup-and-configure-latest-magento-2-on-linux-ec2","status":"publish","type":"post","link":"https:\/\/blog.ngocha.biz\/?p=659","title":{"rendered":"Title: How To Setup and Configure Latest Magento 2.x On Linux EC2"},"content":{"rendered":"<p>This guide explains the steps to install and configure latest Magento 2.x on a Linux ec2 cloud server or a VPS. We will be doing the following.<\/p>\n<ol>\n<li>Setting up LAMP Stack (Mysql version 5.6 or later)<\/li>\n<li>Setting up Database and user (CLI and PHPMyAdmin)<\/li>\n<li>Setting up Magento 2.0 using composer.<\/li>\n<\/ol>\n<p>I am using an Ubuntu 14.04 LTS server from Amazon ec2. This tutorial will work on any cloud or VPS having a Ubuntu server.<\/p>\n<h3 id=\"setup-lamp-stack\">Setup LAMP Stack<\/h3>\n<p>1. Update the Server<\/p>\n<pre><code>sudo apt-get update -y<\/code><\/pre>\n<p>2. Install apache<\/p>\n<pre><code>sudo apt-get install apache2<\/code><\/pre>\n<p>3. Install MySQL server and the PHP module for MySQL. During installation, MySQL would prompt for the password for the root user. Set a strong password.<\/p>\n<pre><code>sudo apt-get install mysql-server-5.6 php5-mysql<\/code><\/pre>\n<p>4. Create MySQL database directory using the following command.<\/p>\n<pre><code>sudo mysql_install_db<\/code><\/pre>\n<p>5. Run the MySQL secure installation command.<\/p>\n<pre><code>sudo mysql_secure_installation<\/code><\/pre>\n<p>The above command would prompt for the root password. Enter the root password and proceed with the options given in the output below.<\/p>\n<pre><code>Enter current password for root (enter for none):\n\nChange the root password? [Y\/n] n\n ... skipping.\n\nRemove anonymous users? [Y\/n] y\n ... Success!\n\nDisallow root login remotely? [Y\/n] y\n ... Success!\n\nRemove test database and access to it? [Y\/n] y\n\nReload privilege tables now? [Y\/n] y\n ... Success!<\/code><\/pre>\n<p>6. Install PHP.<\/p>\n<pre><code>sudo apt-get install php5 libapache2-mod-php5 php5-mcrypt<\/code><\/pre>\n<p>7. Open \/etc\/apache2\/mods-enabled\/dir.conf file using vi or nano editor.<\/p>\n<pre><code> sudo vi \/etc\/apache2\/mods-enabled\/dir.conf<\/code><\/pre>\n<p>The file would look like the following.<\/p>\n<pre><code>DirectoryIndex index.html index.cgi index.pl index.php index.xhtml index.htm<\/code><\/pre>\n<p>Move index.php to first so that the file would look like the following.<\/p>\n<pre><code>DirectoryIndex index.php index.html index.cgi index.pl i index.xhtml index.htm<\/code><\/pre>\n<p>8. Restart apache server.<\/p>\n<pre><code>sudo service apache2 restart\n<\/code><\/pre>\n<p>9. To know all the PHP details, create a file named info.php<\/p>\n<pre><code>sudo vi \/var\/www\/html\/info.php<\/code><\/pre>\n<p>Copy the following contents on the info.php file.<\/p>\n<pre><code>&lt;?php\nphpinfo();\n?&gt;<\/code><\/pre>\n<p>Now, if you browse to http:\/\/&lt;Server-IP&gt;\/php.info, you will be able to see all the PHP configuration details.<\/p>\n<h3 id=\"install-and-configure-phpmyadmin\">Install and Configure PhpMyAdmin<\/h3>\n<p>PhpMyAdmin is a great utility for managing databases through GUI. Follow the steps carefully for setting up PhpMyAdmin.<\/p>\n<p>1. Install PhpMyAdmin<\/p>\n<pre><code>sudo apt-get install phpmyadmin -y<\/code><\/pre>\n<p>When it prompts for web server, press space bar and select apache2 and press enter. For Configure database for PHPMyAdmin, press enter. Password of the database&#8217;s administrative user, enter the root password for MySQL that you created during MySQL installation. Enter the same password for confirmation.<\/p>\n<p>2. Enable PHP mcrypt module.<\/p>\n<pre><code>sudo php5enmod mcrypt<\/code><\/pre>\n<p>3. Restart the web server.<\/p>\n<pre><code>sudo service apache2 restart<\/code><\/pre>\n<p>Now you can access the PhpMyAdmin Web UI by visiting the ec2 public IP address followed by PHPMyAdmin as shown below.<\/p>\n<pre><code>http:\/\/&lt;server-IP&gt;phpmyadmin<\/code><\/pre>\n<p>You can use the MySQL root credentials to log in to PHPMyAdmin account.<\/p>\n<h3 id=\"create-magento-user-and-database\">Create Magento User and Database<\/h3>\n<p>You can create MySQL user and Database using the command line as well through PhpMyAdmin. Using PHPMyAdmin is self-explanatory. If you want to use the command line for creating the user and database, you can follow the steps given below.<\/p>\n<ol>\n<li>Sign into MySQL client using the root user and password.<\/li>\n<\/ol>\n<pre><code>mysql -u root -p<\/code><\/pre>\n<p><!--kg-card-begin: html--><\/p>\n<ol start=\"2\">\n<li>Create database Magento.<\/li>\n<\/ol>\n<p><!--kg-card-end: html--><\/p>\n<pre><code>CREATE DATABASE magento;<\/code><\/pre>\n<p><!--kg-card-begin: html--><\/p>\n<ol start=\"3\">\n<li>Create a magento_admin with a strong password. Replace &#8220;password&#8221; with your strong password.<\/li>\n<\/ol>\n<p><!--kg-card-end: html--><\/p>\n<pre><code>CREATE USER magento_admin@localhost IDENTIFIED BY 'password';<\/code><\/pre>\n<p><!--kg-card-begin: html--><\/p>\n<ol start=\"4\">\n<li>Grant all privileges to magento_admin for Magento database. Replace password accordingly.<\/li>\n<\/ol>\n<p><!--kg-card-end: html--><\/p>\n<pre><code>GRANT ALL PRIVILEGES ON magento.* TO magento_admin@localhost IDENTIFIED BY 'password';<\/code><\/pre>\n<p><!--kg-card-begin: html--><\/p>\n<ol start=\"5\">\n<li>Flush all the privileges and exit the MySQL CLI.<\/li>\n<\/ol>\n<p><!--kg-card-end: html--><\/p>\n<pre><code>FLUSH PRIVILEGES; exit<\/code><\/pre>\n<h2 id=\"setting-up-magento\">Setting up Magento<\/h2>\n<p>In this section, we will configure Magento using LAMP stack. Follow the steps carefully.<\/p>\n<ol>\n<li>Create a file called magento.conf in the apache sites available folder.<\/li>\n<\/ol>\n<pre><code>sudo vi \/etc\/apache2\/sites-available\/magento.conf<\/code><\/pre>\n<p>Copy the following content on the file.<\/p>\n<pre><code>&lt;VirtualHost *:80&gt;\n DocumentRoot \/var\/www\/html\n &lt;Directory \/var\/www\/html\/&gt;\n Options Indexes FollowSymLinks MultiViews\n AllowOverride All\n &lt;\/Directory&gt;\n&lt;\/VirtualHost&gt;<\/code><\/pre>\n<p><!--kg-card-begin: html--><\/p>\n<ol start=\"2\">\n<li>Enable our new conf and disable the default conf using the following commands.<\/li>\n<\/ol>\n<p><!--kg-card-end: html--><\/p>\n<pre><code>sudo a2ensite magento.conf\nsudo a2dissite 000-default.conf<\/code><\/pre>\n<p><!--kg-card-begin: html--><\/p>\n<ol start=\"3\">\n<li>Reload the apache service.<\/li>\n<\/ol>\n<p><!--kg-card-end: html--><\/p>\n<pre><code>sudo service apache2 reload<\/code><\/pre>\n<p><!--kg-card-begin: html--><\/p>\n<ol start=\"4\">\n<li>Open php.ini file to increase the memory_limit parameter to 512M (default 128M).<\/li>\n<\/ol>\n<p><!--kg-card-end: html--><\/p>\n<pre><code>sudo vi \/etc\/php5\/apache2\/php.ini<\/code><\/pre>\n<p>Find memory_limit parameter and set it to 512M and save the file.<\/p>\n<pre><code>memory_limit = 512M<\/code><\/pre>\n<p><!--kg-card-begin: html--><\/p>\n<ol start=\"5\">\n<li>Install required PHP modules for Magento.<\/li>\n<\/ol>\n<p><!--kg-card-end: html--><\/p>\n<pre><code>sudo apt-get -y install libcurl3 php5-curl php5-gd php5-mcrypt php5-intl php5-xsl<\/code><\/pre>\n<p><!--kg-card-begin: html--><\/p>\n<ol start=\"6\">\n<li>Enable rewrite, mcrypt module and restart the apache server.<\/li>\n<\/ol>\n<p><!--kg-card-end: html--><\/p>\n<pre><code>sudo a2enmod rewrite sudo php5enmod mcrypt sudo service apache2 restart<\/code><\/pre>\n<h3 id=\"setup-magento-2x\">Setup Magento 2.X<\/h3>\n<ol>\n<li>Install Composer. <\/li>\n<\/ol>\n<pre><code>curl -sS https:\/\/getcomposer.org\/installer | sudo php \u2013 --install-dir=\/usr\/local\/bin --filename=composer<\/code><\/pre>\n<ol start=\"2\">\n<li>Create a Magento marketplace account and get public and private access keys from your account. Refer <a href=\"http:\/\/devdocs.magento.com\/guides\/v2.0\/install-gde\/prereq\/connect-auth.html?ref=devopscube.com\">this link<\/a> for getting the public and private keys<\/li>\n<\/ol>\n<p><!--kg-card-begin: html--><\/p>\n<ol start=\"3\">\n<li>Create an auth.json file<\/li>\n<\/ol>\n<p><!--kg-card-end: html--><\/p>\n<pre><code>sudo vi \/root\/.composer\/auth.json<\/code><\/pre>\n<p>Copy the following content on to the file with your public and private key.<\/p>\n<pre><code>{\n\"http-basic\": {\n      \"repo.magento.com\": {\n         \"username\": \"edd45269f04a6ca51cbbbed2fedab26b\",\n         \"password\": \"ef88687a5cf5d109c5540ff401b0b903\"\n      }\n   }\n}<\/code><\/pre>\n<p><!--kg-card-begin: html--><\/p>\n<ol start=\"4\">\n<li>Get the latest Magento binaries using git.<\/li>\n<\/ol>\n<p><!--kg-card-end: html--><\/p>\n<p>If you don&#8217;t have git installed, install it using the following command.<\/p>\n<pre><code>sudo apt-get install git -y<\/code><\/pre>\n<p>Clone the magento2 community version code to Magento directory.<\/p>\n<pre><code>git clone -b 2.0 https:\/\/github.com\/magento\/magento2.git magento<\/code><\/pre>\n<p><!--kg-card-begin: html--><\/p>\n<ol start=\"5\">\n<li>Copy all files to \/var\/www\/html directory using rysync.<\/li>\n<\/ol>\n<p><!--kg-card-end: html--><\/p>\n<pre><code>sudo rsync -avP magento\/. \/var\/www\/html\/<\/code><\/pre>\n<p><!--kg-card-begin: html--><\/p>\n<ol start=\"6\">\n<li>CD into \/var\/www\/html folder and install all the required Magento modules using composer.<\/li>\n<\/ol>\n<p><!--kg-card-end: html--><\/p>\n<pre><code>cd \/var\/www\/html composer install<\/code><\/pre>\n<p><!--kg-card-begin: html--><\/p>\n<ol start=\"7\">\n<li>Change the owner of \/var\/www\/html to www-data.<\/li>\n<\/ol>\n<p><!--kg-card-end: html--><\/p>\n<pre><code>sudo chown -R www-data:www-data \/var\/www\/html\/<\/code><\/pre>\n<p><!--kg-card-begin: html--><\/p>\n<ol start=\"8\">\n<li>Visit the public IP of your server. You will see the Magento setup page as shown below.<\/li>\n<\/ol>\n<p><!--kg-card-end: html--><\/p>\n<figure class=\"kg-card kg-image-card\"><img decoding=\"async\" src=\"https:\/\/storage.ghost.io\/c\/5f\/2f\/5f2f4d20-2abf-4534-8d40-7aa233aedd43\/content\/images\/2025\/03\/magento-setup-ec2-1.jpg\" class=\"kg-image\" alt=\"magento initial setup\" loading=\"lazy\" width=\"1524\" height=\"882\" srcset=\"https:\/\/storage.ghost.io\/c\/5f\/2f\/5f2f4d20-2abf-4534-8d40-7aa233aedd43\/content\/images\/size\/w600\/2025\/03\/magento-setup-ec2-1.jpg 600w, https:\/\/storage.ghost.io\/c\/5f\/2f\/5f2f4d20-2abf-4534-8d40-7aa233aedd43\/content\/images\/size\/w1000\/2025\/03\/magento-setup-ec2-1.jpg 1000w, https:\/\/storage.ghost.io\/c\/5f\/2f\/5f2f4d20-2abf-4534-8d40-7aa233aedd43\/content\/images\/2025\/03\/magento-setup-ec2-1.jpg 1524w\" sizes=\"auto, (min-width: 720px) 720px\"><\/figure>\n<p><!--kg-card-begin: html--><\/p>\n<ol start=\"9\">\n<li>Click agree and setup. Click next for database settings.<\/li>\n<\/ol>\n<p><!--kg-card-end: html--><\/p>\n<figure class=\"kg-card kg-image-card\"><img decoding=\"async\" src=\"https:\/\/storage.ghost.io\/c\/5f\/2f\/5f2f4d20-2abf-4534-8d40-7aa233aedd43\/content\/images\/2025\/03\/screen-shot-2016-09-13-at-8-54-08-pm_mini-1.jpg\" class=\"kg-image\" alt=\"magento 2 initial setup\" loading=\"lazy\" width=\"2000\" height=\"782\" srcset=\"https:\/\/storage.ghost.io\/c\/5f\/2f\/5f2f4d20-2abf-4534-8d40-7aa233aedd43\/content\/images\/size\/w600\/2025\/03\/screen-shot-2016-09-13-at-8-54-08-pm_mini-1.jpg 600w, https:\/\/storage.ghost.io\/c\/5f\/2f\/5f2f4d20-2abf-4534-8d40-7aa233aedd43\/content\/images\/size\/w1000\/2025\/03\/screen-shot-2016-09-13-at-8-54-08-pm_mini-1.jpg 1000w, https:\/\/storage.ghost.io\/c\/5f\/2f\/5f2f4d20-2abf-4534-8d40-7aa233aedd43\/content\/images\/size\/w1600\/2025\/03\/screen-shot-2016-09-13-at-8-54-08-pm_mini-1.jpg 1600w, https:\/\/storage.ghost.io\/c\/5f\/2f\/5f2f4d20-2abf-4534-8d40-7aa233aedd43\/content\/images\/2025\/03\/screen-shot-2016-09-13-at-8-54-08-pm_mini-1.jpg 2010w\" sizes=\"auto, (min-width: 720px) 720px\"><\/figure>\n<p><!--kg-card-begin: html--><\/p>\n<ol start=\"10\">\n<li>Enter the database username , password and database name you have created under MySQL configuration as shown below. Click next after entering the details.<\/li>\n<\/ol>\n<p><!--kg-card-end: html--><\/p>\n<figure class=\"kg-card kg-image-card\"><img decoding=\"async\" src=\"https:\/\/storage.ghost.io\/c\/5f\/2f\/5f2f4d20-2abf-4534-8d40-7aa233aedd43\/content\/images\/2025\/03\/screen-shot-2016-09-13-at-8-57-42-pm_mini-1.jpg\" class=\"kg-image\" alt=\"magento database configuration\" loading=\"lazy\" width=\"1994\" height=\"1114\" srcset=\"https:\/\/storage.ghost.io\/c\/5f\/2f\/5f2f4d20-2abf-4534-8d40-7aa233aedd43\/content\/images\/size\/w600\/2025\/03\/screen-shot-2016-09-13-at-8-57-42-pm_mini-1.jpg 600w, https:\/\/storage.ghost.io\/c\/5f\/2f\/5f2f4d20-2abf-4534-8d40-7aa233aedd43\/content\/images\/size\/w1000\/2025\/03\/screen-shot-2016-09-13-at-8-57-42-pm_mini-1.jpg 1000w, https:\/\/storage.ghost.io\/c\/5f\/2f\/5f2f4d20-2abf-4534-8d40-7aa233aedd43\/content\/images\/size\/w1600\/2025\/03\/screen-shot-2016-09-13-at-8-57-42-pm_mini-1.jpg 1600w, https:\/\/storage.ghost.io\/c\/5f\/2f\/5f2f4d20-2abf-4534-8d40-7aa233aedd43\/content\/images\/2025\/03\/screen-shot-2016-09-13-at-8-57-42-pm_mini-1.jpg 1994w\" sizes=\"auto, (min-width: 720px) 720px\"><\/figure>\n<p><!--kg-card-begin: html--><\/p>\n<ol start=\"11\">\n<li>Next page, you can see the store and admin page address. You can customize the admin age path. If you have a domain name, you can map the domain name to the IP address.<\/li>\n<\/ol>\n<p><!--kg-card-end: html--><\/p>\n<figure class=\"kg-card kg-image-card\"><img decoding=\"async\" src=\"https:\/\/storage.ghost.io\/c\/5f\/2f\/5f2f4d20-2abf-4534-8d40-7aa233aedd43\/content\/images\/2025\/03\/screen-shot-2016-09-13-at-9-37-19-pm_mini-1.jpg\" class=\"kg-image\" alt=\"magento 2 admin url confirations\" loading=\"lazy\" width=\"2000\" height=\"900\" srcset=\"https:\/\/storage.ghost.io\/c\/5f\/2f\/5f2f4d20-2abf-4534-8d40-7aa233aedd43\/content\/images\/size\/w600\/2025\/03\/screen-shot-2016-09-13-at-9-37-19-pm_mini-1.jpg 600w, https:\/\/storage.ghost.io\/c\/5f\/2f\/5f2f4d20-2abf-4534-8d40-7aa233aedd43\/content\/images\/size\/w1000\/2025\/03\/screen-shot-2016-09-13-at-9-37-19-pm_mini-1.jpg 1000w, https:\/\/storage.ghost.io\/c\/5f\/2f\/5f2f4d20-2abf-4534-8d40-7aa233aedd43\/content\/images\/size\/w1600\/2025\/03\/screen-shot-2016-09-13-at-9-37-19-pm_mini-1.jpg 1600w, https:\/\/storage.ghost.io\/c\/5f\/2f\/5f2f4d20-2abf-4534-8d40-7aa233aedd43\/content\/images\/2025\/03\/screen-shot-2016-09-13-at-9-37-19-pm_mini-1.jpg 2048w\" sizes=\"auto, (min-width: 720px) 720px\"><\/figure>\n<p>From this point, you can click next and fill in the details. In the last page, click &#8220;Install&#8221; option. Once installed, you will get all the details of your Magento site as shown below.<\/p>\n<figure class=\"kg-card kg-image-card\"><img decoding=\"async\" src=\"https:\/\/storage.ghost.io\/c\/5f\/2f\/5f2f4d20-2abf-4534-8d40-7aa233aedd43\/content\/images\/2025\/03\/screen-shot-2016-09-13-at-9-45-15-pm_mini.jpg\" class=\"kg-image\" alt=\"magento final installtion\" loading=\"lazy\" width=\"1924\" height=\"1408\" srcset=\"https:\/\/storage.ghost.io\/c\/5f\/2f\/5f2f4d20-2abf-4534-8d40-7aa233aedd43\/content\/images\/size\/w600\/2025\/03\/screen-shot-2016-09-13-at-9-45-15-pm_mini.jpg 600w, https:\/\/storage.ghost.io\/c\/5f\/2f\/5f2f4d20-2abf-4534-8d40-7aa233aedd43\/content\/images\/size\/w1000\/2025\/03\/screen-shot-2016-09-13-at-9-45-15-pm_mini.jpg 1000w, https:\/\/storage.ghost.io\/c\/5f\/2f\/5f2f4d20-2abf-4534-8d40-7aa233aedd43\/content\/images\/size\/w1600\/2025\/03\/screen-shot-2016-09-13-at-9-45-15-pm_mini.jpg 1600w, https:\/\/storage.ghost.io\/c\/5f\/2f\/5f2f4d20-2abf-4534-8d40-7aa233aedd43\/content\/images\/2025\/03\/screen-shot-2016-09-13-at-9-45-15-pm_mini.jpg 1924w\" sizes=\"auto, (min-width: 720px) 720px\"><\/figure>\n<hr>\n<p><strong>Ngu\u1ed3n:<\/strong> <a href=\"https:\/\/devopscube.com\/setup-and-configure-latest-magento-2-on-linux-ec2\/\" target=\"_blank\" rel=\"noopener noreferrer\">Title: How To Setup and Configure Latest Magento 2.x On Linux EC2 \u2014 DevOpsCube<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>Source: https:\/\/devopscube.com\/setup-and-configure-latest-magento-2-on-linux-ec2\/<\/p>\n","protected":false},"author":1,"featured_media":660,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[],"class_list":["post-659","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-devops"],"_links":{"self":[{"href":"https:\/\/blog.ngocha.biz\/index.php?rest_route=\/wp\/v2\/posts\/659","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/blog.ngocha.biz\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/blog.ngocha.biz\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/blog.ngocha.biz\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/blog.ngocha.biz\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=659"}],"version-history":[{"count":0,"href":"https:\/\/blog.ngocha.biz\/index.php?rest_route=\/wp\/v2\/posts\/659\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/blog.ngocha.biz\/index.php?rest_route=\/wp\/v2\/media\/660"}],"wp:attachment":[{"href":"https:\/\/blog.ngocha.biz\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=659"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/blog.ngocha.biz\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=659"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/blog.ngocha.biz\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=659"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}