Analyze. Act. Achieve.
Kurinchilion KURINCHILION Analyze. Act. Achieve.

Articles

Linux: Securing Apache

Run the below command to check what user and group apache is running as, by typing $ ps auwfx | grep apache2 root 28937 0.0 0.1 3004 756 pts/0 S+ 12:35 0:00 | \_ grep apache2 root 25235 0.0 2.5 37744 12992 ? Ss Mar18 0:06 /usr/sbin/apache2 -k start www-data 27102 0.0 1.3 38252 6972 ? S Mar21 0:00 \_ /usr/sbin/apache2 -k start

If apache is running as root user, We need to change this by creating a group and a user within this group that can run Apache.

$ groupadd www-data $ useradd -g www-data www-data $ vi /etc/apache2/apache2.conf

Search for the below lines in apache2.conf, User root Group root

and change them to

User www-data Group www-data

Tip: Sometimes the user group and name will be added to variables within /etc/apache2/envars and may be referenced in /etc/apache2/apache2.conf

Reload apache configuration file setting changes by typing $ /etc/init.d/apache2 reload