Magento 2: Installation Guide

Magento 2 Logo

I thought I might as well do a quick guide on the installation of Magento 2. Start with the basics and work our way up. I will add some more guides in surrounding topic areas soon so watch this space.

First of all we need to ensure we have our base server setup complete.
In this guide I will be using:

  • Ubuntu 18.04.2 LTS
  • Magento 2.3
  • PHP 7.1.30 and required extensions
  • Composer

I’m going to assume you have the above set up, configured and ready to go. Also, that you have setup your Apache virtual hosts for local development, along with setting up your Magento 2 database and database users.

OK, lets start by switching to our dedicated Magento user in a development environment this is likely going to be your user account. However, in production you want to lock down permissions as best as possible having a dedicated Magento system user without sudo privileges helps to contain privileged system access. The user owning the Magento installation should not be the web server user.

su - magento

You should be prompted for the users password and then if successful the account change will be visible in the terminal window shown below.

change user accounts in Ubuntu

Next we will install the Magento 2 software

composer create-project --repository=https://repo.magento.com/ magento/project-community-edition <install-directory-name>

You will be asked for authentication which you can obtain from the Magento marketplace

Composer should now start downloading and installing the required software components. It might complain and throw an error if your environment is not configured correctly. Although, the error thrown normally gives a fairly clear indication of the problem.

Once composer completes you are ready to set file permissions

cd /var/www/html/<install directory>
find var generated vendor pub/static pub/media app/etc -type f -exec chmod g+w {} +
find var generated vendor pub/static pub/media app/etc -type d -exec chmod g+ws {} +
chown -R :www-data .
chmod u+x bin/magento

You now have two options to complete installation, the command line or web interface. If using the web interface navigate to your virtual host domain to confirm everything is working as expected. If so you should be presented with the Magento 2 installation screen.

For the latest reference see the Magento 2 dev docs.

Leave a Reply

Your email address will not be published. Required fields are marked *