微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

在开始使用apachectl面对apache

如何解决在开始使用apachectl面对apache

当我尝试使用命令启动或停止apache

/ebiz/apache/httpd/sbin/apachectl -k stop -f /ebiz/apache/httpd/conf/httpd.conf

出现此错误:-

/ebiz/apache/httpd/sbin/apachectl: line 122: ./httpd: No such file or directory

但是当我尝试从sbin位置执行相同的命令时,它工作正常。我将apache放置在自定义位置,而apachectl放置在“ / ebiz / apache / httpd / sbin”位置,而httpd.conf放置在“ / ebiz / apache / httpd / conf /”位置

如果我查看我的apachectl文件

#!/bin/sh
#
# Licensed to the Apache Software Foundation (ASF) under one or more
# contributor license agreements.  See the NOTICE file distributed with
# this work for additional information regarding copyright ownership.
# The ASF licenses this file to You under the Apache License,Version 2.0
# (the "License"); you may not use this file except in compliance with
# the License.  You may obtain a copy of the License at
#
#     http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing,software
# distributed under the License is distributed on an "AS IS" BASIS,# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND,either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
#
# Apache control script designed to allow an easy command line interface
# to controlling Apache.  Written by marc Slemko,1997/08/23
# 
# The exit codes returned are:
#   XXX this doc is no longer correct Now that the interesting
#   XXX functions are handled by httpd
#   0 - operation completed successfully
#   1 - 
#   2 - usage error
#   3 - httpd Could not be started
#   4 - httpd Could not be stopped
#   5 - httpd Could not be started during a restart
#   6 - httpd Could not be restarted during a restart
#   7 - httpd Could not be restarted during a graceful restart
#   8 - configuration Syntax error
#
# When multiple arguments are given,only the error from the _last_
# one is reported.  Run "apachectl help" for usage info
#
ACMD="$1"
ARGV="$@"
#
# |||||||||||||||||||| START CONfigURATION SECTION  ||||||||||||||||||||
# --------------------                              --------------------
# 
# the path to your httpd binary,including options if necessary
HTTPD='./httpd'
#
#
# a command that outputs a formatted text version of the HTML at the
# url given on the command line.  Designed for lynx,however other
# programs may work.  
if [ -x "/usr/bin/links" ]; then
  LYNX="/usr/bin/links -dump"
else
  LYNX=none
fi
#
# the URL to your server's mod_status status page.  If you do not
# have one,then status and fullstatus will not work.
STATUSURL="http://localhost:80/server-status"


#
# Set this variable to a command that increases the maximum
# number of file descriptors allowed per child process. This is
# critical for configurations that use many file descriptors,# such as mass vhosting,or a multithreaded server.
ULIMIT_MAX_FILES="ulimit -S -n `ulimit -H -n`"
# --------------------                              --------------------
# ||||||||||||||||||||   END CONfigURATION SECTION  ||||||||||||||||||||

# Set the maximum number of file descriptors allowed per child process.
if [ "x$ULIMIT_MAX_FILES" != "x" ] ; then
    $ULIMIT_MAX_FILES
fi

ERROR=0
if [ "x$ARGV" = "x" ] ; then 
    ARGV="-h"
fi

function checklynx() {
if [ "$LYNX" = "none" ]; then
   echo "The 'links' package is required for this functionality."
   exit 8
fi
}

function testconfig() {
# httpd is denied terminal access in SELinux,so run in the
# current context to get stdout from $HTTPD -t.
if test -x /usr/sbin/selinuxenabled && /usr/sbin/selinuxenabled; then
  runcon -- `id -Z` $HTTPD $OPTIONS -t
else
  $HTTPD $OPTIONS -t
fi
ERROR=$?
}

case $ACMD in
start|stop|restart|graceful|graceful-stop)
    $HTTPD $OPTIONS -k $ARGV
    ERROR=$?
    ;;
startssl|sslstart|start-SSL)
    echo The startssl option is no longer supported.
    echo Please edit httpd.conf to include the SSL configuration settings
    echo and then use "apachectl start".
    ERROR=2
    ;;
configtest)
    testconfig
    ;;
status)
    checklynx
    $LYNX $STATUSURL | awk ' /process$/ { print; exit } { print } '
    ;;
fullstatus)
    checklynx
    $LYNX $STATUSURL
    ;;
*)
    $HTTPD $OPTIONS "$@"
    ERROR=$?
esac

exit $ERROR

在第122行上,它正在寻找“ $ HTTPD $ OPTIONS” $ @””。我如何在任何地方执行apache

解决方法

您会看到httpd的路径被硬编码为./httpd中的相对路径apachectl

# the path to your httpd binary,including options if necessary
HTTPD='./httpd'

如果您不在正确的工作目录中,则指向错误的位置。

将路径更改为二进制文件的绝对路径即已足够

# the path to your httpd binary,including options if necessary
HTTPD=/ebiz/apache/httpd/sbin/httpd

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。

相关推荐


Selenium Web驱动程序和Java。元素在(x,y)点处不可单击。其他元素将获得点击?
Python-如何使用点“。” 访问字典成员?
Java 字符串是不可变的。到底是什么意思?
Java中的“ final”关键字如何工作?(我仍然可以修改对象。)
“loop:”在Java代码中。这是什么,为什么要编译?
java.lang.ClassNotFoundException:sun.jdbc.odbc.JdbcOdbcDriver发生异常。为什么?
这是用Java进行XML解析的最佳库。
Java的PriorityQueue的内置迭代器不会以任何特定顺序遍历数据结构。为什么?
如何在Java中聆听按键时移动图像。
Java“Program to an interface”。这是什么意思?