Question

After deployment, I changed my project folder name from /var/www/html to /var/www/stand_blog and now I have View Not Found error in browser

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.


Submit an answer


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!

Sign In or Sign Up to Answer

These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.

Bobby Iliev
Site Moderator
Site Moderator badge
February 19, 2024
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:

  1. 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.

  2. 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
    
  3. 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.

  4. 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.

  5. 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.

  6. 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

KFSys
Site Moderator
Site Moderator badge
February 20, 2024

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

Try DigitalOcean for free

Click below to sign up and get $200 of credit to try our products over 60 days!

Sign up

Get our biweekly newsletter

Sign up for Infrastructure as a Newsletter.

Hollie's Hub for Good

Working on improving health and education, reducing inequality, and spurring economic growth? We'd like to help.

Become a contributor

Get paid to write technical tutorials and select a tech-focused charity to receive a matching donation.

Welcome to the developer cloud

DigitalOcean makes it simple to launch in the cloud and scale up as you grow — whether you're running one virtual machine or ten thousand.

Learn more
DigitalOcean Cloud Control Panel