Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is there a way to start/restart/stop apache server on linux as non-root user? [closed]

Tags:

linux

apache

I'd like to know if it is possible for non-root user on linux (i'm using openSUSE) to run apache without using sudo command. Take into account that the user is in the same group as apache (wwwrun).
Thanks in advance.

like image 776
Adriana Avatar asked Feb 08 '09 13:02

Adriana


People also ask

How do I start Apache without root?

Method 1: Sudo privileges Provide the non-root account sudo privileges to start the service. For example test user wants to start Apache service. Add the following configuration to /etc/sudoers file. In case your user is different, replace the test user with the user account name of your choice.

Does Apache have to run as root?

Although Apache is typically started with root privileges in order to listen on port 80 and 443, it can and should run as another non-root user in order to perform the web services.

How do I force restart httpd?

How do I restart httpd service? You can use the service or systemctl command to restart httpd server. Another option is use /etc/init. d/httpd service script under Linux or Unix-like systems.


1 Answers

You can run Apache as any user. Just make sure that it is set up to only use allowed resources (directories, files and most importantly listening on a non privileged port).

To have it appear on HTTP’s standard port 80 (which is priviledged) you will have to setup, as root a redirection to your real Apache server. The easiest way is probably using iptables. For example if your Apache server is listening on port 8080:

iptables -t nat -A PREROUTING -p tcp --dport 80 --syn -j REDIRECT --to-port 8080

If you can not configure the server like this (or have your sysadmin do that once for all) you will have to use a non privileged port (something like Listen 8080) and access it using an URL that looks like http://www.example.com:8080/

like image 177
kmkaplan Avatar answered Sep 20 '22 15:09

kmkaplan