Before you install Magento 2, make sure that the webserver (such as LAMP) and Elasticsearch are configured and meet Magento 2 requirements.
Install the virtualhost script for the LAMP server, and create a new virtual host dev.mymagento.com, run the command:
virtualhost create dev.mymagento.com
Open this link in your browser and make sure you can see the content, not the error.
Download the archive with the latest version of Мagento 2. When downloading, you can select the "Include sample data" option, so that after you install Magento 2 test products and categories are available in the store.
Once you download the archive, place the folders and files from it in your domain directory /var/www/devmymagentocom.
Edit the virtual host domain configuration file, run the command:
gedit /etc/apache2/sites-available/dev.mymagento.com.conf
and change the string
DocumentRoot /var/www/devmymagentocom
to
DocumentRoot /var/www/devmymagentocom/pub
The pub folder must be the root one for the webserver.
After saving the changes, do not forget to restart the webserver, run the command:
service apache2 restart
Start installing Magento 2.
In earlier versions of Magento 2, an installation wizard with a web interface was available, as you can see on this picture:
However, for a number of reasons, including security, it has been removed, and now you can install Magento 2 using console commands.
Warning! It is very important that all subsequent commands are executed not with sudo privileges or the root user, but with the same user on whose behalf the webserver is running.
To begin the installation process, go to the root folder of Magento 2, run the command:
cd /var/www/devmymagentocom
Start the installation process, run the command (before starting, edit the settings and change them to your own):
php bin/magento setup:install --admin-firstname=root --admin-lastname=root --admin-email=myemail@gmail.com --admin-user=root --admin-password=root123 --db-password=phpmyadmin --db-host=localhost --db-name=magento2 --db-user=phpmyadmin --base-url="http://dev.mymagento.com/" --backend-frontname=admin --db-prefix=mym2_
Note: you have to set your own values for admin-firstname, admin-lastname, admin-lastname, admin-user, admin-password, db-password, db-host, db-name, db-user, base-url, backend-frontname and db-prefix.
That's it! Now you can visit your Magento 2 store in the browser.
We also recommend putting the store in development mode, if you plan to conduct development activities, run the command:
php bin/magento deploy:mode:set developer