DebianLinuxTutorials

How To Install Bagisto on Debian 11

Install Bagisto on Debian 11

In this tutorial, we will show you how to install Bagisto on Debian 11. For those of you who didn’t know, Bagisto is a free and open-source e-commerce platform. It is built on various open sources technologies such as Laravel and Vue.js. Bagisto is a hand-tailored eCommerce that allows you to build your online store in no time. It is fast, responsive, beautifully frontend, and easy to use.

This article assumes you have at least basic knowledge of Linux, know how to use the shell, and most importantly, you host your site on your own VPS. The installation is quite simple and assumes you are running in the root account, if not you may need to add ‘sudo‘ to the commands to get root privileges. I will show you through the step-by-step installation of the Bagisto open-source eCommerce on a Debian 11 (Bullseye).

Prerequisites

  • A server running one of the following operating systems: Debian 10 or Debian 11.
  • It’s recommended that you use a fresh OS install to prevent any potential issues.
  • A non-root sudo user or access to the root user. We recommend acting as a non-root sudo user, however, as you can harm your system if you’re not careful when acting as the root.

Install Bagisto on Debian 11 Bullseye

Step 1. Before we install any software, it’s important to make sure your system is up to date by running the following apt commands in the terminal:

sudo apt update
sudo apt upgrade

Step 2. Installing the LEMP stack.

A Debian 11 LEMP server is required. If you do not have LEMP installed, Please read our previous tutorial to install LEMP Server on Debian 11.

Step 3. Configuring MariaDB.

By default, MariaDB is not hardened. You can secure MariaDB using the mysql_secure_installation script. You should read and below each step carefully which will set the root password, remove anonymous users, disallow remote root login, and remove the test database and access to secure MariaDB:

mysql_secure_installation

Configure it like this:

- Set 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

Next, we will need to log in to the MariaDB console and create a database for Bagisto. Run the following command:

mysql -u root -p

This will prompt you for a password, so enter your MariaDB root password and hit Enter. Once you are logged in to your database server, you need to create a database for Bagisto installation:

MariaDB [(none)]> CREATE DATABASE bagisto_db;
MariaDB [(none)]> CREATE USER 'bagisto_user'@'localhost' IDENTIFIED BY 'Your-Strong-Passwd';
MariaDB [(none)]> GRANT ALL PRIVILEGES ON bagisto_db.* to bagisto_user@'localhost';
MariaDB [(none)]> FLUSH PRIVILEGES;
MariaDB [(none)]> exit

Step 4. Installing Composer.

The Composer is needed for installing Bagisto eCommerce. Now run the following command below to install Composer on your Debian system:

php -r "copy('https://getcomposer.org/installer', 'composer-setup.php');"
php -r "if (hash_file('sha384', 'composer-setup.php') === '906a84df04cea2aa72f40b5f787e49f22d4c2f19492ac310e8cba5b96ac8b64115ac402c8cd292b8a03482574915d1a8') { echo 'Installer verified'; } else { echo 'Installer corrupt'; unlink('composer-setup.php'); } echo PHP_EOL;"

Next, run the installer script ‘composer-setup.php‘ to install the Composer:

php composer-setup.php
php -r "unlink('composer-setup.php');"

After that, move and rename the ‘composer.phar to ‘/usr/local/bin/composer‘ :

sudo mv composer.phar /usr/local/bin/composer

Step 5. Installing Bagisto on Debian 11.

Now we install the Bagisto manually through the Composer:

mkdir -p /var/www/{.cache,.config}
sudo chown -R www-data:www-data /var/www/{.cache,.config}

Next, create the ‘/var/www/project‘ directory and change the ownership to ‘www-data‘. You will be installing Bagisto on this directory:

mkdir -p /var/www/project; sudo chown -R www-data:www-data /var/www/project

After that, move a directory to /var/www/project and run the Composer command below to download and install Bagisto source code and all additional PHP dependencies:

cd /var/www/project
sudo -u www-data composer create-project bagisto/bagisto

Next, move to the /var/www/project/bagisto‘ directory and edit the ‘.env file using your favorite text editor:

cd /var/www/project/bagisto
sudo nano .env

Add the following configuration:

APP_NAME=Bagisto
APP_ENV=production

Change the APP_DEBUG‘ to ‘false’ and enter your installation URL on the ‘APP_URL‘:

APP_DEBUG=false
APP_URL=https://www.your-domain.com

Configuring a detailed database for your Bagisto installation as below:

DB_CONNECTION=mysql
DB_HOST=127.0.0.1
DB_PORT=3306
DB_DATABASE=bagisto_db
DB_USERNAME=bagisto_user
DB_PASSWORD=Your-Strong-Passwd
DB_PREFIX=

Save the configuration and exit, Then install the Bagisto eCommerce using the following command:

sudo -u www-data php artisan bagisto:install

We will need to change some folders permissions:

sudo chown -R www-data:www-data /var/www/project/bagisto

Step 5. Configure Nginx.

Now we create a new virtual host configuration ‘bagisto‘ using the nano editor:

sudo nano /etc/nginx/sites-available/bagisto

Add the following file:

server {
    listen 80;
    server_name your-domain.com;
    return 302 https://$server_name$request_uri;
}

server {
  listen 443 ssl http2;

    server_name  your-domain.com;
    root   /var/www/bagisto/public;
    index  index.php;

  ssl_certificate /etc/letsencrypt/live/your-domain.com/fullchain.pem;
  ssl_certificate_key /etc/letsencrypt/live/your-domain.com/privkey.pem;

  ssl_protocols TLSv1.2;
  ssl_prefer_server_ciphers on;
  ssl_ciphers ECDHE-RSA-AES256-GCM-SHA512:DHE-RSA-AES256-GCM-SHA512:ECDHE-RSA-AES256-GCM-SHA384:DHE-RSA-AES256-GCM-SHA384:ECDHE-RSA-AES256-SHA384;
  ssl_ecdh_curve secp384r1; # Requires nginx >= 1.1.0
  ssl_session_timeout  10m;
  ssl_session_cache shared:SSL:10m;
  ssl_session_tickets off; # Requires nginx >= 1.5.9
  # ssl_stapling on; # Requires nginx >= 1.3.7
  # ssl_stapling_verify on; # Requires nginx => 1.3.7
  resolver 8.8.8.8 8.8.4.4 valid=300s;
  resolver_timeout 5s;
  add_header X-Frame-Options DENY;
  add_header X-Content-Type-Options nosniff;
  add_header X-XSS-Protection "1; mode=block";

    access_log /var/log/nginx/your-domain.com.access.log;
    error_log /var/log/nginx/your-domain.com.error.log;

    client_max_body_size 100M;

    autoindex off;

    location / {
    try_files $uri /index.php$is_args$args;
      }

    location ~ \.php$ {
         include snippets/fastcgi-php.conf;
         fastcgi_pass unix:/var/run/php/php7.4-fpm.sock;
         include fastcgi_params;
         fastcgi_intercept_errors on;
    }
}

Save and close the file, then restart the Nginx web server so that the changes take place:

sudo ln -s /etc/nginx/sites-available/bagisto /etc/nginx/sites-enabled/
sudo systemctl restart nginx

Step 6. Installing the Let’s Encrypt Certificates.

First, install Certbot to your Debian system using the following command below:

sudo apt install certbot python3-certbot-nginx

Then, generate the certificates, with the following command:

sudo certbot --nginx -d your-domian.com -d www.your-domain.com

You will then be prompted to enter an email address for the certificate. After you have entered that you must agree to the T&C’s and decide if you want to share your email address with the Electronic Frontier Foundation. This last step is optional. Once successfully, Reload Nginx again to load all the new configurations.

Step 7. Configure Firewall.

By default, the UFW firewall is enabled on Debian. Depending on your Apache virtual host configuration file, open ports 80 and 443 to allow HTTP and HTTPS traffic:

sudo ufw allow 80/tcp
sudo ufw allow 443/tcp
sudo ufw reload

Step 8. Accessing Bagisto eCommerce Web Interface.

Once successfully installed, open your web browser and access the Bagisto using the URL https://your-domian.com. You will be redirected to the Bagisto interface page:

Install Bagisto on Debian 11 Bullseye

Congratulations! You have successfully installed Bagisto. Thanks for using this tutorial for installing the latest version of the Bagisto eCommerce on Debian 11 Bullseye. For additional help or useful information, we recommend you check the official Bagisto website.

VPS Manage Service Offer
If you don’t have time to do all of this stuff, or if this is not your area of expertise, we offer a service to do “VPS Manage Service Offer”, starting from $10 (Paypal payment). Please contact us to get the best deal!

r00t

r00t is an experienced Linux enthusiast and technical writer with a passion for open-source software. With years of hands-on experience in various Linux distributions, r00t has developed a deep understanding of the Linux ecosystem and its powerful tools. He holds certifications in SCE and has contributed to several open-source projects. r00t is dedicated to sharing her knowledge and expertise through well-researched and informative articles, helping others navigate the world of Linux with confidence.
Back to top button