設定httpd自動啟動

來源:互聯網
上載者:User

OS: CentOS

httpd: /opt/httpd

1. Copy script

[root@localhost ~]# cp /opt/httpd/bin/apachectl /etc/rc.d/init.d/httpd
2. Edit script

(1) Change directory

[root@localhost ~]# cd /etc/rc.d/init.d
(2) Edit file
[root@localhost init.d]# vi httpd
The original file(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#ARGV="$@"## |||||||||||||||||||| START CONFIGURATION SECTION  ||||||||||||||||||||# --------------------                              --------------------# # the path to your httpd binary, including options if necessaryHTTPD='/opt/httpd/bin/httpd'## pick up any necessary environment variablesif test -f /opt/httpd/bin/envvars; then  . /opt/httpd/bin/envvarsfi## 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.  LYNX="lynx -dump"## 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_FILESfiERROR=0if [ "x$ARGV" = "x" ] ; then     ARGV="-h"ficase $ARGV instart|stop|restart|graceful|graceful-stop)    $HTTPD -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)    $HTTPD -t    ERROR=$?    ;;status)    $LYNX $STATUSURL | awk ' /process$/ { print; exit } { print } '    ;;fullstatus)    $LYNX $STATUSURL    ;;*)    $HTTPD $ARGV    ERROR=$?esacexit $ERROR
Add the following section to the file:(File header)
#!/bin/sh## Startup script for the Apache Web Server## chkconfig: 345 85 15# description: Apache is a World Wide Web server.  It is used to serve \#              HTML files and CGI.# processname: httpd

Reference:

1. chkconfig

"service httpd does not support chkconfig" solutions

2. apachectl(en)

3. apachectl(zh)

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.