Home / How To / How to install Magento on CentOS 8

How to install Magento on CentOS 8



Magento is one of the most popular open source e-commerce platforms that lets you set up e-commerce websites and online stores in minutes. It is written in PHP, based on the Zend Framework and uses the Entity Attribute Value (EAV) database model to store data. It comes with a simple and user-friendly interface that allows you to easily customize your online store and sell your products and services.

In this tutorial, we will show you how to install Magento eCommerce platform on CentOS 8 with Let & # 39; s Encrypt free SSL.

Requirements

  • A server running CentOS 8 with 2 GB of RAM.
  • A valid domain name pointed to your server IP.
  • A root password is configured on the server.

Installing LEMP Server

First install Nginx web server, MariaDB database server, PHP and other necessary PHP libraries by running the following command:

  dnf install nginx mariadb server php php-cli php-mysqlnd php-opcache php-xml php -gd php-soap php-bcmath php-intl php-mbstring php-json php-iconv php-fpm php-zip unzip git-y 

When all packages are installed, start the service Nginx, MariaDB and PHP -FPM and enable them to start after restarting the system with the following command:

  systemctl start nginx 
systemctl start mariadb
systemctl start php-fpm
systemctl enable nginx
systemctl enable mariadb
systemctl enable php-fpm

Then you need to edit php.ini file and tweak some settings:

  nano /etc/php.iniebrit19659010??Change the following lines: 

  memory_limit = 512M
upload_max_filesize = 200M
zlib.output_compression = On
max_execution_time = 300
date.timezone = Asia / Kolkata

Save and close the file when you are done.

Configure Database

By default, MariaDB is not secured so you must secure it first. Run the following script to secure MariaDB:

  mysql_secure_installation 

Answer all questions shown below:

  Enter the current root password (specify for none):
Set root password? [Y/n] Y
New password:
Re-enter new password:
Delete anonymous users? [Y/n] Y
Remove root login remotely? [Y/n] Y
Delete the test database and access it? [Y/n] Y
Reload privilege tables now? [Y/n] Y

When you are finished, log in to the MariaDB shell with the following command:

  mysql -u root -p 

Enter your root password when you become quickly create a database and user for Magento a as shown below:

  MariaDB [(none)]> CREATE DATABASE magentodb; 
MariaDB [(none)]> GRANT ALL ON magentodb. * TO [email protected] IDENTIFIED BY & # 39; password & # 39 ;;

Next, flush the privileges and exit the MariaDB shell with the following command:

  MariaDB [(none)]> flush privileges; 
MariaDB [(none)]> exit;

Configuring PHP-FPM for Magento

Next, you need to configure PHP-FPM pool for your Magento instance. You can configure it by creating the following file:

  nano /etc/php-fpm.d/magento.confospel19659010??Add the following lines: 

  [magento]
user = nginx
group = nginx
list.owner = nginx
list.group = nginx
listen = /run/php-fpm/magento.sock
pm = ondemand
pm.max_children = 50
pm.process_idle_timeout = 10s
pm.max_requests = 500
chdir = /

Save and close the file and then restart the PHP-FPM service to implement the changes:

  systemctl restart php-fpm 

Download Magento [19659008] First, download the latest version of Magento from the Git layer with the following command:

  cd / var / www / html 
wget https://github.com/magento/magento2/archive/2.3.zipebrit19659010? ? downloaded, unzip the downloaded file as shown below:

  unzip 2.3.zip 

Next, move the extracted directory to magento2 as shown below:

  etc. magento2-2.3 magento2 

Then you need to install Composer to install PHP dependencies for Magento.

You can install Composer with the following command:

  curl -sS https://getcomposer.org/installer | php 
mv composer.phar / usr / local / bin / composer

Then change the directory to magento2 and install all Magento dependencies with the following command:

  cd / var / www / html / magento2 
composer update
composer install

Then you need to create Magento crontab to schedule tasks. You can create it with the following command:

  ./ bin / magento cron: install 

You can verify crontab with the following command:

  crontab -l 

You should get the following output: [19659015] # ~ MAGENTO START f73db5f5dcf223372d4c9fab56bef0c1730eece898fad5cbee0c313b46b0dd1f
* * * * * / usr / bin / php / var / www / html / magento2 / bin / magento cron: run 2> & 1 | grep -v "Ran job by schedule" >> /var/www/html/magento2/var/log/magento.cron.log
* * * * * / usr / bin / php /var/www/html/magento2/update/cron.php >> /var/www/html/magento2/var/log/update.cron.log
* * * * * / usr / bin / php / var / www / html / magento2 / bin / magento setup: cron: run >> /var/www/html/magento2/var/log/setup.cron.log
# ~ MAGENTO END f73db5f5dcf223372d4c9fab56bef0c1730eece898fad5cbee0c313b46b0dd1f

Then grant the permissions to the magento2 directory:

  chown -R nginx: nginx / var / www / html / magento2 
chmod-R 755 / var / www / html / magento2

Configuring Nginx for Magento

Next, you need to create a virtual Nginx host file for Magento. You can create it with the following command:

  nano /etc/nginx/conf.d/magento.confebrit19659010??Add the following lines: 

  upstream fastcgi_backend {
serverunix: /run/php-fpm/magento.sock;
}

server {
listen 80;
server name magento.linuxbuz.com;

set $ MAGE_ROOT / var / www / html / magento2;
set $ MAGE_MODE developer;

access_log /var/log/nginx/magento-access.log;
error_log /var/log/nginx/magento-error.log;

include /var/www/html/magento2/nginx.conf.sample;
}

Save and close the file when you are done. Then restart Nginx and PHP-FPM service to implement changes:

  systemctl restart php-fpm 
systemctl restart nginx

Configure SELinux and Firewall

By default, SELinux is enabled in CentOS 8. So you will need to configure SELinux for Magento to work properly.

You can configure SELinux with the following command:

  semanage permissive -a httpd_t 

Next, you must create a firewall rule to allow HTTP and HTTPS service from external networks. You can allow it with the following command:

  firewall-cmd --permanent --add-service = http 
  firewall-cmd --permanent --add-service = https 
firewall-cmd --reload [19659064] Secure Magento with Let & # 39; s Encrypt SSL

Magento is now installed and configured. It's time to secure it with Let's Encrypt free SSL.

To do so, you must download the certbot client to your server. You can download and set the correct state by running the following command:

  wget https://dl.eff.org/certbot-autoebrit19459022??mv certbot-auto / usr / local / bin / certbot-auto 
chown root / usr / local / bin / certbot-auto
chmod 0755 / usr / local / bin / certbot-auto

Now run the following command to obtain and install an SSL certificate for your Magento site. [19659009] certbot-auto --nginx -d magento.linuxbuz.com

The above command first installs all the necessary dependencies shown below:

  Installed:
gcc-8.2.1-3.5.el8.x86_64 mod_ssl-1: 2.4.37-12.module_el8.0.0 + 185 + 5908b0db.x86_64
python3-virtualenv-15.1.0-18.module_el8.0.0 + 33 + 0a10c0e1.noarch python36-devel-3.6.8-2.module_el8.0.0 + 33 + 0a10c0e1.x86_64
redhat-rpm-config-116-1.el8.0.1.noarch augeas-libs-1.10.1-8.el8.x86_64
libffi-devel-3.1-18.el8.x86_64 openssl-devel-1: 1.1.1-8.el8.x86_64
annobin-8.64-1.el8.x86_64 cpp-8.2.1-3.5.el8.x86_64
dwz-0.12-9.el8.x86_64 efi-srpm-macros-3-2.el8.noarch
ghc-srpm-macros-1.4.2-7.el8.noarch go-srpm-macros-2-16.el8.noarch
isl-0.16.1-6.el8.x86_64 libmpc-1.0.2-9.el8.x86_64
ocaml-srpm-macros-5-4.el8.noarch openblas-srpm-macros-2-2.el8.noarch
perl-srpm-macros-1-25.el8.norch platform-python-devel-3.6.8-2.el8_0.0.1.x86_64
python-rpm-macros-3-37.el8.orch python-srpm-macros-3-37.el8.orch
python3-rpm-generators-5-4.el8.noarch python3-rpm-macros-3-37.el8.noarch
qt5-srpm-macros-5.11.1-2.el8.noarch-srpm-macros-5-2.el8.noarch
glibc-devel-2.28-42.el8.1.x86_64 glibc-headers-2.28-42.el8.1.x86_64
kernel-headers-4.18.0-80.11.2.el8_0.x86_64 keyutils-libs-devel-1.5.10-6.el8.x86_64
krb5-devel-1.16.1-22.el8.x86_64 libcom_err-devel-1.44.3-2.el8.x86_64
libkadm5-1.16.1-22.el8.x86_64 libselinux-devel-2.8-6.el8.x86_64
libsepol-devel-2.8-2.el8.x86_64 libverto-devel-0.3.0-5.el8.x86_64
libxcrypt-devel-4.1.1-4.el8.x86_64 pcre2-devel-10.32-1.el8.x86_64
pcre2-utf16-10.32-1.el8.x86_64 pcre2-utf32-10.32-1.el8.x86_64
ZLIB devel 1.2.11-10.el8.x86_64

Complete!
Creating virtual environment ...
Installing Python packages ...
Installation succeeded.

Once all dependencies are installed, you will be prompted to enter your email address and approve the service shown below:

  Save Troubleshooting Log to /var/log/letsencrypt/letsencrypt.log
Selected plugins: Authenticator nginx, installer nginx
Enter Email Address (Used for Emergency Renewal and Security Messages) (Enter & # 39; c & # 39; to
cancel): [email protected]

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Read the terms of use at
https://letsencrypt.org/documents/LE-SA-v1.2-November-15-2017.pdf. You must
agree to register on the ACME server at
https://acme-v02.api.letsencrypt.org/directory
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
(A) gree / (C) ancel: A

Saves debug log to /var/log/letsencrypt/letsencrypt.log
Selected plugins: Authenticator nginx, installer nginx
Get a new certificate
Perform the following challenges:
http-01 challenge for magento.linuxbuz.com
Waiting for verification ...
Cleaning of challenges
Distribute certificates to VirtualHost /etc/nginx/conf.d/magento.conf

Then you must choose whether you want to redirect HTTP traffic to HTTPS as shown below:

  Choose whether or not to redirect HTTP traffic to HTTPS.
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
1: No Redirect - Do not make any further changes to the web server configuration.
2: Redirect - Makes all requests redirect to secure HTTPS access. Select this for
new websites, or if you are sure your site is working on HTTPS. You can undo this
change by editing your web server configuration.
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Select the appropriate number [1-2] and then [enter] (press & # 39; c & # 39; to cancel): 2

Type 2 and press Enter to install Let's # Encrypt SSL certificate for your domain as shown below:

  Redirects all traffic on port 80 to ssl in /etc/nginx/conf.d/magento .conf

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Congratulations! You have enabled https://magento.linuxbuz.com

You should test your configuration on:
https://www.ssllabs.com/ssltest/analyze.html?d=magento.linuxbuz.com
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

IMPORTANT NOTES:
- Congratulations! Your certificate and chain have been saved to:
/etc/letsencrypt/live/magento.linuxbuz.com/fullchain.pem
Your key file has been saved to:
/etc/letsencrypt/live/magento.linuxbuz.com/privkey.pem
Your certificate expires 2020-03-23. To get a new or fine tuned
version of this certificate in the future, simply run certbot-auto
again with the "certonly" option. Not to renew * everything *
of your certificates, run "certbot-auto-renewal"
- If you like Certbot, you can consider supporting our work by:

Donate to ISRG / Let & # 39; s Encrypt: https://letsencrypt.org/donate
Donate to EFF: https://eff.org/donate-le

Access Magento

Magento is now installed and configured. It's time to get to the Magento installation guide.

Open your browser and enter the URL https://magento.linuxbuz.com . You will be redirected to the Magento Welcome Page:

 Magento Installer

Click the Agree and Setup Magento button. You can see the Magento emergency check guide:

 System-ready check

Now click the Next button. You should see the following page:

 Database set

Enter your database information and click the Next button. You should see the following page:

 Web Configuration

Now, enter your Magento store and URL and click the Next button. You should see the following page:

 Configure currency, time zone and language

Select the desired time zone, currency, language and click the Next button. You should see the following page:

 Configure username

Now, enter your Magento admin username, password and click the Next button. You should see the following page:

 Continue with the installation

Now click the Install Now button to start the Magento installation. When the installation is complete. You should see the following page:

 Installation succeeded

Now click on the Your Store Address button. You should see your Magento store on the following page:

 Magento website Ads

To access your Magento Admin interface, type the URL https://magento.linuxbuz.com/admin_1teqss in your browser. You will be redirected to the Magento login page:

 Magento login

Enter your Magento admin username, password and click the Sign in the button. You should see your Magento admin interface on the following page:

 Magento Dashboard

That's it for now. Your Magento is now secured with Let's Encrypt free SSL.


Source link