2015/04/09

How to change Apache user and group


Apache web server normally runs as the user nobody, www-data or apache. These users usually has limited permission on the system, and doesn't normally has shell login. This is good for security reason, but if for whatever reason you are required to run Apache as different user and group, you have the option to do that.


What you'll need to do is to change the User and Group directive in Apache configuration file. In Ubuntu the main configuration file is /etc/apache2/httpd.conf.


The following configuration will run Apache as the user nobody, and group nobody.



User nobody
Group nobody

You can change that to other user and group available in the system.



This could be a big security risk, especially to those changing the user to root

You will need to restart Apache first for the changes to take effect.



sudo /etc/init.d/apache2 restart

The check if the your changes work, run ps as the following;



ps aux | grep apache

Which should give you output imilar to the following;



root      1188  0.0  0.1 162184  6664 ?        Ss   Mar29   0:02 /usr/sbin/apache2 -k start
nobody 1197 0.0 0.1 162184 5668 ? S Mar29 0:00 /usr/sbin/apache2 -k start
nobody 1198 0.0 0.1 162184 5916 ? S Mar29 0:00 /usr/sbin/apache2 -k start
nobody 1200 0.0 0.1 162184 5684 ? S Mar29 0:00 /usr/sbin/apache2 -k start
nobody 1201 0.0 0.1 162184 5684 ? S Mar29 0:00 /usr/sbin/apache2 -k start
nobody 1202 0.0 0.1 162184 5684 ? S Mar29 0:00 /usr/sbin/apache2 -k start

Notice that Apache runs as the user nobody.



ليست هناك تعليقات:

إرسال تعليق