Guides 11792 Published by

This tutorial walks you through setting up Bagisto on an Ubuntu or Debian server, beginning with updating your system to prevent later dependency issues. It covers installing the necessary PHP extensions and other core packages, creating a MySQL database with proper UTF‑8 settings, and cloning the Bagisto repository into your web root. After pulling the code, Composer installs production dependencies while environment variables are configured for database access and URL routing, followed by running migrations, seeding data, and creating an admin user via artisan commands. Finally, you adjust file permissions for the web server, configure Nginx or Apache to serve the storefront, and verify that the shop loads correctly in a browser.



How to Install Bagisto on Ubuntu/Debian Servers

If you’re looking to spin up a modern, open‑source e‑commerce storefront on an Ubuntu or Debian machine, Bagisto is the framework that’s been making waves lately. This guide walks through the exact steps I use myself—no fluff, just what you need to get the shop running.

Step 1: Get Your Base System Ready

Before diving into PHP and Composer, make sure your server is up‑to‑date so you avoid weird dependency headaches.

sudo apt update && sudo apt upgrade -y

Why it matters? An outdated kernel or glibc can break the PHP build step later. I’ve seen this happen after a bad driver update that left PHP 8.1 complaining about missing extensions.

Step 2: Install Core Dependencies

Bagisto relies on PHP, Composer, MySQL/MariaDB, and some system libraries. Pull them in with one command:

sudo apt install -y php php-cli php-fpm php-mbstring php-xml php-gd php-curl \
                    mysql-server git unzip curl

Each extension is a piece of the puzzle: mbstring handles multibyte strings, xml and curl let Bagisto talk to external APIs, and gd powers image manipulation. Skip any and you’ll hit errors later.

Step 3: Set Up MySQL (or MariaDB)

Create a fresh database user for the shop:

sudo mysql -u root -p

CREATE DATABASE bagisto CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;
GRANT ALL PRIVILEGES ON bagisto.* TO 'bagisto_user'@'localhost' IDENTIFIED BY 'StrongPassword!';
FLUSH PRIVILEGES;
EXIT;

Using utf8mb4 ensures emoji and non‑Latin scripts display correctly. I’ve seen sites crash when the charset is wrong because product titles get mangled.

Step 4: Pull Bagisto from GitHub

Navigate to your web root (e.g., /var/www/html) and clone the repo:

cd /var/www/html
sudo git clone https://github.com/bagisto/storefront.git
sudo chown -R $USER:$USER storefront

We’ll keep ownership on you so Composer can write files without sudo later.

Step 5: Install PHP Dependencies with Composer
cd storefront
composer install --no-dev

The --no-dev flag skips dev packages like PHPUnit, saving disk space. If Composer spits out “Permission denied” errors, double‑check the folder ownership from Step 4.

Step 6: Configure Environment Variables

Copy the example environment file and edit it:

cp .env.example .env
nano .env

Update these lines to match your database credentials:

DB_CONNECTION=mysql
DB_HOST=127.0.0.1
DB_PORT=3306
DB_DATABASE=bagisto
DB_USERNAME=bagisto_user
DB_PASSWORD=StrongPassword!

Also set APP_URL to your server’s public address, e.g., http://shop.example.com. I’ve run into broken URLs before when this was left as the default localhost placeholder.

Step 7: Run Migrations and Seed Data
php artisan migrate --seed

The migration creates tables; seeding populates them with sample categories, products, and admin users. If you hit “SQLSTATE[HY000]” errors, double‑check that MySQL is listening on the port you specified.

Step 8: Create a Superuser (Admin Account)
php artisan bagisto:create-admin \
    --name="Jane Doe" \
    --email="admin@example.com" \
    --password="SecurePass123"

This command drops you straight into the admin panel without the need to log in via the front‑end. I’ve used it after accidental data loss and had to rebuild the whole shop from scratch.

Step 9: Set File Permissions for Web Server

If you’re running Nginx or Apache, give it write access to storage and bootstrap/cache:

sudo chown -R www-data:www-data storage bootstrap/cache
sudo chmod -R ug+rwx storage bootstrap/cache

Without proper permissions the shop will complain about “Cannot write to config file” during updates.

Step 10: Point Your Web Server to Bagisto

For Nginx, a minimal server block:

server {
    listen 80;
    server_name shop.example.com;

    root /var/www/html/storefront/public;
    index index.php index.html;

    location ~ \.php$ {
        try_files $uri =404;
        fastcgi_pass unix:/run/php/php8.1-fpm.sock; # adjust PHP version
        include fastcgi_params;
        fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
    }

    location / {
        try_files $uri $uri/ /index.php?$query_string;
    }
}

Restart Nginx after saving:

sudo systemctl restart nginx

If you’re on Apache, just enable mod_rewrite and point the document root to /var/www/html/storefront/public.

Step 11: Verify Everything Works

Open your browser at http://shop.example.com. You should see Bagisto’s homepage. Log in with the admin account you created. If any pages return a 500 error, check storage/logs/laravel.log for clues.

That’s it—Bagisto is now up and running on Ubuntu/Debian. Happy hacking, and may your sales stay as smooth as your code!