linux - 从 bash 启动 apachectl

标签 linux apache bash

我正在写一个 bash 文件。我需要从我的 bash 文件启动 apachectl。所以我写道:

apachectl start

当我用 root 运行它时,发生错误:

apachectl: command not found

我搜索了一下,发现我应该是 super user su - 而不是 su

现在,我想知道:

  • 为什么会出现这个错误?

  • 如何使用 su 运行它?

最佳答案

在 shell 脚本中,你应该使用完整路径来执行命令,除非 $PATH 中已经包含可执行文件的目录。 例如,查找 apachectl 二进制文件所在的位置:

which apachectl

whereis apachectl

你会得到类似的东西:

/usr/local/sbin/apachectl

所以,使用它。

关于linux - 从 bash 启动 apachectl,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9348204/

相关文章:

bash - 如何在期望中转义方括号?

c - 在cygwin 1.7环境下使用GDB如何使gettimeofday函数调用失败?

python - 如何查看安装了哪个版本的nltk、scikit learn?

Django在Apache上使用mod_wsgi-500错误: Authtype not set?

linux - 如何知道要使用什么脚本头以及它为什么重要?

linux - 是否可以检查unix中的下一行是否包含一行,如果是,则删除下一行

asp.net - 尝试运行 ASP.NET 5 Docker 容器时出现异常

linux - Linux 程序员如何在不使用 IDE 的情况下创建 GUI 应用程序?

apache - AWS ALB 重定向到 https

apache - ulimit : error setting limit - Operation not permitted - (using apachectl in container on ECS)