×
Community Blog Finding Out What User Apache Is Running As

Finding Out What User Apache Is Running As

This article explains how to find out what user Apache is running as.

By Alain Francois

Apache is the most common web server used on Linux systems. It is a free and open-source web server that delivers web content through the Internet. One of the most common web application stacks involves Linux, Apache, MySQL, and PHP. It is called LAMP.

Features of Apache Web Server

Apache functions as a way to communicate over networks from client to server using the TCP/IP protocol. Apache offers features, such as:

  • Handling of Static Files
  • Loadable Dynamic Modules
  • Auto-Indexing
  • .htaccess
  • Supports HTTP/2
  • FTP Connections
  • Gzip Compression and Decompression
  • Bandwidth Throttling
  • Load Balancing
  • URL Rewriting

Check Your Apache Installation on Your ECS Instance

You should log in on your ECS instance first, install Apache if it is not installed yet, and check if the service is running.

  • On a Debian-based ECS instance:
$ sudo apt update && sudo apt install apache2

Make sure the service is running:

$ sudo systemctl start apache2
  • On RedHat-based ECS instance:
$ sudo dnf install httpd

Make sure the service is running:

$ sudo systemctl start httpd

Checking through Configuration Files

Apache, in its working process, defines what user Apache is running as in the configuration files. It means you can check those files to see the user configured.

On Debian-based systems, check the configuration file /etc/apache2/apache2.conf and look for the directive user:

$ cat /etc/apache2/apache2.conf

1

The value can be set as an environment variable, so you need to look: /etc/apache2/envvars:

$ cat /etc/apache2/envvars

2

You can see the user is www-data on the Ubuntu server.

On RedHat-based systems, check the configuration file /etc/httpd/conf/httpd.conf and look for the directive user:

$ cat /etc/httpd/conf/httpd.conf

3

Here, the user is apache on the CentOS server.

This method will show you the configured user to run Apache, but it doesn't show if other users are running Apache.

Linux Process

As Linux systems are multi-session, it means some others can run Apache. It will be interesting to display this sort of result. So, another way is to list all the running processes with the ps command (with the user running them) and filter the result to only catch the Apache process.

On a Debian-based system, as the package is Apache, you should use the command below:

$ sudo ps -aux | grep apache

4

While on RedHat based systems, the package is httpd, so you should use the command below:

$ sudo ps -aux | grep http

5

On each result, you can see the previous default user.

0 0 0
Share on

Alibaba Cloud Community

1,042 posts | 256 followers

You may also like

Comments