【问题标题】:Changing the user that nginx worker processes run under (Ubuntu 12.04)更改运行 nginx 工作进程的用户(Ubuntu 12.04)
【发布时间】:2013-08-01 20:36:02
【问题描述】:

我在 Ubuntu 12.04 上手动安装了 nginx。当我运行./configure 时,我使用了以下选项:

./configure --user=www-data --group=www-data --with-http_ssl_module --with-http_realip_module

现在 nginx 工作进程在 www-data 组中的 www-data 用户下运行。但是,我希望将其更改为其他用户(在我的情况下称为 nginx)。

在运行makemake install 之后可以这样做吗?

任何帮助将不胜感激。

【问题讨论】:

    标签: nginx ubuntu-12.04 usergroups


    【解决方案1】:

    只要您的新用户(在您的情况下为 nginx)拥有适当的权限,一切都应该正常工作。

    您必须在 nginx.conf

    中更改您的 user 设置
    ...
    user nginx;
    ...
    

    并重新启动/重新加载您的服务器。 Link to docs.

    【讨论】:

    • 在 nginx 1.8 及更高版本上,您还必须指定组,例如“user nginx staff;”
    • 请记住,该指令应该在“主”上下文中,即在任何其他指令之外。
    【解决方案2】:

    如果你使用 PHP5-FPM 并在重启 nginx 后得到 502 错误,请查看 /var/run/php5-fpm.sock (Debian):

    root@ns353941:/var/run# chown nginx:www php5-fpm.sock

    就我而言:

    nginx = 新的 nginx 用户

    www = 网络组

    nginx 用户显然属于 www。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2021-01-09
      • 2012-12-12
      • 1970-01-01
      • 2013-12-06
      • 1970-01-01
      相关资源
      最近更新 更多