Linux源代码编译安装详解(3)

这两个脚本是从其他机器上复制的,然后改了一下文件与目录的路径

[root@GNOME-C7 ~]# cat /etc/sysconfig/httpd # Configuration file for the httpd service. # # The default processing model (MPM) is the process-based # 'prefork' model. A thread-based model, 'worker', is also # available, but does not work with some modules (such as PHP). # The service must be stopped before changing this variable. # HTTPD=/usr/local/apache2/bin/httpd.worker ##表示启动的httpd服务mpm为worker # # To pass additional options (for instance, -D definitions) to the # httpd binary at startup, set OPTIONS here. # #OPTIONS= # # By default, the httpd process is started in the C locale; to # change the locale in which the server runs, the HTTPD_LANG # variable can be set. # #HTTPD_LANG=C # # By default, the httpd process will create the file # /var/run/httpd/httpd.pid in which it records its process # identification number when it starts. If an alternate location is # specified in httpd.conf (via the PidFile directive), the new # location needs to be reported in the PIDFILE. # #PIDFILE=/var/run/httpd/httpd.pid [root@GNOME-C7 ~]# cat /etc/rc.d/init.d/httpd #!/bin/bash # # httpd Startup script for the Apache HTTP Server # # chkconfig: - 85 15 # description: The Apache HTTP Server is an efficient and extensible \ # server implementing the current HTTP standards. # processname: httpd # config: /etc/httpd/httpd.conf # config: /etc/sysconfig/httpd # pidfile: /usr/local/apache2/logs/httpd.pid # ### BEGIN INIT INFO # Provides: httpd # Required-Start: $local_fs $remote_fs $network $named # Required-Stop: $local_fs $remote_fs $network # Should-Start: distcache # Short-Description: start and stop Apache HTTP Server # Description: The Apache HTTP Server is an extensible server # implementing the current HTTP standards. ### END INIT INFO # Source function library. . /etc/rc.d/init.d/functions if [ -f /etc/sysconfig/httpd ]; then . /etc/sysconfig/httpd fi # Start httpd in the C locale by default. HTTPD_LANG=${HTTPD_LANG-"C"} # This will prevent initlog from swallowing up a pass-phrase prompt if # mod_ssl needs a pass-phrase from the user. INITLOG_ARGS="" # Set HTTPD=/usr/sbin/httpd.worker in /etc/sysconfig/httpd to use a server # with the thread-based "worker" MPM; BE WARNED that some modules may not # work correctly with a thread-based MPM; notably PHP will refuse to start. # Path to the apachectl script, server binary, and short-form for messages. apachectl=/usr/local/apache2/bin/apachectl httpd=${HTTPD-/usr/local/apache2/bin/httpd} prog=httpd pidfile=${PIDFILE-/usr/local/apache2/logs/httpd.pid} lockfile=${LOCKFILE-/var/lock/subsys/httpd} RETVAL=0 STOP_TIMEOUT=${STOP_TIMEOUT-10} # The semantics of these two functions differ from the way apachectl does # things -- attempting to start while running is a failure, and shutdown # when not running is also a failure. So we just do it the way init scripts # are expected to behave here. start() { echo -n $"Starting $prog: " LANG=$HTTPD_LANG daemon --pidfile=${pidfile} $httpd $OPTIONS RETVAL=$? echo [ $RETVAL = 0 ] && touch ${lockfile} return $RETVAL } # When stopping httpd, a delay (of default 10 second) is required # before SIGKILLing the httpd parent; this gives enough time for the # httpd parent to SIGKILL any errant children. stop() { status -p ${pidfile} $httpd > /dev/null if [[ $? = 0 ]]; then echo -n $"Stopping $prog: " killproc -p ${pidfile} -d ${STOP_TIMEOUT} $httpd else echo -n $"Stopping $prog: " success fi RETVAL=$? echo [ $RETVAL = 0 ] && rm -f ${lockfile} ${pidfile} } reload() { echo -n $"Reloading $prog: " if ! LANG=$HTTPD_LANG $httpd $OPTIONS -t >&/dev/null; then RETVAL=6 echo $"not reloading due to configuration syntax error" failure $"not reloading $httpd due to configuration syntax error" else # Force LSB behaviour from killproc LSB=1 killproc -p ${pidfile} $httpd -HUP RETVAL=$? if [ $RETVAL -eq 7 ]; then failure $"httpd shutdown" fi fi echo } # See how we were called. case "$1" in start) start ;; stop) stop ;; status) status -p ${pidfile} $httpd RETVAL=$? ;; restart) stop start ;; condrestart|try-restart) if status -p ${pidfile} $httpd >&/dev/null; then stop start fi ;; force-reload|reload) reload ;; graceful|help|configtest|fullstatus) $apachectl $@ RETVAL=$? ;; *) echo $"Usage: $prog {start|stop|restart|condrestart|try-restart|force-reload|reload|status|fullstatus|graceful|help|configtest}" RETVAL=2 esac exit $RETVAL 3.1.9. 使用chkconfig管理 [root@GNOME-C7 ~]# chmod 755 /etc/init.d/httpd [root@GNOME-C7 ~]# chkconfig --add httpd [root@GNOME-C7 ~]# chkconfig --level 3 httpd on [root@GNOME-C7 ~]# chkconfig --list | grep httpd httpd 0:off 1:off 2:off 3:on 4:off 5:off 6:off 3.1.10. 启动服务 [root@GNOME-C7 ~]# service httpd start Starting httpd (via systemctl): [ OK ] [root@GNOME-C7 ~]# ss -ant | grep 80 LISTEN 0 128 *:80 *:* [root@GNOME-C7 ~]# ps aux | grep http[d] ##现在运行httpd的用户是daemon,可以在配置文件中更改 root 114229 0.0 0.0 97508 2536 ? Ss 18:34 0:00 /usr/local/apache2/bin/httpd daemon 114231 0.0 0.0 386420 4416 ? Sl 18:34 0:00 /usr/local/apache2/bin/httpd daemon 114232 0.0 0.0 386420 4416 ? Sl 18:34 0:00 /usr/local/apache2/bin/httpd daemon 114233 0.0 0.0 386420 4420 ? Sl 18:34 0:00 /usr/local/apache2/bin/httpd daemon 114234 0.0 0.0 386420 4420 ? Sl 18:34 0:00 /usr/local/apache2/bin/httpd 3.1.11. 访问测试

Linux源代码编译安装详解

3.2. Centos7编译安装apache 2.4.6

内容版权声明:除非注明,否则皆为本站原创文章。

转载注明出处:https://www.heiqu.com/44123ec20e806eb679beb0fe9a90c162.html