How to Install Magento 2
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 Magento 2 as the platform. I’ll guide you through the installation process of Magento 2.
Make sure you fulfill some basic Magento 2.x system requirements prior to installing Magento 2. You can also install Magento 2 via command line.
There are three ways to install Magento 2:
Let’s understand each method.
-
- Visit the Magento Download Page. Download the latest Magento 2 package from any archive type (zip, tar.gz, tar.bz2), with or without sample data.
- Now upload the zip file to the server and extract it to Magento root directory.
- you can unzip or extract the package for shared hosting users.
- For the local server, follow the commands below:
# File .tar.gz tar zxf *filename* # File .zip unzip *filename*
- Run below command to add write permission for var, app/etc, pub folders.
chmod 777 -R var chmod 777 -R app/etc chmod 777 -R pub
- Now run Magento setup wizard and finish installation process.
-
A composer is a tool for dependency management in PHP. To learn more about the composer, visit https://getcomposer.org/doc/00-intro.md
Similar to above method, Magento core code is stored under /vendor directory and updating is possible through Magento admin.
Collect your authentication keys from here. Navigate to “My Access Keys”, enter a descriptive “Name” and generate a new set of keys.
Enter the following command in the terminal:
composer create-project --repository-url=https://repo.magento.com/ magento/project-community-edition
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.
That’s it for the installation of Magento 2 via composer without sample data.
Now I’ll show you how to install sample data. Navigate to Magento 2 root directory through the terminal, and run the following command:
php bin/magento sampledata:deploy php bin/magento setup:upgrade
When you run the above two commands, 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:
php bin/magento setup:di:compile
Sit back and wait for some time while the command is being executed.
-
Follow the below steps:
- Clone Magento 2 repo from github.com/magento/magento2 or download a necessary release github.com/magento/magento2/releases.
- Create a new empty directory.
- Run the following command:
git clone [email protected]:magento/magento2.git
- Wait for the deployment to be finished.
- Enter the following command:
composer install
- 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.
php -f bin/magento setup:install –-base-url=server-url --backend-frontname=admin-url-key --db-host=db-host-name --db-name=db-name --db-user=db-user-name --db-password=db-password --admin-firstname=admin-firstname --admin-lastname=admin-lastname --admin-email=admin-mail-id --admin-user=admin-user --admin-password=admin-password --language=your-locale-language --currency=default-currency --timezone=timezone –-use-rewrites=1
- Open your browser and visit your local link
- Magento 2 is now installed!
To install Magento 2 via Github with sample data, follow the below steps:
- Go to the web root which is not Magento 2.
- Run the below command:
git clone [email protected]:magento/magento2-sample-data.git
Please complete your information below to login.