How to make your Linux Apache run under a particular user

It is common to see errors like: “permission denied”, that you can see in your applications after uploading the code to your Linux server. You can simply change many of these errors by providing the proper permissions to apache running on your server.

To change the apache running user, execute the below command and open the file with vim:

Look through the file contents and modify the lines which resembles like:

Replace the “www-data” in the first line to your username and for second line, replace with your user’s group name.

Save the file with VIM commands. For more details about VIM commands, please click here.

Restart the server by executing the following command:

Now, you can see that your application will run without permission errors.

Note: The whole article is written by assuming that you uploaded all your files to a user owned folder.