Why do we use root as user for apache2?

Posted April 12, 2020 1.8k views

Hi there,
I have a question, If we follow the instructions to implement a web server with apache on Ubuntu 18.04, why do we use the root user (or sudo user granted privileges) in the installation process? From what I’ve seen they use www-data user, because of security. Is that OK?

These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.

Submit an Answer
1 answer

Hello, @ericferrando92

Could you please let me know if you refer to to this article:

As the article says “In order to complete this tutorial, you will need to have an Ubuntu 18.04 server with a non-root sudo-enabled user account”

As for the user with which Apache (and the individual sites) run on the server this can be modified.

If you’re just running apache, serving static files and things, www-data is enough.

If you have a whole bundle of applications also running in apache (in modphp, modperl etc) you end up with lots of your own, custom, internet-facing code running as www-data, which gives the bad guys more of a chances to gain access to that user, and puts them in control of more stuff if they do.

Hope this helps!


by Mark Drake
by Erika Heidi
A "LAMP" stack is a group of open source software that is typically installed together to enable a server to host dynamic websites and web apps. This stack typically consists of the Linux operating system, the Apache web server, a MySQL database, and PHP, a dynamic content processor. This tutorial serves as a guide for installing these components on an Ubuntu 18.04 server.