By py1210
I am using Digital Ocean VPS with a LEMP stack. I am struggling in the problem that return 404|not Found when accessing to my website. My lavarel project is stored as /var/www/html/api. It works fine with default /var/www/html root. My current config file is:
server {
listen 80 default_server;
listen [::]:80 default_server;
root /var/www/html/api/public;
#root /var/www/html; //ok
# Add index.php to the list if you are using PHP
index index.php index.html index.htm index.nginx-debian.html;
server_name ipaddress;
client_max_body_size 64M;
location / {
try_files $uri $uri/ /index.php$is_args$args;
}
location ~ \.php$ {
include snippets/fastcgi-php.conf;
fastcgi_pass unix:/run/php/php7.2-fpm.sock;
}
}
Any help would be appreciative. Thanks a lot.
This textbox defaults to using Markdown to format your answer.
You can type !ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!
Hey,
Question, have you checked the log files and can you also provide us with it ? Although I also suspect as @denislavgavrilov mentioned that this is a permissions problem.
Regards, Ivan
Hey, @py1210 ,
From what I can see, the nginx configuration seems perfectly fine. Could you please try and readjust the permissions for your Laravel projects with these:
sudo find /path/to/your/laravel/root/directory -type f -exec chmod 664 {} \;
sudo find /path/to/your/laravel/root/directory -type d -exec chmod 775 {} \;
Also, please make sure to make the www-data owner of the directory:
sudo chown www-data:www-data /path/to/your/laravel/root/directory
I hope this helps and feel free to keep the conversation going!
Best,
Hi @denislavgavrilov , Thanks a lot for your detailed instruction. I followed your comment and below is the terminal output.
root@customize:/var/log/nginx# sudo find /var/www/html/api -type f -exec chmod 664 {} \;
root@customize:/var/log/nginx# sudo find /var/www/html/api -type d -exec chmod 775 {} \;
root@customize:/var/log/nginx# cd /var/www/html/api
root@customize:/var/www/html/api# sudo chgrp -R www-data storage bootstrap/cache
root@customize:/var/www/html/api# sudo chmod -R ug+rwx storage bootstrap/cache
root@customize:/var/www/html/api#
root@customize:/var/www/html/api#
root@customize:/var/www/html/api# ls -lrt
total 424
drwxrwxr-x 10 www-data www-data 4096 Jun 15 01:35 Modules
-rw-rw-r-- 1 www-data www-data 1686 Jun 15 01:35 artisan
drwxrwxr-x 6 www-data www-data 4096 Jun 15 01:35 app
-rw-rw-r-- 1 www-data www-data 537 Jun 15 01:35 webpack.mix.js
drwxrwxr-x 4 www-data www-data 4096 Jun 15 01:35 tests
drwxrwxr-x 5 www-data www-data 4096 Jun 15 01:35 storage
-rw-rw-r-- 1 www-data www-data 563 Jun 15 01:35 server.php
drwxrwxr-x 2 www-data www-data 4096 Jun 15 01:35 routes
.....
-rw-rw-r-- 1 www-data www-data 1125 Jun 15 01:35 package.json
drwxrwxr-x 3 www-data www-data 4096 Jun 15 01:35 database
drwxrwxr-x 2 www-data www-data 4096 Jun 15 01:35 config
-rw-rw-r-- 1 www-data www-data 2451 Jun 15 03:19 composer.json
drwxrwxr-x 3 www-data www-data 4096 Jun 15 04:16 bootstrap
drwxrwxr-x 71 www-data www-data 4096 Jun 15 04:42 vendor
-rw-rw-r-- 1 www-data www-data 355447 Jun 15 04:42 composer.lock
drwxrwxr-x 2 www-data www-data 4096 Jun 16 01:04 public
root@customize:/var/www/html/api# tail -n 20 /var/log/nginx/error.log
Nothing appeared in last tail command.And the 404|Not Found stayed the same when accessing to the website. Thanks. Ny
Get paid to write technical tutorials and select a tech-focused charity to receive a matching donation.
Full documentation for every DigitalOcean product.
The Wave has everything you need to know about building a business, from raising funding to marketing your product.
Stay up to date by signing up for DigitalOcean’s Infrastructure as a Newsletter.
New accounts only. By submitting your email you agree to our Privacy Policy
Scale up as you grow — whether you're running one virtual machine or ten thousand.
Sign up and get $200 in credit for your first 60 days with DigitalOcean.*
*This promotional offer applies to new accounts only.