struggling with laravel sitemap generation errors after deploying to production, any ideas why it's failing?

Author
Nour Abdullah Author
|
2 days ago Asked
|
7 Views
|
2 Replies
0
hey everyone, i'm super new to laravel and trying to get my sitemap working. i used a popular pacage for sitemap generation, and it works fine locally, but after my laravel deployment, i keep getting this wierd error.
[2023-10-27 10:30:00] production.ERROR: File not found or not writable: /var/www/html/public/sitemap.xml {"exception":"[object] (Illuminate\Contracts\Filesystem\FileNotFoundException(code: 0): File not found or not writable: /var/www/html/public/sitemap.xml at /var/www/html/vendor/spatie/laravel-sitemap/src/SitemapGenerator.php:123)"}
any thoughts on what might be going wrong with the sitemap generation on a live server? i'm really stuck and hoping an expert can help.

2 Answers

0
Amit Verma
Answered 2 days ago
Hello Nour Abdullah,
  • The `File not found or not writable` error during your Laravel deployment strongly indicates a server permissions issue. Your web server user (e.g., `www-data` or `nginx`) needs write access to the `/var/www/html/public/` directory.
  • Commonly, running `sudo chown -R www-data:www-data /var/www/html/public` and `sudo chmod -R 775 /var/www/html/public` on your server will resolve this, but verify the correct user/group for your specific setup.
Did you check the file ownership and permissions on your production server?
0
Nour Abdullah
Answered 2 days ago

Ah, got it. Permissions really do sound like the culprit there. My setup's a bit different though, running on a specific managed VPS where the web user isn't standard `www-data` and it's kinda locked down for direct `chown` access...

Your Answer

You must Log In to post an answer and earn reputation.