Laravel Octane Setup on VPS (Step-by-Step Guide for 2025)
Laravel Octane Setup on VPS (Step-by-Step Guide for 2025)
If you're looking to boost your Laravel app speed by 10x, Laravel Octane is the secret weapon you need.
Octane runs Laravel using high-performance application servers like Swoole or RoadRunner, giving you blazing-fast responses.
In this guide, we'll go step-by-step through installing and configuring Laravel Octane on a VPS.
---
What Is Laravel Octane?
Laravel Octane is a high-performance package that keeps your Laravel application in memory between requests, unlike traditional PHP-FPM setups that restart the framework on every request. This persistent application state results in dramatically improved performance.
Key Benefits
---
Prerequisites
Before starting, ensure your VPS meets these requirements:
---
Step 1 — Update Your VPS
First, update your system packages to ensure you have the latest security patches and updates:
1sudo apt update && sudo apt upgrade -y---
Step 2 — Install PHP & Extensions
Install PHP and all required extensions for Laravel:
1sudo apt install php php-cli php-common php-mbstring php-xml php-curl php-bcmath php-zip php-mysql unzip git -y---
Step 3 — Install Composer
Composer is essential for managing Laravel dependencies:
1curl -sS https://getcomposer.org/installer | php2sudo mv composer.phar /usr/local/bin/composer3composer --version---
Step 4 — Clone or Create Laravel Project
Set up your Laravel project:
1cd /var/www2git clone https://github.com/yourusername/todoproject.git3cd todoproject4composer install5cp .env.example .env6php artisan key:generate---
Step 5 — Install Laravel Octane
Install Octane via Composer and run the installation command:
1composer require laravel/octane2php artisan octane:installWhen prompted, choose your preferred application server — Swoole (recommended for most use cases) or RoadRunner.
---
Step 6 — Install Swoole or RoadRunner
Option 1: Install Swoole
1sudo apt install php-swooleOption 2: Install RoadRunner
1./vendor/bin/rr get-binary---
Step 7 — Start Laravel Octane Server
Start the Octane server:
1php artisan octane:start --server=swoole --host=0.0.0.0 --port=8000You can now access your Laravel application on port 8000 at: http://your-server-ip:8000
---
Step 8 — Configure Nginx for Laravel Octane
Create or edit your Nginx configuration:
1sudo nano /etc/nginx/sites-available/laravelAdd this configuration to proxy requests to Octane:
1server {2 listen 80;3 server_name projectdomain.com;4 root /var/www/todoproject/public;5 6 index index.php;7 location / {8 proxy_pass http://127.0.0.1:8000;9 proxy_set_header Host $host;10 proxy_set_header X-Real-IP $remote_addr;11 proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;12 }13}Enable the site and restart Nginx:
1sudo ln -s /etc/nginx/sites-available/laravel /etc/nginx/sites-enabled/2sudo systemctl restart nginx---
Step 9 — Set Up Supervisor (Auto-Restart)
Install Supervisor to automatically restart Octane if it crashes:
1sudo apt install supervisor -yCreate the Octane supervisor configuration:
1sudo nano /etc/supervisor/conf.d/octane.confAdd this configuration:
1[program:octane]2command=php artisan octane:start --server=swoole --host=127.0.0.1 --port=80003directory=/var/www/todoproject4autostart=true5autorestart=true6user=www-data7redirect_stderr=true8stdout_logfile=/var/log/octane.logApply the configuration and start Octane:
1sudo supervisorctl reread2sudo supervisorctl update3sudo supervisorctl start octane---
Step 10 — Test Performance
Use ApacheBench or k6 to test your application's performance:
1ab -n 1000 -c 50 http://127.0.0.1:8000/You should notice drastically improved response times and higher throughput compared to traditional PHP-FPM.
---
Final Notes
Laravel Octane is perfect for:
Keep your Octane server monitored and restart occasionally during deployments.
---
Keywords to Target
1laravel octane setup2laravel octane swoole3laravel octane vps installation4laravel performance optimization 20255laravel on ubuntu 22.04---
With this setup, your Laravel app can handle thousands of requests per second with minimal load — a true production-grade configuration for 2025.
Enjoyed this article?
Support our work and help us create more free content for developers.
Stay Updated
Get the latest articles and updates delivered to your inbox.