rhl6u084

Lemur zaprasza

Red Hat® Linux 6 Unleashed










Chapter 9: Apache Server





Previous
ChapterNext
Chapter










Sections in this Chapter:








Server
Installation





CGI and
SSI






Runtime
Server Configuration Settings





Starting and Stopping the Server






Virtual
Hosting





Configuration
File Listings

















 

Previous
SectionNext
Section






Starting and Stopping the Server



Starting the
Server Manually






The /etc/rc.d
httpd Scripts







At this point, you have your Apache server installed and
configured the way you want it. It's time to start it up for the first
time.



Starting the Server Manually
The
Apache
server, httpd, has a few command-line options you
can use to set some defaults specifying where httpd
will read its configuration directives. The Apache
httpd executable understands the following
options:



httpd [-d directory] [-f file]
[-C "directive"] [-c "directive"]
[-v] [-V] [-h] [-l] [-L] [-S] [-t]

The -d
option overrides the location of the ServerRoot
directory. It sets the initial value of the
ServerRoot variable (the directory where the
Apache server is installed) to whichever path you specify. This default is
usually read from the ServerRoot directive in
httpd.conf.The
-f flag specifies the
location of the main configuration file,
conf/httpd.conf. It reads and executes the
configuration commands found in
ConfigurationFile on startup. If the
ConfigurationFile is not an absolute path (it
doesn't begin with a /), its location is
assumed to be relative to the path specified in the
ServerRoot directive in
httpd.conf. By default, this value is set to
ServerRoot/conf/httpd.conf.The
-v option prints the
development version of the Apache server and terminates the
process.The -V
option shows all of the settings that were in effect
when the server was compiled.The
-h option prints the
following usage information for the
server:



Usage: httpd [-d directory] [-f file]
[-C "directive"] [-c "directive"]
[-v] [-V] [-h] [-l] [-L] [-S] [-t]
Options:
-D name : define a name for use in <IfDefine name> directives
-d directory : specify an alternate initial ServerRoot
-f file : specify an alternate ServerConfigFile
-C "directive" : process directive before reading config files
-c "directive" : process directive after reading config files
-v : show version number
-V : show compile settings
-h : list available command line options (this page)
-l : list compiled-in modules
-L : list available configuration directives
-S : show parsed settings (currently only vhost settings)
-t : run syntax test for configuration files only

The -l
option lists those modules that are compiled into your
Apache serverThe -L
option lists all of the configuration directives
that are available with the modules that are available to
you.The -S
option lists the virtual host settings for the
server.The -t
option is extremely useful. It runs a syntax check on
your configuration files. It's a good idea to run this check before
restarting your server, once you have made changes to your configuration
files.




Note - When you start the server
manually from the command line, you need to do so as root. There are two
main reasons for this:



    l

    If your standalone server uses the default HTTP port
    (port 80), only the superuser can bind to Internet ports that are
    lower than 1025.


    l

    l

    Only processes owned by root can change their UID and
    GID as specified by the User and Group
    directives. If you start the server under another UID, it will run
    with the permissions of the user starting the process.


    l






The /etc/rc.d httpd
Scripts
Red Hat Linux uses
scripts
in the /etc/rc.d directory to control the startup and shutdown of various
services, including the Apache Web server. The main script installed for the
Apache Web server is /etc/rc.d/init.d/httpd and is
shown in Listing 9.1.



Note - /etc/rc.d/init.d/httpd
is a shell script and is not the same as the Apache server located in
/usr/sbin. That is, /usr/sbin/httpd
is the program executable file, and /etc/rc.d/init.d/httpd
is a shell script that helps control that program. See Chapter
6 for more information.


You can use the following options to control the Web
server:






start



 

The system uses this option to start the Web server during
bootup. You, as root, can also use this script to start the server.






stop



 

The system uses this option to stop the server gracefully.
You should use this script, rather than the kill
command, to stop the server.






reload



 

You can use this option to send the HUP
signal to the httpd server to have it reread
the configuration files after modification.






restart



 

This option is a convenient way to stop and then immediately
start the Web server.






status



 

This option indicates whether the server is running, and
if it is, it provides the various PIDs for each instance of the server.







For example, to check on the current status, use the following
command:



/etc/rc.d/init.d/httpd status

which prints



httpd (pid 8643 8642 6510 6102 6101 6100 6099 6323 6322 6098 6097 6096 6095 362 6094 6093) is running...

This indicates that the Web server is running; in fact, there
are 16 servers currently running.


Tip -
Use the reload option if you are making many changes
to the various server configuration files. This saves time when you're
stopping and starting the server by having the system simply reread the
configuration files--without requiring you to remember the PID for the Web
server. If you do need to know the PID, the status
command can provide that information. Also, the system keeps the PID (and many
other PIDs) in a file located in
/var/run.

LISTING
9.1  /etc/rc.d/init.d/http

#!/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
# pidfile: /var/run/httpd.pid
# config: /etc/httpd/conf/access.conf
# config: /etc/httpd/conf/httpd.conf
# config: /etc/httpd/conf/srm.conf

# Source function library.
. /etc/rc.d/init.d/functions

# See how we were called.
case "$1" in
start)
echo -n "Starting httpd: "
daemon httpd
echo
touch /var/lock/subsys/httpd
;;
stop)
echo -n "Shutting down http: "
[ -f /var/run/httpd.pid ] && {
kill ´cat /var/run/httpd.pid´
echo -n httpd
}
echo
rm -f /var/lock/subsys/httpd
rm -f /var/run/httpd.pid
;;
status)
status httpd
;;
restart)
$0 stop
$0 start
;;
reload)
echo -n "Reloading httpd: "
[ -f /var/run/httpd.pid ] && {
kill -HUP ´cat /var/run/httpd.pid´
echo -n httpd
}
echo
;;
*)
echo "Usage: $0 {start|stop|restart|reload|status}"
exit 1
esac

exit 0




Red Hat® Linux 6 Unleashed










Chapter 9: Apache Server





Previous
ChapterNext
Chapter










Sections in this Chapter:








Server
Installation





CGI and
SSI






Runtime
Server Configuration Settings





Starting and Stopping the Server






Virtual
Hosting





Configuration
File Listings

















 

Previous
SectionNext
Section





© Copyright Macmillan USA. All rights reserved.

  • zanotowane.pl
  • doc.pisz.pl
  • pdf.pisz.pl
  • teen-mushing.xlx.pl
  • Wątki
    Powered by wordpress | Theme: simpletex | © Lemur zaprasza