Contoh Konfigurasi Server Block Laravel5 di Nginx
Berikut adalah contoh Konfigurasi server blok nginx untuk Laravel5 sebagai domain induk dan sub direktori
Laravel5 Sebagai Domain Induk di Nginx
server {
listen 80;
server_name laravelqu.mastohir.com;
root /usr/share/nginx/html/laravel5/public;
index index.php;
location / {
try_files $uri $uri/ /index.php?$query_string;
}
# Remove trailing slash to please routing system.
if (!-d $request_filename) {
rewrite ^/(.+)/$ /$1 permanent;
}
# PHP FPM configuration.
location ~* \.php$ {
fastcgi_pass unix:/run/php/php7.1-fpm.sock;
fastcgi_index index.php;
fastcgi_split_path_info ^(.+\.php)(.*)$;
include /etc/nginx/fastcgi_params;
#fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
fastcgi_intercept_errors off;
fastcgi_buffer_size 64k;
fastcgi_buffers 512 64k;
}
}
Laravel5 Sebagai Sub Direktori di Nginx
server {
listen 80;
server_name localhost;
root /usr/share/nginx/html;
index index.php;
location / {
try_files $uri $uri/ /index.php?$uri&$args;
}
location ~ [^/]\.php(/|$) {
fastcgi_split_path_info ^(.+?\.php)(/.*)$;
if (!-f $document_root$fastcgi_script_name) {
return 404;
}
# Mitigate https://httpoxy.org/ vulnerabilities
fastcgi_param HTTP_PROXY "";
#fastcgi_pass 127.0.0.1:9000;
fastcgi_pass unix:/run/php/php7.1-fpm.sock;
fastcgi_index index.php;
fastcgi_read_timeout 600;
include fastcgi_params;
}
# sub directory of codeigniter
location /codeigniter {
try_files $uri $uri/ /codeigniter/index.php?$uri&$args;
}
# end codeigniter
# sub directory of laravel5
location ^~ /laravel5 {
alias /usr/share/nginx/html/laravel5/public;
try_files $uri $uri/ @laravel5;
location ~ \.php {
include snippets/fastcgi-php.conf;
fastcgi_pass unix:/run/php/php7.1-fpm.sock;
fastcgi_param SCRIPT_FILENAME /usr/share/nginx/html/laravel5/public/index.php;
}
}
location @laravel5 {
rewrite /laravel5/(.*)$ /laravel5/index.php?/$1 last;
}
# end laravel5
}
Tinggalkan komentar