{"id":121,"date":"2018-06-15T12:10:39","date_gmt":"2018-06-15T12:10:39","guid":{"rendered":"https:\/\/meetanshi.com\/blog\/2018\/06\/15\/install-magento-2\/"},"modified":"2025-07-15T17:33:42","modified_gmt":"2025-07-15T12:03:42","slug":"install-magento-2","status":"publish","type":"post","link":"https:\/\/meetanshi.com\/blog\/install-magento-2\/","title":{"rendered":"How to Install Magento 2"},"content":{"rendered":"\n<p class=\"wp-block-paragraph\">If you are visiting this post that means you are on the stepping stone in E-commerce world! And, you have made the right choice to select&nbsp;<a href=\"https:\/\/meetanshi.com\/blog\/what-is-magento\/\" target=\"_blank\" rel=\"noreferrer noopener\">Magento 2<\/a>&nbsp;as the platform. I\u2019ll guide you through the installation process of Magento 2.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Make sure you fulfill some basic&nbsp;<a href=\"https:\/\/meetanshi.com\/blog\/magento-2-system-requirements\/\" target=\"_blank\" rel=\"noreferrer noopener\">Magento 2.x&nbsp;system requirements<\/a>&nbsp;prior to installing Magento 2. You can also&nbsp;<a href=\"https:\/\/meetanshi.com\/blog\/install-magento-2-4-via-command-line\/\" target=\"_blank\" rel=\"noreferrer noopener\">install Magento 2 via command line<\/a>.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">There are three ways to install Magento 2:<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">1. Install Magento 2 from the Archive File<\/h2>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Visit the&nbsp;<a href=\"https:\/\/meetanshi.com\/blog\/download-magento\/\" target=\"_blank\" rel=\"noreferrer noopener\">Magento Download Page<\/a>. Download the latest Magento 2 package from any of the archive types (zip, tar.gz, tar.bz2), with or without sample data.<\/li>\n\n\n\n<li>Now upload the zip file to the server and extract it to Magento root directory.<\/li>\n\n\n\n<li>For shared hosting users, you can unzip or extract the package.<\/li>\n\n\n\n<li>For the local server, follow the commands below:<\/li>\n<\/ul>\n\n\n\n<pre class=\"wp-block-code\"><code># File .tar.gz\t\ntar zxf <filename>\n\n# File .zip\nunzip <\/filename><\/code><\/pre>\n\n\n\n<ul class=\"wp-block-list\">\n<li>&nbsp;Run below command to add write permission for&nbsp;var, app\/etc, pub folders.<\/li>\n<\/ul>\n\n\n\n<pre class=\"wp-block-code\"><code>chmod 777 -R var\nchmod 777 -R app\/etc\nchmod 777 -R pub<\/code><\/pre>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Now run Magento setup wizard and finish installation process.<\/li>\n<\/ul>\n\n\n\n<h2 class=\"wp-block-heading\">2. Install Magento 2 via composer<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">A composer is a tool for dependency management in PHP. To learn more about the composer, visit&nbsp;<a href=\"https:\/\/getcomposer.org\/doc\/00-intro.md\" target=\"_blank\" rel=\"noreferrer noopener\">https:\/\/getcomposer.org\/doc\/00-intro.md<\/a><\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Similar to above method,&nbsp;Magento core code is stored under&nbsp;<strong>\/vendor<\/strong>&nbsp;directory and updating is possible through Magento admin.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Collect your authentication keys from&nbsp;<a href=\"https:\/\/account.magento.com\/applications\/customer\/login\/?client_id=10906dd964b2dcc6befafab4f567ce6b&amp;redirect_uri=https%3A%2F%2Fcommercemarketplace.adobe.com%2Fsso%2Faccount%2FoauthCallback%2F&amp;response_type=code&amp;scope=adobe_profile&amp;state=55011d65c95c04e2f66bb3d7bcbee8ec\" target=\"_blank\" rel=\"noreferrer noopener\">here<\/a>. Navigate to \u201cMy Access Keys\u201d, enter a descriptive \u201cName\u201d and generate a new set of keys.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Enter the following command in the terminal:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>composer create-project --repository-url=https:\/\/repo.magento.com\/ magento\/project-community-edition<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">Your public key is the username, and the private key is the password which is needed to be entered after which the Magento 2 is ready to install. Just go through the Setup Wizard and install it now.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">That\u2019s it for the installation of Magento 2 via composer without sample data.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Now I\u2019ll show you how to install sample data. Navigate to Magento 2 root directory through the terminal, and run the following command:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>php bin\/magento sampledata:deploy\nphp bin\/magento setup:upgrade<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">When you run the above two commands,&nbsp;composer.json file will be updated and the sample data will be installed. If you are asked to re-run the Magento compile command, enter the following:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>php bin\/magento setup:di:compile<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">Sit back and wait for some time while the command is being executed.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">3. Install Magento 2 via Github<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">Follow the below steps:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Clone Magento 2 repo from&nbsp;<a href=\"https:\/\/github.com\/magento\/magento2\" target=\"_blank\" rel=\"noreferrer noopener\">github.com\/magento\/magento2<\/a>&nbsp;or download a necessary release&nbsp;<a href=\"https:\/\/github.com\/magento\/magento2\/releases\" target=\"_blank\" rel=\"noreferrer noopener\">github.com\/magento\/magento2\/releases<\/a>.<\/li>\n\n\n\n<li>Create a new empty directory.<\/li>\n\n\n\n<li>Run the following command:<\/li>\n<\/ul>\n\n\n\n<pre class=\"wp-block-code\"><code>git clone git@github.com:magento\/magento2.git<\/code><\/pre>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Wait for the deployment to be finished.<\/li>\n\n\n\n<li>Enter the following command:<\/li>\n<\/ul>\n\n\n\n<pre class=\"wp-block-code\"><code>composer install<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">Install Magento 2Example of the command that installs Magento 2. Check the base-url, db-name, db-password, admin-email, and admin-password to match your local setup.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>php -f bin\/magento setup:install \u2013base-url=&lt;server-url&gt; --backend-frontname=&lt;admin-url-key&gt; --db-host=&lt;db-host-name&gt; --db-name=&lt;db- name&gt; --db-user=&lt;db-user-name&gt; --db-password=&lt;db-password&gt; --admin-firstname=&lt;admin-firstname&gt; --admin-lastname=&lt;admin-lastname&gt; --admin-email=&lt;admin-mail-id&gt; --admin-user=&lt;admin-user&gt; --admin-password=&lt;admin-password&gt; --language=&lt;your-locale-language&gt; --currency=&lt;default-currency&gt; --timezone=&lt;timezone&gt; \u2013use-rewrites=1<\/code><\/pre>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Open your browser and visit your local link<\/li>\n\n\n\n<li>Magento 2 is now installed!<\/li>\n<\/ul>\n\n\n\n<p class=\"wp-block-paragraph\">To install Magento 2 via Github with sample data, follow the below steps:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Go to the web root which is not Magento 2.<\/li>\n\n\n\n<li>Run the below command:<\/li>\n<\/ul>\n\n\n\n<pre class=\"wp-block-code\"><code>git clone git@github.com:magento\/magento2-sample-data.git<\/code><\/pre>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Navigate to cloned Magento 2 directory.<\/li>\n\n\n\n<li>Run the below command:<\/li>\n<\/ul>\n\n\n\n<pre class=\"wp-block-code\"><code>php -f dev\/tools\/build-sample-data.php -- --ce-source=\"your Magento CE install dir\"<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">Symlinks to your Magento 2 installation are created.<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>For Linux machine, you need to set ownership and permissions:<\/li>\n<\/ul>\n\n\n\n<pre class=\"wp-block-code\"><code>chown -R :your web server group name\nfind . -type d -exec chmod g+ws {} ;<\/code><\/pre>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Clear cache. Navigate to the Magento 2 var\/ folder and run the below command:<\/li>\n<\/ul>\n\n\n\n<pre class=\"wp-block-code\"><code>rm -rf cache\/* page_cache\/* generation\/*<\/code><\/pre>\n\n\n\n<ul class=\"wp-block-list\">\n<li>To install the sample data, run the below commands:<\/li>\n<\/ul>\n\n\n\n<pre class=\"wp-block-code\"><code>php bin\/magento setup:upgrade\nphp bin\/magento setup:di:compile<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">So that was all about Magento 2 installation<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">You can always refer the&nbsp;<a href=\"https:\/\/experienceleague.adobe.com\/en\/docs\/commerce-operations\/installation-guide\/overview\" target=\"_blank\" rel=\"noreferrer noopener\">https:\/\/experienceleague.adobe.com\/docs\/commerce-operations\/installation-guide\/overview.html<\/a><\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Best wishes for your&nbsp;<a href=\"https:\/\/meetanshi.com\/blog\/start-online-business\/\" target=\"_blank\" rel=\"noreferrer noopener\">online store<\/a>&nbsp;success with the help of latest&nbsp;<a href=\"https:\/\/meetanshi.com\/blog\/magento-2-4-6-release\/\" target=\"_blank\" rel=\"noreferrer noopener\">Magento 2.4.6<\/a>&nbsp;features and security!<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Feel free to share the tutorial with Magento Community via social media<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Thank you.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>If you are visiting this post that means you are on the stepping stone in E-commerce world! And, you have made the right choice to&#8230;<\/p>\n","protected":false},"author":5,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"footnotes":""},"categories":[34],"tags":[],"class_list":["post-121","post","type-post","status-publish","format-standard","hentry","category-magento"],"acf":[],"_links":{"self":[{"href":"https:\/\/meetanshi.com\/blog\/wp-json\/wp\/v2\/posts\/121","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/meetanshi.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/meetanshi.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/meetanshi.com\/blog\/wp-json\/wp\/v2\/users\/5"}],"replies":[{"embeddable":true,"href":"https:\/\/meetanshi.com\/blog\/wp-json\/wp\/v2\/comments?post=121"}],"version-history":[{"count":4,"href":"https:\/\/meetanshi.com\/blog\/wp-json\/wp\/v2\/posts\/121\/revisions"}],"predecessor-version":[{"id":17862,"href":"https:\/\/meetanshi.com\/blog\/wp-json\/wp\/v2\/posts\/121\/revisions\/17862"}],"wp:attachment":[{"href":"https:\/\/meetanshi.com\/blog\/wp-json\/wp\/v2\/media?parent=121"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/meetanshi.com\/blog\/wp-json\/wp\/v2\/categories?post=121"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/meetanshi.com\/blog\/wp-json\/wp\/v2\/tags?post=121"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}