Easy Troubleshooting 500 Internal Server Error Linux [Fix]

I am here again with a new topic and most common error while transferring from one server to another server or after uploading new files. The 500 Internal Server Error Linux is mainly due to conflict of user permissions as well as user ownership. Mostly after moving files from one linux server to another server, first thing which we encounter is internal server error. For new comers, making transfer for the first time, it is like a huge issue and often take hours to take back site live.

In my start of Linux, I moved a server and then browsed internet for hours to find the cause of apache internal server error, after hours of Googling, I finally found a solution and now I want to share this with you. If you have moved to a new server or even if you have just uploaded new files or testing a new project 500 Internal Server Error is nothing more or less than ownership conflict or permissions error.

For most of the projects like wordpress, MyBB or other CMS, required permissions for files are 644 and folder permissions are 755. If you have just moved or want to clear refresh permission messed up, below 2 command will do all your task in just couple of seconds.

  1. 1- Change Directory Permission Recursively

# find \path-to-root-directory\ -type d -exec chmod 755 {} \ ;

This above command will change all directories after that path permissions to 755 which is most required for all sort of CMS unless otherwise specifically stated.

2- Change Files Permission Recursively

# find \path-to-root-directory\ -type f -exec chmod 664 {} \ ;

This command will change all files permission in the root directory and in sub directories to 664 which is required for all projects.

Now you have to check ownership of the files and folders. Normally when we configure server without any control panel, we need to have file ownership of all files and folders required to be served via web server to apache & group apache. Don’t worry about the number of files and folders, I am going to provide you a simple command which will change ownership of all files and folders in just few seconds. You don’t need to run command for ownership change on all files individually.

1- Change of Ownership of Files

# chown -R user:group /foldername

In above code you will replace user with apache and group with apache if you have configured Apache web server. If you are using cPanel or anyother control panel than you have to set your cPanel username as user and group. This command will change all ownership of files and folder including sub folders and files.

Now test your website and it will not be having 500 Internal server error anymore. If you want to verify whether all permissions & ownership of files & folder are changed. Just run the command given below in any folder and it will give you list of all files and in that folder along with their permissions and ownership plus group.

If you are still facing any issue or having problem in executing above commands, use comment section or contact me for further information & help.

Aly Chiman

Aly Chiman is a Blogger & Reporter at AlyChiTech.com which covers a wide variety of topics from local news from digital world fashion and beauty . AlyChiTech covers the top notch content from the around the world covering a wide variety of topics. Aly is currently studying BS Mass Communication at University.