Description: Here I have explained, How to install Magento 2 with Nginx, Self signed SSL, MariaDB 10.x, PHP 7.3 on Ubuntu 20
- Before start the installation Update the packages
# apt update
- Install Nginx using apt command
# apt install nginx
- Start and Enable Nginx service. Check the Nginx service status
# systemctl start nginx
# systemctl enable nginx
# systemctl status nginx
- Install and configure PHP-FPm 7.3
- Before install PHP add repository for same
# sudo apt install software-properties-common
# add-apt-repository ppa:ondrej/php
- Install PHP from PPA repository
- Update PHP FPm and CLI configuration as follow
Open /etc/php/7.3/fpm/php.ini and vi /etc/php/7.3/cli/php.ini configuration file and update the parameters as follow:
date.timezone = Asia/Kolkata memory_limit = 2G max_execution_time = 1800 zlib.output_compression = On cgi.fix_pathinfo = 1 opcache.enable=1 opcache.save_comments = 1
- Start and Enable php-fpm service. Also check php-fpm status
# systemctl enable php7.3-fpm
# systemctl status php7.3-fpm
- Install and Configure MariaDB
# apt install mariadb-server
After installation start and enable mariadb service
# systemctl start mariadb
# systemctl enable mariadb
Configure Mariadb
# mysql_secure_installation
Set a root password? [Y/n] Y Remove anonymous users? [Y/n] Y Disallow root login remotely? [Y/n] Y Remove test database and access to it? [Y/n] Y Reload privilege tables now? [Y/n] Y
Login into mysql using root user and create database and user with privileges
# mysql -u root -p
create database magentodb; create user magentouser@'localhost' identified by 'magentopassdb'; grant all privileges on magentodb.* to magentouser@'localhost'; flush privileges;
Install composer and verify the version
# apt install composer -y
# composer --version
Download and Install Magento 2
# cd /var/www ### You can change to path as per your requirement ###
# wget -q https://github.com/magento/magento2/archive/2.3.5.tar.gz
# tar -xf 2.3.5.tar.gz
# mv magento2-2.3.5/ magento2
# cd /var/www/magento2/
# composer install
Setup SSL for Magento Site: Here I am going to create self signed certificate and use it for same
- Generate Self Signed SSL in ubuntu [In this example I will use magentotestlab.com as URL]
# mkdir /home/ssl
# cd /home/ssl
# openssl req -newkey rsa:4096 -x509 -sha256 -days 3650 -nodes -out magentotestlab.crt -keyout magentotestlab.key
Country Name (2 letter code) [AU]:IN State or Province Name (full name) [Some-State]:GJ Locality Name (eg, city) []:AH Organization Name (eg, company) [Internet Widgits Pty Ltd]:magentotestlab pvt ltd Organizational Unit Name (eg, section) []:IT Common Name (e.g. server FQDN or YOUR name) []:magentotestlab.com Email Address []:
Note: After filled all the details certificate and key file will be created on same path
Setup Nginx Virtual Host for Magento2
Setup Nginx Virtual Host for Magento2
- Open the Nginx configuration directory and create configuration for Magento
# cd /etc/nginx/sites-available/
# vi magentotestlab ### Create the configuration and paste as follow ###
upstream fastcgi_backend { server unix:/run/php/php7.3-fpm.sock; } server { listen 80; listen [::]:80; server_name magentotestlab.com; return 301 https://$server_name$request_uri; } server { listen 443 ssl http2; server_name magentotestlab.com; ssl_certificate /home/ssl/magentotestlab.crt; ssl_certificate_key /home/ssl/magentotestlab.key; set $MAGE_ROOT /var/www/magento2; set $MAGE_MODE developer; include /var/www/magento2/nginx.conf.sample; }
Remove Default host configuration from /etc/nginx/sites-available and /etc/nginx/sites-enable
After remove the configuration link the configuration using ln command
# ln -s /etc/nginx/sites-available/magentotestlab /etc/nginx/sites-enabled
# nginx -t ### Verify the configuration after setup ###
Magento Post Installation Task
Browse the URL and complete the task
https://magentotestlab.com/
Store Configuration Details
Once the installation will completed you will receive Screen as follow
Too Many Redirection error in Admin Page
- After installation some time Admin page showing error like too many redirection
- To resolve this redirection issue navigate to installation path /var/www/magento2 and run the following commands
# cd /var/www/magento2/
# bin/magento config:set web/secure/use_in_adminhtml 1
# php bin/magento cache:clean
- Now try to reopen the admin url
Setup Cron in Magento: After setup Magento Need to setup default cron job for Magento
Navigate to Path /var/www/magento2
# cd /var/www/magento2
# bin/magento cron:install --force ### Install cron job ###
No comments:
Post a Comment