Step 1: Magento System Requirements

Make sure that your system meets all the Magento 2 requirements. Here are the main points:

Also, to make your installation process secure, set up the Magento file system owner on the server.

Step 2: Install Magento via Composer

After preparations are done, you need to get the Magento software. You can do it by using Composer or by downloading the archive. 

If you are using Composer, change to the web server docroot directory with the command:

cd <web server docroot directory>

Then, create a new project with the meta-package:

composer create-project --repository-url= magento/project-community-edition <install-directory-name>

Authenticate by entering the keys that you can set up in Magento Marketplace.

Step 3: File permissions for Magento

Next, you need to change permissions to read-write. Otherwise, you won’t be able to install Magento files via the command line. The process will be different for shared and private hostings. Let’s see how to configure permissions for shared hosting.

1) Set write permissions for the following directories:

  • vendor
  • app/etc
  • pub/static
  • var
  • Generated

2) Then, open the command line and enter the commands:

cd <magento_root>

find var generated vendor pub/static pub/media app/etc -type f -exec chmod u+w {} +

find var generated vendor pub/static pub/media app/etc -type d -exec chmod u+w {} +

chmod u+x bin/magento

3) Next, switch to the Magento file system owner with the command:

su <username>

Step 4: Install Magento on Ubuntu via CLI

Now, we will go directly to the process of installing Magento 2 on Ubuntu.

For this, run the command:

bin/magento setup:install --base-url= \
--db-host=localhost --db-name=magento --db-user=magento --db-password=magento \
--admin-firstname=Magento --admin-lastname=Admin \
--admin-user=admin --admin-password=12345 --language=en_US \
--currency=USD --timezone=America/Chicago --use-rewrites=1 \
--search-engine=elasticsearch7 \

The admin’s first and last names are Magento Admin, username - admin, password - 12345, e-mail - The Magento 2 will be installed to the /var/www/html/magento2 folder, and the storefront URL will be The database name, the username, and the password are magento

The default store language is U.S. English, the currency is USD, the time zone is U.S. Central

Elasticsearch 7 is connected through port 9200.

Step 5. Finally, you need to verify that everything works correctly. For this, open your website frontend with the URL and try to log in to the admin panel with the admin’s username and password.