Here is my nginx.conf file :
The config file i've made not working and it doesn't go to http://localhost/api my system is manjaro
....
http {
....
server {
....
}
include /etc/nginx/sites-enabled/*;
}
and my laravel config file is :
server {
root /srv/tamsam/public;
index index.php index.html index.htm;
gzip on;
gzip_types text/plain application/xml text/css application/javascript;
gzip_min_length 1000;
location ~ \.php$ {
fastcgi_pass unix:/run/php-fpm/php-fpm.sock;
fastcgi_index index.php;
include fastcgi.conf;
}
location /storage {
alias /srv/tamsam/public;
try_files $uri $uri/ @laravelapi;
location ~ \.php$ {
fastcgi_pass unix:/run/php-fpm/php-fpm.sock;
fastcgi_index index.php;
include fastcgi.conf;
}
}
location /api {
alias /srv/tamsam/public;
try_files $uri $uri/ @laravelapi;
location ~ \.php$ {
fastcgi_pass unix:/run/php-fpm/php-fpm.sock;
fastcgi_index index.php;
include fastcgi.conf;
}
}
location @laravelapi {
rewrite /api/(.*)?$ /api/index.php?$is_args$args last;
}
}
but the http://localhost/api give me the error 404 Not Found
I appreciate your help thanks
CodePudding user response:
Looks like your @laravelapi
locations configuration is not correct.
location @laravelapi {
rewrite /api/(.*)$ /api/index.php last;
}
Please also check your php configuration
location ~ \.php$ {
fastcgi_split_path_info ^(. \.php)(/. )$;
fastcgi_pass unix:/var/run/php/php7.3-fpm.sock;
fastcgi_index index.php;
include fastcgi_params;
fastcgi_param SCRIPT_FILENAME $request_filename;
}
The fastcgi_param SCRIPT_FILENAME $request_filename;
is important to make it work.