How To Install Magento 2

Magento has canceled the web loader since the 2.4 version. Problems are just started here.
You probably can’t install Magento on shared hosting. Because you have to customize the webserver. Maybe you can buy customized Magento hosting which is I don’t recommend. I have to mention that prices are too high for shared Magento hosting. (And it won’t you happy.) If you want to install Magento, I recommend getting a VPS instead of hosting. Magento requires more system requirements than other systems.

Magento has two main versions. The first is Magento open source, which we will be using, and the other is Magento Commerce. The paid software has different features, including reporting and extensions. It is also worth mentioning that its price is over $20,000. (Don’t know current prices.)

I will show you how to install Magento with the zip file

Advantages of Magento 2:

Good performance with a high number of products
Offering SEO advantage without almost any intervention in its structure
API support
Open source
Magento-using sites grow faster than others
Advanced campaign modules
Advanced and easy product and category management

Disadvantages of Magento 2:

  • Lack of experts who can support as much as WordPress or OpenCart
  • Expensive themes and modules
  • Development processes may take longer than other e-commerce software (developer support is more expensive)
  • Higher resource consumption compared to other systems
  • You have to constantly care.

Magento Requirements

Minimum 2 GB of RAM, 4 GB or above is recommended.

Required software:

Elasticsearch

Required PHP extensions:

ext-bcmath, ext-ctype, ext-curl, ext-dom, ext-gd, ext-hash, ext-iconv, ext-intl, ext-mbstring, ext-openssl, ext-pdo_mysql, ext-simplexml, ext-soap, ext-xsl, ext-zip, ext-sockets

Recommendations:

Redis, Varnish cache, PHP OPcache, SSL, RabbitMQ – I will write about their installations later.

Operating system and web server:

  • You can install on any version of Linux. I recommend installing on CENTOS.
  • You can install on PHP 7 or above.
  • It is recommended to use Apache + NGINX. NGINX is much faster than Apache. You can use either of them alone.

SSH

You need to establish an SSH connection. If you are using Linux, you can easily do it, but if you are working on Windows, you can connect with putty.
During installations, you need to do it with a user that you gave shell access, not with the root user.

You can change the user with

su -l user

If you are on a shared server, they will probably not give you SSH privileges.

If you are using a panel (cpanel), you can create a database and give the user privileges through your panel for convenience.

mysql -u root

Creating a Database User

CREATE USER ‘newuser’@’localhost’ IDENTIFIED BY ‘PASSWORD’;

Creating a Database

CREATE DATABASE DATABASE_NAME;

Granting Permissions to a User

To grant all privileges on a database to a user, use the following command:
GRANT ALL PRIVILEGES ON DATABASE_NAME.* TO ‘newuser’@’localhost’;

Installing Elasticsearch

Install Java.

On CentOS and its variants:
– Update the system: yum -y update
– Install Java: yum -y install java-1.8.0-openjdk
Download Elasticsearch files:
wget https://artifacts.elastic.co/downloads/elasticsearch/elasticsearch-7.10.1-x86_64.rpm
wget https://artifacts.elastic.co/downloads/elasticsearch/elasticsearch-7.10.1-x86_64.rpm.sha512
shasum -a 512 -c elasticsearch-7.10.1-x86_64.rpm.sha512
sudo rpm –install elasticsearch-7.10.1-x86_64.rpm

Install Elasticsearch using the following commands:
sudo yum install –enablerepo=elasticsearch elasticsearch
sudo zypper modifyrepo –enable elasticsearch &&
sudo zypper install elasticsearch;
sudo zypper modifyrepo –disable elasticsearch

For the latest instructions on installing Elasticsearch, refer to the official documentation here: https://www.elastic.co/guide/en/elasticsearch/reference/current/install-elasticsearch.html

After installing, start Elasticsearch using the following command:
sudo -i service elasticsearch start

To check if Elasticsearch is working, run the following command:
curl -XGET http://localhost:9200

Setting File Ownership and Permissions

There are multiple ways to fix write permission issues in Magento.
To fix file permission and write issues on shared hosting:
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

Installation Using Composer

If you haven’t already, install Composer by downloading it from here: https://getcomposer.org/download/.

To get the keys from the marketplace, go to Magento.com.

Then, run the installation with the following command:

composer create-project –repository-url=https://repo.magento.com/ magento/project-community-edition

bin/magento setup:install
–base-url=http://your-site.com
–db-host=localhost
–db-name=DATABASE_NAME
–db-user=DATABASE_USERNAME
–db-password=DATABASE_PASSWORD
–admin-firstname=admin
–admin-lastname=admin
[email protected]
–admin-user=admin
–admin-password=admin123
–language=tr_TR
–currency=TRY
–timezone=EUROPE/ISTANBUL
–use-rewrites=1
–search-engine=elasticsearch7 –elasticsearch-host=localhost
–elasticsearch-port=9200

Manual Installation with Zip File

You can also install using the zip file. First, download the software from magento.com and upload it to your server.
After resolving the file writing and permission issues, you can run the installation with the following command:

bin/magento setup:install
–base-url=http://your-site.com
–db-host=localhost
–db-name=DATABASE_NAME
–db-user=DATABASE_USERNAME
–db-password=DATABASE_PASSWORD
–admin-firstname=admin
–admin-lastname=admin
[email protected]
–admin-user=admin
–admin-password=admin123
–language=tr_TR
–currency=TRY
–timezone=EUROPE/ISTANBUL
–use-rewrites=1
–search-engine=elasticsearch7 –elasticsearch-host= localhost
–elasticsearch-port=9200

After the installation, you will be given the path to the admin panel. You can log in to the management panel through this link.

Leave a Reply