I ran chown -R www-data:www-data /var/www and got 500 Internal Server Error

I ran chown -R www-data:www-data /var/www and got 500 Internal Server Error, get a file not found error on all of my domains and can’t seem to fix it.

I feel like it used the wrong path since everything is there but I’m not positive.


Submit an answer
You can type!ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!

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.

Accepted Answer

Got it! It had changed the permission of the folder /var/www and the ownership of vhost files and folders also. Thanks folks!

I know you’ve got plesk, can you restart it or Restart nginx. Every time i’ve had this happen it’s due to a change i’ve made in the /etc/nginx/nginx.conf or any .conf in /etc/nginx or even other changes. When battling 500’s likely due to server nginx always Restart nginx after each change, if possible which with D.O. certainly should be.

I think it’s systemctl service stop nginx depending on the distro and version. and then systemctl service start nginx (maybe even restart in some instances, and other instances it’s like a “?” service.nginx restart command. You’ll have to browse the googles for them, there’s a few. Or if you used homebrew for linux or are locally on mac it would be something like brew service nginx restart

NOTE: I could have butchered these commands i’m writing mobile off the top My apologies to others, you perfect code monks and Heads of the Board of Forum Board Educators, Etiquette, and Format :)

The other matter I’ve found myself failing at often was php-fpm in my nginx configuration. I had a local version running php7.2-fpm on a @php7.4fpm version. Make sure your path mentioned in your sites-available match up. Thirdly, create a new folder as user sudo mkdir in sites-enabled and this actually helped in one case where I opted not to use the default that was set up and just matched all files up correctly. In my case it was laravel on Ubuntu. Today, it still is so if you chaps have any input on my soon to be thread i’d appreciate any input.

Also if you use git at all you may be using root on a VPS any change you make might undo your work by changing user/group perms back to root.

My one, two, or maybe 3 cents more than anyone wanted on this matter but maybe will keep the next “me” who’s browsing similar topics to see this and say hey I know that, and “no, I dont need to restart nginx, it’s fine.” then suddenly they see this where I had previously thought that exact thing, Boom resolution along with the items listed above.

@andrewobenreder @hansen

Starting a new reply as the other was maxed out.

Now that I can see the “File Not Found” using the IP address, that’s most likely an issue with NGINX, not Apache and also an issue with permissions. I’ve seen the same error on proxy setups with NGINX before and it falls back on PHP-FPM in most cases.

So if you have NGINX in front of Apache and setup as a proxy (NGINX on Port 80/443, Apache on Port 7080, etc), then I’d take a look at your PHP-FPM configuration and if possible, post that as well.

Specifically, we’d need to look at the location block that handles PHP connections for NGINX.

I didn’t specify any user or other attributes but the error appeared directly after utilizing the base code.

It also affected the sites different: gives and internal server error and says file not found.


The only issue I can see from the logs appears to be from the warning being generated.

server certificate does NOT include an ID which matches the server

The above seems to persist across all domains which would indicate that there’s something wrong with the SSL Certificates being used.

That being said, can you also post your site-specific configuration (i.e. VirtualHost blocks) for the site or sites affected? Normally running chown won’t cause file not found issues, unless the user that you’re changing ownership to doesn’t have permission to read/write on those specific files.

This comment has been deleted


What web server are you using, Apache or NGINX?

If apache, please run:

tail -50 /var/log/apache2/error.log

If NGINX, please run:

tail -50 /var/log/nginx/error.log

If your log files are in a different directory, please replace accordingly and post the output in a code block – we can take a closer look at the error logs to see what’s going on.