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.
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.
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 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.
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/
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With