Ubuntu

如何在沒有root權限的ubuntu伺服器中自動啟動網路伺服器?

  • July 22, 2012

如何在沒有 root 權限的情況下(作為另一個使用者)在啟動時執行網路伺服器?我可以在 rc.local 中添加它,但它是在 root 使用者下執行的。

如何在沒有 root 權限的情況下(作為另一個使用者)在啟動時執行網路伺服器?

為什麼?你想達到什麼目的?

Apache 在成為守護程序並在埠上列出之後所做的第一件事就是將 setuid 設置為配置文件中定義的使用者 - 即它不以 root 權限執行。

除非您是 root 使用者,否則不可能在低於 1024 的埠上啟動守護程序偵聽- 但完全可以啟動它來偵聽,例如埠 8000,也很可能設置 iptables 以將埠 80 請求代理到埠 8000 - 但僅限root 程序可以將 setuid 設置為不同的 uid - 因此您需要更改 Apache 配置,以便它不呼叫 setuid,或者僅將 setuid 呼叫為目前 uid。

如果您擔心安全性,那麼在嘗試修復實際上不存在的安全漏洞之前,您應該考慮做很多其他事情。

C。

在 httpd 配置文件中搜尋以下部分:

#
# If you wish httpd to run as a different user or group, you must run
# httpd as root initially and it will switch.  
#
# User/Group: The name (or #number) of the user/group to run httpd as.
# It is usually good practice to create a dedicated user and group for
# running httpd, as with most system services.
#
User daemon
Group daemon

並將“守護程序”使用者和組更改為所需的使用者名。

引用自:https://serverfault.com/questions/158159