How to Install Bagisto on Debian 11

Note – Debian 11 (Bullseye) reached its End of Life (EOL) on July 7, 2024.

Bagisto is an eCommerce ecosystem designed for all to build and scale your business. It's a free and open-source eCommerce framework that offers you a wide range of functionality and lets you have total control of your store. Built on top of the Laravel stack, it is coupled with easy product information management and fast time to market the product. Besides, the framework is very flexible and easy to use even for non-tech savvies. In this article, we are going to learn how to install Bagisto on Debian 11. So, let’s get started.

Update the System

Let's update your repository, packaages using the below command,

apt update -y 

apt upgrade -y 

Install Sudo using below command,

apt install sudo -y 

Installing LEMP Stack

Install PHP-FPM, Nginx web server, and MariaDB database using below command,

apt install nginx-full mariadb-server php-fpm php-cli php-common php-zip php-mysql php-gd php-intl php-curl php-imap php-mbstring php-xml php-json libpcre3 git -y

Edit the PHP configuration php.ini using nano editor,

nano /etc/php/7.4/fpm/php.ini
nano /etc/php/7.4/cli/php.ini

Update the following options,

memory_limit = 512M
max_execution_time = 360
date.timezone = America/Chicago 

Restart the PHP-FPM service to apply new configuration,

systemctl restart php7.4-fpm

Configure MariaDB

Secure MariaDB using below command,

mysql_secure_installation

Output:

root@vps:~# mysql_secure_installation

NOTE: RUNNING ALL PARTS OF THIS SCRIPT IS RECOMMENDED FOR ALL MariaDB
      SERVERS IN PRODUCTION USE!  PLEASE READ EACH STEP CAREFULLY!

In order to log into MariaDB to secure it, we'll need the current
password for the root user. If you've just installed MariaDB, and
haven't set the root password yet, you should just press enter here.

Enter current password for root (enter for none): 
OK, successfully used password, moving on...

Setting the root password or using the unix_socket ensures that nobody
can log into the MariaDB root user without the proper authorisation.

You already have your root account protected, so you can safely answer 'n'.

Switch to unix_socket authentication [Y/n] y
Enabled successfully!
Reloading privilege tables..
 ... Success!

You already have your root account protected, so you can safely answer 'n'.

Change the root password? [Y/n] n
 ... skipping.

By default, a MariaDB installation has an anonymous user, allowing anyone
to log into MariaDB without having to have a user account created for
them.  This is intended only for testing, and to make the installation
go a bit smoother.  You should remove them before moving into a
production environment.

Remove anonymous users? [Y/n] y
 ... Success!

Normally, root should only be allowed to connect from 'localhost'.  This
ensures that someone cannot guess at the root password from the network.

Disallow root login remotely? [Y/n] y
 ... Success!

By default, MariaDB comes with a database named 'test' that anyone can
access.  This is also intended only for testing, and should be removed
before moving into a production environment.

Remove test database and access to it? [Y/n] y
 - Dropping test database...
 ... Success!
 - Removing privileges on test database...
 ... Success!

Reloading the privilege tables will ensure that all changes made so far
will take effect immediately.

Reload privilege tables now? [Y/n] y
 ... Success!

Cleaning up...

All done!  If you've completed all of the above steps, your MariaDB
installation should now be secure.

Thanks for using MariaDB!

Create New Database and User for Bagiosto

Log in to the MariaDB shell as user root using below command,

mysql -u root -p

CREATE DATABASE bagisto_db;

CREATE USER bagistouser@localhost IDENTIFIED BY 'Your_Password_Here';

GRANT ALL ON bagisto_db.* TO bagistouser@localhost WITH GRANT OPTION;

FLUSH PRIVILEGES;

EXIT

Replace Your_Password_Here with your actual/strong password

Install Composer Tool

First install the required packages for composer tool using below command,

apt install curl php-cli php-mbstring git unzip

Download and Install Composer,

curl -sS https://getcomposer.org/installer -o composer-setup.php

HASH=`curl -sS https://composer.github.io/installer.sig`

Verify the Installer using below command,

php -r "if (hash_file('SHA384', 'composer-setup.php') === '$HASH') { echo 'Installer verified'; } else { echo 'Installer corrupt'; unlink('composer-setup.php'); } echo PHP_EOL;"

Output:

root@vps:~# php -r "if (hash_file('SHA384', 'composer-setup.php') === '$HASH') { echo 'Installer verified'; } else { echo 'Installer corrupt'; unlink('composer-setup.php'); } echo PHP_EOL;"
Installer verified
root@vps:~# 

Download and Install Composer,

sudo php composer-setup.php --install-dir=/usr/local/bin --filename=composer

Output:

root@vps:~# sudo php composer-setup.php --install-dir=/usr/local/bin --filename=composer
All settings correct for using Composer
Downloading...

Composer (version 2.5.5) successfully installed to: /usr/local/bin/composer
Use it: php /usr/local/bin/composer
root@vps:~# 

Install Bagisto on Debian 11

Install Bagisto manually using the composer,

mkdir -p /var/www/{.cache,.config}

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

Create the /var/www/project directory and change the ownership to www-data

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

Move to directory /var/www/project and run the Composer command to download and install Bagisto like below,

cd /var/www/project

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

Output:

Package manifest generated successfully.
96 packages you are using are looking for funding.
Use the `composer fund` command to find out more!
Found 13 security vulnerability advisories affecting 4 packages.
Run composer audit for a full list of advisories.
> @php artisan key:generate
Application key set successfully.
> Webkul\Core\Events\ComposerEvents::postCreateProject

 ____              _     _
| __ )  __ _  __ _(_)___| |_ ___
|  _ \ / _` |/ _` | / __| __/ _ \
| |_) | (_| | (_| | \__ \ || (_) |
|____/ \__,_|\__, |_|___/\__\___/
             |___/

Welcome to the Bagisto project! Bagisto Community is an open-source e-commerce ecosystem 
which is built on top of Laravel and Vue.js.

Made with 💖  by the Bagisto Team. Happy helping :)

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

cd /var/www/project/bagisto

nano .env

Update the following configuration,

APP_URL=https://dev1.domainhere.info
DB_DATABASE=bagisto_db
DB_USERNAME=bagisto_user
DB_PASSWORD=Your-Strong-Passwd

Save the configuration file and install Bagisto using below command,

sudo -u www-data php artisan bagisto:install

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

Output:

Generated optimized autoload files containing 9570 classes

-----------------------------
Congratulations!
The installation has been finished and you can now use Bagisto.
Go to http://dev1.domainhere.info/admin and authenticate with:
Email: admin@example.com
Password: admin123
Cheers!

Configure Nginx Web Server

Create new virtual host configuration for bagisto using the nano editor,

nano /etc/nginx/sites-available/bagisto

Add the following into the file,

server {
    listen 80;
    server_name dev1.domainhere.info;
    return 302 https://$server_name$request_uri;
}

server {
  listen 443 ssl http2;

    server_name  dev1.domainhere.info;
    root   /var/www/bagisto/public;
    index  index.php;

  ssl_certificate /etc/letsencrypt/live/dev1.domainhere.info/fullchain.pem;
  ssl_certificate_key /etc/letsencrypt/live/dev1.domainhere.info/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/dev1.domainhere.info.access.log;
    error_log /var/log/nginx/dev1.domainhere.info.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;
    }
}

Replace dev1.domainhere.info with your actual domain name

Save the configuration file and exit.

Next, Activate the bagisto server block using the below command,

ln -s /etc/nginx/sites-available/bagisto /etc/nginx/sites-enabled/

Installing the Let’s Encrypt Certificates

Install Certbot on your Debian system using the below command,

apt install certbot python3-certbot-nginx

Generate the certificates, using the following command,

certbot certonly --standalone -d dev1.domainhere.info

Replace dev1.domainhere.info with your actual domain name

Restart the Nginx using below command,

systemctl restart nginx

Verify Nginx configuration,

nginx -t

Output:

root@vps:~# nginx -t
nginx: the configuration file /etc/nginx/nginx.conf syntax is ok
nginx: configuration file /etc/nginx/nginx.conf test is successful
root@vps:~# 

Accessing Bagisto Web Interface

Once successfully installed the Bagisto, open web browser and access the Bagisto using the URL https://dev1.domainhere.info, this will be redirected to the Bagisto interface page

Replace the dev1.domainhere.info with your actual domain name

images


CrownCloud - Get a SSD powered KVM VPS at $4.5/month!
Use the code WELCOME for 10% off!

1 GB RAM / 25 GB SSD / 1 CPU Core / 1 TB Bandwidth per month

Available Locations: LAX | MIA | ATL | FRA | AMS