在 ubuntu 中以 www-data 用户重启 apache

在 ubuntu 中以 www-data 用户重启 apache

我有一个 SaaS webapp 服务,因此每次在我的注册应用程序中注册新客户端时,它都会创建一个新的子域和一个新的 apache 虚拟主机配置文件,为了启用此配置,我需要重新启动 apache(在端口 8080 上运行),但是如果我尝试在 www-data 下运行/etc/init.d/apache2 restartapache2ctl restart这是运行我的应用程序的用户),我会收到以下错误:

Address already in use: make_sock: could not bind to address 0.0.0.0:8080
no listening sockets available, shutting down
Unable to open logs
Action 'start' failed.
The Apache error log may have more information.

我怎样才能自动重新启动 apache?

操作系统是 Ubuntu Server 10.10

答案1

您可以将其添加到您的 sudoers 文件中,然后只需使用 sudo 即可调用 apache restart 命令。

Cmnd_Alias AP2RESTART=/etc/init.d/apache2
www-data ALL=NOPASSWD: AP2RESTART

相关内容