Featured

Laravel Octane Setup on VPS (Step-by-Step Guide for 2025)

T
Team
·8 min read
#laravel#octane#vps#php#backend#performance

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

  • Super-fast response times (2x to 10x faster than traditional PHP-FPM)
  • Lower CPU and memory usage per request
  • Supports both Swoole and RoadRunner application servers
  • Ideal for high-traffic APIs, real-time dashboards, and large-scale applications

  • ---


    Prerequisites


    Before starting, ensure your VPS meets these requirements:

  • Ubuntu 22.04+ or Debian 11+
  • PHP 8.2+ with necessary extensions
  • Composer for dependency management
  • Nginx or Apache web server
  • Git for version control
  • Laravel 10 or 11 installed and configured

  • ---


    Step 1 — Update Your VPS


    First, update your system packages to ensure you have the latest security patches and updates:


    bash
    1sudo apt update && sudo apt upgrade -y

    ---


    Step 2 — Install PHP & Extensions


    Install PHP and all required extensions for Laravel:


    bash
    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:


    bash
    1curl -sS https://getcomposer.org/installer | php
    2sudo mv composer.phar /usr/local/bin/composer
    3composer --version

    ---


    Step 4 — Clone or Create Laravel Project


    Set up your Laravel project:


    bash
    1cd /var/www
    2git clone https://github.com/yourusername/todoproject.git
    3cd todoproject
    4composer install
    5cp .env.example .env
    6php artisan key:generate

    ---


    Step 5 — Install Laravel Octane


    Install Octane via Composer and run the installation command:


    bash
    1composer require laravel/octane
    2php artisan octane:install

    When prompted, choose your preferred application server — Swoole (recommended for most use cases) or RoadRunner.


    ---


    Step 6 — Install Swoole or RoadRunner


    Option 1: Install Swoole

    bash
    1sudo apt install php-swoole

    Option 2: Install RoadRunner

    bash
    1./vendor/bin/rr get-binary

    ---


    Step 7 — Start Laravel Octane Server


    Start the Octane server:


    bash
    1php artisan octane:start --server=swoole --host=0.0.0.0 --port=8000

    You 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:


    bash
    1sudo nano /etc/nginx/sites-available/laravel

    Add this configuration to proxy requests to Octane:


    nginx
    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:


    bash
    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:


    bash
    1sudo apt install supervisor -y

    Create the Octane supervisor configuration:


    bash
    1sudo nano /etc/supervisor/conf.d/octane.conf

    Add this configuration:


    text
    1[program:octane]
    2command=php artisan octane:start --server=swoole --host=127.0.0.1 --port=8000
    3directory=/var/www/todoproject
    4autostart=true
    5autorestart=true
    6user=www-data
    7redirect_stderr=true
    8stdout_logfile=/var/log/octane.log

    Apply the configuration and start Octane:


    bash
    1sudo supervisorctl reread
    2sudo supervisorctl update
    3sudo supervisorctl start octane

    ---


    Step 10 — Test Performance


    Use ApacheBench or k6 to test your application's performance:


    bash
    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:

  • High-traffic apps
  • Real-time dashboards
  • APIs needing quick response times

  • Keep your Octane server monitored and restart occasionally during deployments.


    ---


    Keywords to Target


    text
    1laravel octane setup
    2laravel octane swoole
    3laravel octane vps installation
    4laravel performance optimization 2025
    5laravel 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.