Deploying Laravel manually on a bare-metal Linux server can be tedious. You have to configure Nginx server blocks to point to the /public directory, handle Composer permissions, and ensure the correct PHP extensions are active. Stackrium automates this entire pipeline.
In this guide, we will walk through deploying a brand new Laravel 11 application using Stackrium's native framework optimization engine. Because Laravel 11 defaults to SQLite, we will also cover how Stackrium automatically provisions the required extensions.
Prerequisites
- A cloud VPS or dedicated server running Ubuntu 24.04 LTS.
- Stackrium Control Panel installed.
- A domain name with an A-Record pointed to your server's IP address.
Step 1: The Jailed System User
Security is paramount. Stackrium enforces a strict isolation architecture. Before we can deploy Laravel, we need to create a dedicated system user to host the application.
- Navigate to the Users & DBs tab in your Stackrium dashboard.
- Click Create User.
- Give the user a recognizable name (e.g.,
laravel_app) and generate a secure password.
/home/user/web/ directories to prevent cross-site contamination.
Step 2: Add the Domain & SSL
Next, we instruct Nginx to listen for our traffic and secure it.
- Go to the Web & Git tab and click New Domain.
- Enter your domain name (e.g.,
app.yourdomain.com) and assign it to the user you just created. - Once created, immediately go to the Security & DNS tab and click Issue Let's Encrypt SSL. Stackrium will handle the ACME challenge and securely reload Nginx.
Step 3: Deploying the Code
You have two options for getting your Laravel code onto the server:
Option A: Git Auto-Deployment (Recommended)
If your code is on GitHub or GitLab, use Stackrium's CI/CD Webhooks. Because Stackrium uses a "One User, One Identity" rule, simply copy the unique ED25519 SSH Deploy Key for your user and add it to your repository's deploy keys. Then, add the Stackrium webhook URL to your repository.
Option B: File Manager Upload
If you are uploading a .zip file manually:
# Navigate to your domain's document root
/home/laravel_app/web/app.yourdomain.com/public_html/
# Extract your Laravel files directly into public_html
# Ensure the artisan file is directly inside public_html
Step 4: The 1-Click Laravel Optimizer
This is where Stackrium shines. By default, Nginx looks for an index.php file in the root directory. However, Laravel's entry point is securely tucked away inside the /public folder.
Instead of manually writing Nginx directives, simply go to your domain in the Web & Git tab, click the App Engines button, and select Deploy Laravel.
Behind the scenes, Stackrium will automatically:
- Reconfigure the Nginx vHost document root to
/public_html/public. - Run
composer install --no-dev --optimize-autoloadersecurely as the jailed user. - Verify that the
storageandbootstrap/cachedirectories have the correct read/write permissions.
Step 5: SQLite Configuration (Laravel 11+)
Laravel 11 uses SQLite by default, which requires specific PHP extensions. Stackrium handles this automatically during the Laravel deployment phase by ensuring php8.3-sqlite3 and php8.3-xml are active via the Software Center.
To initialize your database, open the Stackrium Terminal (or SSH in) and run:
# Switch to your jailed user
su - laravel_app
# Navigate to your project
cd ~/web/app.yourdomain.com/public_html/
# Run the migrations
php artisan migrate --force
Conclusion
Your Laravel application is now live, secured with an SSL certificate, and running on a highly optimized Nginx and PHP-FPM stack. If you ever need to run scheduled tasks, you can add your artisan schedule:run command directly in the Stackrium Cron Jobs dashboard.