Laravel applications can run in when PHP Composer is installed and PHP is running in FastCGI mode (Nginx + PHP-FPM).

Since PHP Composer uses the site's root directory for its operation, the Laravel application will need to be placed in a subdirectory, and the site configuration will need to be modified manually.

In the server block, add the following line as the first entry in the location / section:

try_files $uri $uri/ /index.php?$query_string;

In the same block, add the following sections:

location /<project_directory> {
    alias /var/www/<user>/data/www/<site_name>/<project_directory>/public;
    try_files $uri $uri/ @<project_directory>;

    location ~ \.php$ {
      //Values from existing location @php
    }
}

location @<project_directory> {
    rewrite /<project_directory>/(.*)$ /<project_directory>/index.php?/$1 last;
}

For example, when placing PyroCMS in the pyrocms subdirectory on the domain.com site owned by user www-root, the new sections will be as follows:

location /pyrocms {
    alias /var/www/www-root/data/www/domain.com/pyrocms/public;
    try_files $uri $uri/ @pyrocms;
    location ~ \.php$ {
       include /etc/nginx/vhosts-resources/domain.com/dynamic/*.conf;
       fastcgi_index index.php;
       fastcgi_param PHP_ADMIN_VALUE "sendmail_path = /usr/sbin/sendmail -t -i -f webmaster@laravel.test";
       fastcgi_pass unix:/var/www/php-fpm/1.sock;
       fastcgi_split_path_info ^((?U).+\.ph(?:p\d*|tml))(/?.+)$;
       try_files $uri =404;
       include fastcgi_params;
    }
}

location @pyrocms {
    rewrite /pyrocms/(.*)$ /pyrocms/index.php?/$1 last;
}
Cette réponse était-elle pertinente? 0 Utilisateurs l'ont trouvée utile (0 Votes)