How to Install Magento E-commerce Site on Debian 12 with Nginx and Elasticsearch

Learn how to install Magento, the leading e-commerce platform, on Debian 12 with Nginx and Elasticsearch.

How to Install Magento E-commerce Site on Debian 12 with Nginx and Elasticsearch
Are you ready to take your online business to the next level? Look no further! In this comprehensive guide, we will walk you through the step-by-step process of installing a Magento e-commerce site on Debian 12. With the power of Nginx and Elasticsearch, your website's performance and searchability will be optimized, giving you an edge over your competitors.

Prerequisites

Before diving into the installation process, make sure you have the following prerequisites in place:

  1. A server running Debian 12.
  2. Root access or a user account with sudo privileges.
  3. Basic knowledge of Linux commands.

Now that we have everything set up, let's get started!

Step 1: Update System Packages

To ensure that our system is up-to-date with all the latest packages, run the following command:

sudo apt update && sudo apt upgrade -y

Step 2: Install Required Dependencies

Magento has certain dependencies that need to be installed beforehand. Execute these commands one by one:

sudo apt install php-fpm php-mysql php-common php-xml libapache2-mod-php curl gnupg2 wget unzip -y

sudo systemctl enable --now php7.4-fpm

sudo systemctl start nginx.service

Step 3: Download and Extract Magento Files

In this step, we will download and extract Magento files onto our server using wget command:

cd /var/www/html/

wget https://github.com/magento/magento2/archive/refs/tags/2.x.zip 

unzip 2.x.zip 

mv magento2-*/ magento/

Step 4: Configure Nginx for Magento Site

We need to configure Nginx as a webserver for our Magento site. Create a new Nginx configuration file using the following command:

sudo nano /etc/nginx/sites-available/magento.conf

Add the following content to the file:

server {
    listen 80;
    server_name your_domain.com;

    root /var/www/html/magento/pub;
    index index.php;

    location / {
        try_files $uri $uri/ =404;
    }

	location ~ \.php$ {
		try_files $uri =404;
		fastcgi_pass unix:/run/php/php7.4-fpm.sock; 
		fastcgi_index index.php; 
		fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; 
		include fastcgi_params; 
   }
}

Save and close the file by pressing Ctrl + X, followed by Y and then Enter.

To enable this configuration, create a symbolic link of this file in /etc/nginx/sites-enabled/ directory:

sudo ln -s /etc/nginx/sites-available/magento.conf /etc/nginx/sites-enabled/

Verify if there are any syntax errors in the Nginx configuration files with:

sudo nginx -t

If everything looks good, restart Nginx for changes to take effect:

sudo systemctl restart nginx.service

Step 5: Set Up Magento Database

Now, we need to create a MySQL database for our Magento site. Run these commands one by one:

mysql -u root -p

CREATE DATABASE magento_db;

GRANT ALL PRIVILEGES ON magento_db.* TO 'magento_user'@'localhost' IDENTIFIED BY 'your_password';

FLUSH PRIVILEGES;

EXIT;

Step 6: Install Magento via Web Interface

Open your favorite web browser and navigate to http://your_domain.com/. You will be greeted with the Magento installation page. Follow the on-screen instructions to complete the installation process.

Step 7: Configure Elasticsearch for Magento

Magento utilizes Elasticsearch for advanced search functionality. To install and configure Elasticsearch, execute these commands:

wget https://artifacts.elastic.co/downloads/elasticsearch/elasticsearch-7.x.zip

unzip elasticsearch-7.x.zip 

mv elasticsearch-* /usr/share/elasticsearch/

sudo nano /etc/systemd/system/multi-user.target.wants/elasticsearch.service

Add the following content to the file:

[Unit]
Description=Elasticsearch
Documentation=https://www.elastic.co/guide/en/elasticsearch/reference/current/index.html
Wants=network-online.target
After=network-online.target


[Service]
Type=simple
User=elasticsearch 
Group=elasticsearch  
ExecStart=/usr/share/elasticsearch/bin/elasticsearch -p ${PID_DIR}/elast$
Restart=on-failure 
LimitMEMLOCK=infinity

[Install]
WantedBy=multi-user.target

Save and close the file by pressing Ctrl + X, followed by Y and then Enter.

Enable and start Elasticsearch service:

sudo systemctl enable --now elasticservice && sudo systemctl start elasticservice

Congratulations! You have successfully installed Magento eCommerce Suite on Debian 12 with Nginx and Elasticsearch. You can now access your Magento website by navigating to your domain in a web browser. Remember to follow best practices for securing your server and regularly update your Magento installation to ensure a smooth and secure e-commerce experience for your customers.

COMMENTS

Name

2023,2,Ai,2,AlmaLinux 9,3,Amazon Linux,5,Apache Web Server,1,AppImage,1,Arduino IDE,1,Artificial Intelligence,2,BalenaEtcher,1,Bitcoin,1,Blockchain Data,1,Bookworm,2,Bootable USB,1,C++,1,centos,1,CentOS 8,1,CentOS Stream,1,CMake,1,CockroachDB,2,cuDNN,1,Database Security,1,Debian,2,Debian 10,2,Debian 11,2,Debian 12,9,DNS,1,Docker,1,E-commerce,1,Fail2ban,1,Fedora Linux,1,Firefox 118,1,FreeIPA Server,1,Function,1,Game Projects,1,Git,3,Google PageSpeed,1,How to,5,How to Install,9,HTTPS,1,Introduction,1,Iptables,1,ISO Image,1,KVM,1,Laravel,1,Let's Encrypt SSL,1,Linux,4,Linux 6.4,1,Linux Kernel 6.5,1,Linux Mint,1,Linux Server,1,Linux-Based Systems,1,Mageia 9,1,Magento,1,MariaDB,1,Media Server,1,ModSecurity,1,New Features,1,Nextcloud,2,NGINX,2,Nvidia CUDA,1,odoo,1,Oracles,1,Performance,1,PHP Zip Module,1,pip,1,Plex,1,Port Forwarding,1,postgresql,2,Privacy,1,Programming,1,Pylint,1,python,5,Python 3.10,2,Quantum,1,Quantum Computers,1,Remote Branch,1,Renew,1,RHEL,1,Rocky Linux 9,2,Rufus,1,Shadow Password,1,SQLite,1,SSH,1,SSH key,1,SSH Keys,1,Step-by-Step,4,SuiteCRM,1,SUSE Linux,1,Syslog,1,System,1,Testing,1,Top 10,1,Translation,1,Ubuntu,1,Ubuntu 18.04,1,Ubuntu 20.04,5,Ubuntu 22.10,1,Ubuntu 23.04,1,Ubuntu Server,1,Ubuntu Upgrade,1,unsupported,1,Up-to-Date,1,Upgrade,1,Visual Studio Code,1,Vivaldi 6.2,1,Web 3.0,1,Web Hosting Security,1,Web Security,1,Webmin,1,What's New,1,Windows 11,1,
ltr
item
Linux code EDU: How to Install Magento E-commerce Site on Debian 12 with Nginx and Elasticsearch
How to Install Magento E-commerce Site on Debian 12 with Nginx and Elasticsearch
Learn how to install Magento, the leading e-commerce platform, on Debian 12 with Nginx and Elasticsearch.
https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEj1W-EoQBBHvk8EBn7hb_EBIO2-02BFdKZwWipu1hxvIam_SC1Y7CzPzVHsXsl0qODiPh7is9qwNlMkF7I1HCpRtAfjvUaGVIT0MUDHf4CfONv52YKGIv8STcfW1ZL-G0FHex3AKI_NuYc-1NNyrfblNjFPXPa1yaHN-CfGMQWGnn--V3kx3rsGAtBv25U8/w640-h366/How-to-Install-Magento-E-commerce-Site-on-Debian-12-with-Nginx-and-Elasticsearch.jpg
https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEj1W-EoQBBHvk8EBn7hb_EBIO2-02BFdKZwWipu1hxvIam_SC1Y7CzPzVHsXsl0qODiPh7is9qwNlMkF7I1HCpRtAfjvUaGVIT0MUDHf4CfONv52YKGIv8STcfW1ZL-G0FHex3AKI_NuYc-1NNyrfblNjFPXPa1yaHN-CfGMQWGnn--V3kx3rsGAtBv25U8/s72-w640-c-h366/How-to-Install-Magento-E-commerce-Site-on-Debian-12-with-Nginx-and-Elasticsearch.jpg
Linux code EDU
https://linuxcodeedu.blogspot.com/2023/08/how-to-install-magento-e-commerce-site.html
https://linuxcodeedu.blogspot.com/
https://linuxcodeedu.blogspot.com/
https://linuxcodeedu.blogspot.com/2023/08/how-to-install-magento-e-commerce-site.html
true
6096992636254302192
UTF-8
Loaded All Posts Not found any posts VIEW ALL Readmore Reply Cancel reply Delete By Home PAGES POSTS View All RECOMMENDED FOR YOU LABEL ARCHIVE SEARCH ALL POSTS Not found any post match with your request Back Home Sunday Monday Tuesday Wednesday Thursday Friday Saturday Sun Mon Tue Wed Thu Fri Sat January February March April May June July August September October November December Jan Feb Mar Apr May Jun Jul Aug Sep Oct Nov Dec just now 1 minute ago $$1$$ minutes ago 1 hour ago $$1$$ hours ago Yesterday $$1$$ days ago $$1$$ weeks ago more than 5 weeks ago Followers Follow THIS PREMIUM CONTENT IS LOCKED STEP 1: Share to a social network STEP 2: Click the link on your social network Copy All Code Select All Code All codes were copied to your clipboard Can not copy the codes / texts, please press [CTRL]+[C] (or CMD+C with Mac) to copy Table of Content