How to install Magento 2 in Ubuntu?
Before start installation you should have an access keys in order to download the Magento software
You can create your account on – https://marketplace.magento.com/

Then you will be redirect to the auth services of Adobe. Follow the steps and simply create an account. Or Login with your existing credentials.
Go to My Profile -> Access Keys.
If you already generated access keys you will be able to see the keys in following format.
Public Key : r345118463e4d028092klb7 copy
Private Key : 588d131f60fdb6f8 copy
(These are the sample keys by the way. And not actual keys π )
If you donβt have the keys then you can click on βCreate New Access Keyβ .
Follow the steps and generate new one.
Step 1 – Download Magento via Composer
If you want to install latest version –
$ composer create-project --repository-url=https://repo.magento.com/ magento/project-community-edition <install-directory-name>
Where <install-directory-name> is the root directory name in which the Magento will be installed.
If you want to install specific version
$ composer create-project --repository-url=https://repo.magento.com/ magento/project-enterprise-edition=2.4.5 <install-directory-name>
Once you execute the command in terminal then it will ask you authentication.
Put public Key as a username & private key as a password.
You can see the output as follows.

Step 2 – Install Magento on your local –
Step 2.1 – Create a new database in your mysql.
For example. Here we are creating db with name m2.
Step 2.2 – Create a virtual host
For example. Here we are creating virtual host with name http://m2.local
Step 2.3 – Open the terminal and go to your root directory
$ cd /var/www/html/m2 $ php bin/magento setup:install \ --base-url=http://m2.local \ --db-host=localhost \ --db-name=m2 \ --db-user=root \ --db-password=welcome \ --admin-firstname=M2 \ --admin-lastname=Admin \ --admin-email=test@example.com \ --admin-user=admin \ --admin-password=admin@123 \ --language=en_US \ --currency=INR \ --timezone=Asia/Kolkata
This will show following screen.

In this case it is “/admin_3hu9hl”.
If you observe carefully Magento generates here new admin url key.
We can change this key as per our choice.
Your Magento Installation is done and you can access
Magento backend using – http://m2.local/admin_3hu9hl


You can access frontend using – http://m2.local

And You are done with the installation ! π