Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

gitwithravish's avatar

Laravel Simultaneous Requests

Which deployment technique can be used to achieve simultaneous laravel requests ?

Currently I have deployed my laravel application using docker which is being served using command php artisan serve which uses php's built in server which supports only 1 request at a time. this

Is nginx and laravel deployment can be used to achieve simultaneous requests ? this

I have also heard about laravel octane and php-fpm.

I could really use someone's help to get started in the right direction !

0 likes
3 replies
LaryAI's avatar
Level 58

Yes, using Nginx and Laravel deployment can achieve simultaneous requests. Nginx is a high-performance web server that can handle multiple requests at the same time.

Here's an example of how to set up Nginx and Laravel deployment using Docker Compose:

  1. Create a Dockerfile for your Laravel application:
FROM php:7.4-fpm

WORKDIR /var/www/html

COPY . /var/www/html

RUN apt-get update && \
    apt-get install -y \
        libzip-dev \
        zip \
        unzip && \
    docker-php-ext-install pdo_mysql zip && \
    curl -sS https://getcomposer.org/installer | php -- --install-dir=/usr/local/bin --filename=composer

RUN composer install --no-interaction --no-dev --prefer-dist --optimize-autoloader

RUN chown -R www-data:www-data /var/www/html/storage /var/www/html/bootstrap/cache

CMD ["php-fpm"]

EXPOSE 9000
  1. Create a docker-compose.yml file:
version: '3'

services:
  app:
    build:
      context: .
      dockerfile: Dockerfile
    volumes:
      - .:/var/www/html
    environment:
      - APP_ENV=production
      - APP_DEBUG=false
      - APP_KEY=your-app-key
      - DB_CONNECTION=mysql
      - DB_HOST=db
      - DB_PORT=3306
      - DB_DATABASE=your-db-name
      - DB_USERNAME=your-db-username
      - DB_PASSWORD=your-db-password
    depends_on:
      - db
    networks:
      - app-network

  db:
    image: mysql:5.7
    environment:
      - MYSQL_DATABASE=your-db-name
      - MYSQL_USER=your-db-username
      - MYSQL_PASSWORD=your-db-password
      - MYSQL_ROOT_PASSWORD=your-db-root-password
    volumes:
      - db-data:/var/lib/mysql
    networks:
      - app-network

networks:
  app-network:

volumes:
  db-data:
  1. Run the following command to start the containers:
docker-compose up -d
  1. Configure Nginx to serve your Laravel application:
server {
    listen 80;
    server_name your-domain.com;
    root /var/www/html/public;

    index index.php;

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

    location ~ \.php$ {
        fastcgi_pass app:9000;
        fastcgi_index index.php;
        fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
        include fastcgi_params;
    }
}
  1. Restart Nginx:
sudo service nginx restart

Now your Laravel application should be running on Nginx and able to handle simultaneous requests.

tykus's avatar

Any proper (not PHP's built-in one) web server along with PHP-FPM will handle concurrent requests when properly configured.

1 like
lara286950's avatar
Level 2

Hi @gitwithravish,

Yes, you can use Nginx and PHP-FPM deployment to achieve simultaneous Laravel requests.

Here are the steps to deploy Laravel with Nginx and PHP-FPM:

  1. Install Nginx and PHP-FPM on your server.
  2. Configure Nginx to point to your Laravel application's public directory as the document root.
  3. Configure PHP-FPM to manage your Laravel application's PHP processes.
  4. Adjust the Nginx configuration to send PHP requests to PHP-FPM.

Alternatively, you can also use Laravel Octane to achieve simultaneous requests. Laravel Octane is a high-performance application server for Laravel that can handle multiple requests simultaneously. It uses a combination of PHP's Swoole extension and Laravel's framework to achieve this.

Here are the steps to deploy Laravel with Octane:

  1. Install the Swoole extension for PHP.
  2. Install the Laravel Octane package.
  3. Configure your Laravel application to use Octane.
  4. Start the Octane server using the command line.

Both Nginx and Octane are good options for achieving simultaneous Laravel requests. Nginx is more widely used and can be easier to set up, while Octane is more powerful but may require more configuration.

Please or to participate in this conversation.