Open In App

How to Change User and Group Settings in Apache?

Last Updated : 04 Jul, 2024
Comments
Improve
Suggest changes
Like Article
Like
Report

Apache server is an open source web server that serves resources from specific files or directories which are determined by specific user and group permissions. Apache also allows us to change the user and group settings to meet certain security or operational requirements. In this article, we will learn how to update user and group settings in the Apache web server.

Steps to change user and group settings in Apache

We are going to learn the step that will show how can we change user and group setting in Apache.

Step 1: Identify User and Group directives in the Apache config file

  • In this step, we will find out the user and group under which the Apache web server is running using the below command.
ps aux | grep apache2
or
ps -eo user,group,comm | grep apache2 ( for more precise results)

Step 2: Update the Apache config file with a different user and group

  • First, open the apache config file using the vim text editor with the help of the below command:
sudo vim /etc/apache2/apache2.conf
  • Now, update the config file with the new User and Group directives values.
User newuser
Group newgroup
  • Now, save the file using the below command:
:wq

Step 3: Update directory permissions

  • We will update directory permissions so that the new user and group have the required permissions to run the apache web server.
sudo chown -R newuser:newgroup /var/www/html

Step 4: Restart apache to reflect changes

  • We will restart apache to apply the new settings to the web server
sudo systemctl restart apache2

Step 5: Verify the new user and group directives

  • Run the below command to identify the new user and group directives under which the apache server is running from
ps aux | grep apache2

Next Article
Article Tags :

Similar Reads