我在使用nginx配置时遇到麻烦。
我只想使用laravel api,所以我不知道如何配置它。
因为我在http://138.68.232.50/pronto-back-end/public/api/上找不到404
我的配置/ etc / nginx / sites-available / default
server {
listen 80;
listen [::]:80;
# Log files for Debugging
access_log /var/log/nginx/laravel-access.log;
error_log /var/log/nginx/laravel-error.log;
root /var/www/html/pronto-back-end/public;
# Add index.php to the list if you are using PHP
index index.php index.html index.htm index.nginx-debian.html;
server_name 138.68.232.50;
location / {
# First attempt to serve request as file, then
# as directory, then fall back to displaying a 404.
try_files $uri $uri/ /index.php;
}
# pass PHP scripts to FastCGI server
#
location ~ \.php$ {
try_files $uri =404;
fastcgi_split_path_info ^(.+\.php)(/.+)$;
fastcgi_pass unix:/run/php/php7.2-fpm.sock;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi_params;
}
}
¡请帮助!
您的配置根目录缺少“ / api”。但是我想“ api”内部没有任何内容,因此您没有在根路径中包括它。如果是这种情况,请从网址中将其删除。否则一切正常。
编辑:由于您的问题基于NGINX。此文本上方的原始答案是正确的(请标记为答案),因为您可以在进行更改后看到Laravel页面。下面的补充仅用于帮助您了解如何正确使用Laravel。