Bagisto is a free, open-source eCommerce software built with the Laravel PHP framework and utilizes Vue.js – a progressive JavaScript framework. This well-crafted eCommerce solution allows you to set up your online store swiftly. It is fast, responsive, has an attractive frontend, and is user-friendly. Bagisto supports multiple locales, currencies, various store themes, and offers a multi-store inventory system.
In this tutorial, we will guide you on installing Bagisto eCommerce on Debian 11 Bullseye using PHP-FPM, the Nginx web server, and a MariaDB database.
Prerequisites
- Latest version of Debian 11 Bullseye.
- A user with root or sudo privileges.
- A domain name pointed to your server’s IP address.
Installing LEMP Stack
First, install the LEMP stack on your Debian server. Bagisto requires PHP 7.4 or higher, MariaDB 10.2.17 or higher, and the Nginx web server.
Begin by updating your repository with the following command:
sudo apt update
Install PHP-FPM, Nginx web server, and MariaDB database using the command below:
sudo 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 unzip -y
Once all packages are installed, edit the PHP configuration files using the nano editor:
sudo nano /etc/php/7.4/fpm/php.ini sudo nano /etc/php/7.4/cli/php.ini
Modify the following settings to match your environment:
memory_limit = 512M max_execution_time = 360 date.timezone = America/Toronto
Restart the PHP-FPM service to apply the new configurations:
sudo systemctl restart php7.4-fpm
You’ve now completed the basic LEMP stack installation necessary for Bagisto eCommerce.
Setting Up MariaDB Root Password
After installing the LEMP stack, secure your MariaDB database by setting a root password. Use the ‘mysql_secure_installation‘ command:
mysql_secure_installation
Follow the prompts:
- Press ENTER to set up the root password.
- Type ‘Y‘ to switch root user authentication to Unix socket.
- Type ‘Y‘ to set the root password, then enter and confirm it.
- Type ‘Y‘ to remove anonymous users.
- Type ‘Y‘ to disable remote root login.
- Type ‘Y‘ to remove the test database.
- Type ‘Y‘ to reload privilege tables.
You have now secured your MariaDB deployment.
Setting Up Database and User for Bagisto
Create a new database and user for Bagisto. Log in to the MariaDB shell as root:
mysql -u root -p
Execute the following queries to create a database ‘bagisto’ and a user ‘bagistouser’ with the password ‘BagistoPassword’:
CREATE DATABASE bagisto; CREATE USER bagistouser@localhost IDENTIFIED BY 'BagistoPassword';
Grant permissions and reload privileges:
GRANT ALL ON bagisto.* TO bagistouser@localhost WITH GRANT OPTION; FLUSH PRIVILEGES;
Exit the MariaDB shell. Your database and user for Bagisto are ready.
Installing Composer
Composer is required for Bagisto installation. Download the Composer installer script and verify it:
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;"
Run the installer script and move Composer to a global location:
php composer-setup.php php -r "unlink('composer-setup.php');"
sudo mv composer.phar /usr/local/bin/composer
Verify the Composer installation:
sudo -u www-data composer --version
Installing Bagisto with Composer
Now, install Bagisto manually using Composer. Create necessary directories for cache and config:
mkdir -p /var/www/{.cache,.config} sudo chown -R www-data:www-data /var/www/{.cache,.config}
Set up the installation directory and change ownership:
mkdir -p /var/www/project sudo chown -R www-data:www-data /var/www/project
Navigate to your project directory and use Composer to install Bagisto:
cd /var/www/project sudo -u www-data composer create-project bagisto/bagisto
Edit the ‘.env‘ file to configure your installation:
cd /var/www/project/bagisto sudo nano .env
APP_NAME=Bagisto APP_ENV=production APP_DEBUG=false APP_URL=https://www.example.io DB_CONNECTION=mysql DB_HOST=127.0.0.1 DB_PORT=3306 DB_DATABASE=bagisto DB_USERNAME=bagistouser DB_PASSWORD=BagistoPassword DB_PREFIX=
Save and exit. Install Bagisto using this command:
sudo -u www-data php artisan bagisto:install
Upon completion, you will receive the default admin credentials.
Ensure the ownership of the installation directory:
sudo chown -R www-data:www-data /var/www/project/bagisto
Setting Up Nginx Web Server
Create a new Nginx server block for Bagisto. Create and edit the server block configuration file:
sudo nano /etc/nginx/sites-available/bagisto
server { listen 80; server_name example.io; return 302 https://$server_name$request_uri; } server { listen 443 ssl http2; server_name example.io; root /var/www/bagisto/public; index index.php; ssl_certificate /etc/letsencrypt/live/example.io/fullchain.pem; ssl_certificate_key /etc/letsencrypt/live/example.io/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/example.com.access.log; error_log /var/log/nginx/example.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 exit the configuration file. Enable the server block and verify Nginx configuration:
sudo ln -s /etc/nginx/sites-available/bagisto /etc/nginx/sites-enabled/ sudo nginx -t
Restart Nginx to apply changes:
sudo systemctl restart nginx
Verify Bagisto eCommerce
Open your web browser and navigate to your domain to verify the installation:
You should see the default Bagisto homepage:
Access the admin page and login with default credentials:
Conclusion
Congratulations! You’ve successfully installed Bagisto eCommerce with PHP-FPM, Nginx, and MariaDB on your Debian 11 Bullseye system. You can now start adding products and configuring payment plugins for your store.
FAQ
- What is Bagisto?
- Bagisto is a free, open-source eCommerce platform built using the Laravel PHP framework and Vue.js.
- What are the system requirements for Bagisto?
- Bagisto requires PHP 7.4 or higher, MariaDB 10.2.17 or higher, and an Nginx or Apache web server.
- Can I install Bagisto on a different OS?
- Yes, Bagisto can be installed on various Linux distributions, and other operating systems that support PHP, Composer, and Laravel.
- Is Bagisto suitable for beginners?
- Yes, Bagisto offers a user-friendly interface that makes it easy to build and manage an online store without extensive technical knowledge.