Magento 2 Installation
Today we will install Magento 2. Why do we need to do this? Previous versions will still work, but Magento will stop supporting these versions in a few years’ time.
It brings database optimization and full page caching which should speed up the data processing. It has LESS preprocessor which is better for front-end developers. Extensions like PayPal are integrated.
Firstly we need to download the necessary files from: Magento. Before this, we need to login into our Magento account.
In the download section, we need to choose our format and version, after which we press the download button.
After downloading all the files, we need to extract all data into a website folder. If all is configured correctly, we should see the box below:
MAGENTO 2 REQUIREMENTS
In the first step we should check our server configuration. Our PHP version needs to be higher than 5.5.22 and MySQL should be 5.6.x.
We need to set always_populate_raw_post_data to -1 in php.ini.
After that we need to enable all extensions by removing the semicolon in php.ini and add writable permissions for the website folder. All official requirements are here.
In the next step, we need to configure our database connection, but beforehand we must create the database. We can use phpMyAdmin or terminal.
It’s not recommended to use root user, and also remember to use a strong password.
In the third step, we need to configure our store address and admin URL. It’s not recommended to use ”admin” as the admin URL, because it’s easy to guess.
In Advanced options we can configure https:// options. Apache rewrites to get friendly links, the encryption key and the place where the session is saved.
MAGENTO 2 VIRTUAL HOST
If we are using Magento 2 locally, we need to configure a virtual host like below:
SetEnv APPLICATION_ENV "development"
Options Indexes FollowSymLinks MultiViews
Allow from All
Require all granted
In the fourth step, we need to configure the time zone, default currency and default language. After that we need to create an admin account.
We will use it later to manage the store. In the last step, we just need to press install button.
After that we will see a progress bar. We need to wait around 5 minutes according to your machine. In the last section we will see all information for Magento Admin Info and Database Info.
MAGENTO 2 DATABASE CONFIGURATION FILE
If it’s needed, we can change the database configuration in /app/etc/env.php
MAGENTO 2 CSS AND JS NOT WORKING
php bin/magento setup:static-content:deploy
The above command enables you to write static files to the Magento file system when the Magento software is set to production mode.
php bin/magento indexer:reindex
This command enables you toreindex indexers. After that we need clear the cache. Navigate to var/cache and remove all files.
MAGENTO 2 BROKEN IMAGES
If our images are broken we need navigate to pub/static folder and remove all except the .htaccess file. Next navigate to app/etc/di.xml
Refresh the website in the frontend and backend. After that, revert di.xml back to its original state.