Documentation/Launching the application/Nginx

Nginx

Running the HLEB2 framework using Nginx (or its fork Angie) can be accomplished with either nginx + PHP-FPM or nginx + apache, as well as with NGINX Unit.
This guide will only cover the nginx + PHP-FPM option as it is the most common.

Basic configuration for Nginx + PHP-FPM:

server {
    listen 80;
    server_name mysite.com;

    # Path to the public folder
    root /var/www/mysite.com/public/;

    index index.php;

    location / {
        # Redirect all requests to index.php
        try_files   $uri $uri/ /index.php?$query_string;
    }

    # Process PHP files with FPM
    location ~ \.php$ {
        try_files $uri =404;
        include /etc/nginx/fastcgi.conf;
        # Path to the socket with the required PHP version
        fastcgi_pass unix:/run/php/php8.2-fpm.sock;
    }

    # Hide specific files
    location ~ /\.(ht|svn|git) {
        deny all;
    }
}

After starting the server, you can verify the installation by entering the previously assigned (locally or on a remote server) resource address in the browser's address bar.

Using PHP Server Running with Apache

Page translated: chatgpt 4-o
Back to top