So I deployed laravel app using lemp nginx droplet. It was working fine. I changed the project folder name from /var/www/html to /var/www/stand_blog and I ediied digitalocean file in /etc/nginx/sites-available so that the root points to /var/www/stand_blog/public. I restarted nginx using sudo systemctl restart nginx and it said time out error. I waited for around 15 minutes and tried again and it was restarted successfully. I checked sudo nginx -t and it says ok. But when I check the browser, I got view not found error. Is there anything I need to do? Thank you.
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!
Accepted Answer
Hey!
It sounds like you’ve taken the correct steps by updating the Nginx configuration file to point to the new directory and restarting Nginx. However, the “View Not Found” error in a Laravel application typically indicates an issue with the Laravel view files not being found where the framework expects them to be.
This could be due to several reasons, including file permissions, Laravel cache, or Nginx configuration issues. Here are a few suggestions that you could check:
Check File Permissions:
Ensure that the /var/www/stand_blog
directory and its contents have the correct permissions. Laravel needs certain permissions to read files and directories.
sudo chown -R www-data:www-data /var/www/stand_blog
sudo find /var/www/stand_blog -type f -exec chmod 644 {} \;
sudo find /var/www/stand_blog -type d -exec chmod 755 {} \;
Replace www-data:www-data
with the user and group Nginx runs as on your server if it’s different.
Clear Laravel Cache:
Sometimes, Laravel caches paths that might not update immediately after such changes. Clear the Laravel cache by running these commands from the root of your Laravel project (/var/www/stand_blog
):
php artisan cache:clear
php artisan config:clear
php artisan view:clear
php artisan route:clear
Check Nginx Configuration:
Double-check the Nginx configuration for any typos or mistakes, especially in the root
directive. It should point to the public
directory of your Laravel application:
root /var/www/stand_blog/public;
Also, ensure that the server_name
directive is correctly set to your domain or IP address.
Check Laravel’s .env File:
Ensure that the .env
file in your Laravel project (/var/www/stand_blog/.env
) is correctly configured, especially the APP_URL
setting, which should match your site’s URL.
Check the Laravel Log:
Check the Laravel log file located in /var/www/stand_blog/storage/logs
for any specific errors that might point to the problem.
Ensure Nginx is Running: After making changes, ensure that Nginx is running without errors:
sudo systemctl restart nginx
sudo systemctl status nginx
If you encounter a timeout error again when trying to restart Nginx, investigate further by checking the Nginx error logs (/var/log/nginx/error.log
) for any indications of what might be wrong.
Let me know how it goes!
Best,
Bobby
The “view not found” error in Laravel usually indicates a problem with Laravel’s views or its cache. As suggested, the following should resolve the issue for you
php artisan cache:clear
php artisan view:clear
php artisan config:clear
php artisan route:clear
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.