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 performance package that keeps your application in memory between requests — unlike traditional PHP-FPM setups that restart the framework on every request.


⚡ Key Benefits

  • Super-fast response times (2x to 10x faster)
  • Lower CPU and memory usage
  • Supports Swoole and RoadRunner
  • Ideal for APIs, dashboards, and large applications

  • ---


    🧰 Prerequisites


    Before starting, make sure your VPS has:

  • Ubuntu 22.04+ (or Debian)
  • PHP 8.2+
  • Composer
  • Nginx or Apache
  • Git
  • Laravel 10 or 11

  • ---


    ⚙️ Step 1 — Update Your VPS


    bash
    sudo apt update && sudo apt upgrade -y

    ---


    🧩 Step 2 — Install PHP & Extensions


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


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

    ---


    📦 Step 4 — Clone or Create Laravel Project


    bash
    cd /var/www
    git clone https://github.com/yourusername/todoproject.git
    cd todoproject
    composer install
    cp .env.example .env
    php artisan key:generate

    ---


    🔥 Step 5 — Install Laravel Octane


    bash
    composer require laravel/octane
    php artisan octane:install

    When prompted, choose your preferred server — Swoole (recommended) or RoadRunner.


    ---


    🧠 Step 6 — Install Swoole or RoadRunner


    Option 1: Install Swoole

    bash
    sudo apt install php-swoole

    Option 2: Install RoadRunner

    bash
    ./vendor/bin/rr get-binary

    ---


    🏗️ Step 7 — Start Laravel Octane Server


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

    You can now visit your server’s IP on port 8000, e.g.:

    👉 http://your-server-ip:8000


    ---


    ⚙️ Step 8 — Configure Nginx for Laravel Octane


    Open your Nginx config:


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

    Paste this configuration:


    nginx
    server {
        listen 80;
        server_name projectdomain.com;
        root /var/www/todoproject/public;
    
        index index.php;
        location / {
            proxy_pass http://127.0.0.1:8000;
            proxy_set_header Host $host;
            proxy_set_header X-Real-IP $remote_addr;
            proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
        }
    }

    Save and enable:


    bash
    sudo ln -s /etc/nginx/sites-available/laravel /etc/nginx/sites-enabled/
    sudo systemctl restart nginx

    ---


    🧩 Step 9 — Set Up Supervisor (Auto-Restart)


    Install Supervisor:

    bash
    sudo apt install supervisor -y

    Add Laravel Octane to Supervisor:

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

    Paste:

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

    Save and start:

    bash
    sudo supervisorctl reread
    sudo supervisorctl update
    sudo supervisorctl start octane

    ---


    🎯 Step 10 — Test Performance


    Use any tool like ApacheBench or k6 to test:


    bash
    ab -n 1000 -c 50 http://127.0.0.1:8000/

    You’ll notice drastically improved response times 🚀.


    ---


    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
    laravel octane setup
    laravel octane swoole
    laravel octane vps installation
    laravel performance optimization 2025
    laravel 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.


    Share this article

    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.