Professional Documents
Culture Documents
التقرير النهائي
للعام الدراسي 2020-2019الفصل الدراسي (االول)
اعداد الطالب
زينب كامل شيال
ملادة ( ) Introduction to Linuxاملرحلة ( الرابعة ) الدراسة( املسائي )
باشراف االستاذ
جورج عجام أسكندر
Page 1 of 8
Republic of Iraq جمهورية العراق
Ministry of Higher Education وزارة التعليم العالي والبحث
and Scientific Research العلمي
University of Babylon جامع ــةباب ــل
College of Information كلي ـ ــةتكنولوجياالمعلومات
Technology قسم شبكات املعلومات
Department of Information التقرير النهائي
Network
”Installing Apache Web server on Linux” told you where to download Apache
and explained how to install it on your Linux machine. Now I’ll follow up with
the basics of configuring the Apache Web server. I’ll also show you how to
make sure Apache starts automatically at boot time.
First, let’s look at the reasoning behind the three separate configuration files.
This has an almost Holy Trinity-like mystique in the Apache community. They
are basically a legacy of the NCSA 1.3 Web server and can be handled in many
different ways.
Page 2 of 8
Republic of Iraq جمهورية العراق
Ministry of Higher Education وزارة التعليم العالي والبحث
and Scientific Research العلمي
University of Babylon جامع ــةباب ــل
College of Information كلي ـ ــةتكنولوجياالمعلومات
Technology قسم شبكات املعلومات
Department of Information التقرير النهائي
Network
directive that can be placed in either of the other two files. By placing the
options AccessConfig /dev/null and ResourceConfig /dev/null in httpd.conf, you
can tell Apache to look only to it for its configuration.
This does not mean that you must use those particular files every time. The –f
command-line option allows for Apache to load its configuration from a user-
defined file at run time. Also, preconfigured packages from distributions such as
Red Hat and Debian may install to different directories. Under the current
version of Debian, the configuration files can be found in /etc/apache. If you’re
using Red Hat, you may want to check under /etc/httpd/conf.
If you’ve run more than one version of Linux before, you know that the
Page 3 of 8
Republic of Iraq جمهورية العراق
Ministry of Higher Education وزارة التعليم العالي والبحث
and Scientific Research العلمي
University of Babylon جامع ــةباب ــل
College of Information كلي ـ ــةتكنولوجياالمعلومات
Technology قسم شبكات املعلومات
Department of Information التقرير النهائي
Network
directory structure and file locations can vary. When in doubt, running locate
httpd or locate apache with an updated database of files can be helpful in
pinpointing the exact location.
Page 4 of 8
Republic of Iraq جمهورية العراق
Ministry of Higher Education وزارة التعليم العالي والبحث
and Scientific Research العلمي
University of Babylon جامع ــةباب ــل
College of Information كلي ـ ــةتكنولوجياالمعلومات
Technology قسم شبكات املعلومات
Department of Information التقرير النهائي
Network
Notice that these directives have comments located before them that help to
explain the syntax and functionality. Almost every configuration option is
explained to some degree in the files themselves—a nice feature if you’re like
me and tend to read the documentation only when you can’t figure something
out otherwise. An important one to notice is the LoadModule command. Upon
installing programs related to Apache, you may need to edit the configuration
file(s) to load the modules at start-up. If you installed PHP after Apache, you
will need the above command in combination with an AddType directive to
make sure Apache will process PHP files.
The above examples are fairly standard and may not need editing. Some
Page 5 of 8
Republic of Iraq جمهورية العراق
Ministry of Higher Education وزارة التعليم العالي والبحث
and Scientific Research العلمي
University of Babylon جامع ــةباب ــل
College of Information كلي ـ ــةتكنولوجياالمعلومات
Technology قسم شبكات املعلومات
Department of Information التقرير النهائي
Network
directives, however, will change from server to server. Some examples of these
are:
ServerName
ServerAdmin
BindAddress
The ServerName directive sets the host name of the server and is usually a fully
qualified domain name. This saves the server from trying to do a lookup of the
host name by IP address, which may not return the result you want. An example
of how to use this would be:
ServerNamewww.techrepublic.com
Starting Apache
Apache can either be started manually or automatically at boot time. For manual
operation, you use the command apachectl. As mentioned previously, multiple
arguments can be passed to this command. To start Apache, you execute
apachectl start. To restart the server after making changes to the configuration,
you use apachectl restart or apachectl graceful. The graceful switch sends a
Page 6 of 8
Republic of Iraq جمهورية العراق
Ministry of Higher Education وزارة التعليم العالي والبحث
and Scientific Research العلمي
University of Babylon جامع ــةباب ــل
College of Information كلي ـ ــةتكنولوجياالمعلومات
Technology قسم شبكات املعلومات
Department of Information التقرير النهائي
Network
To load the server during boot time, you can either place a script in init.d orrc.N
or place a call to apachectl from rc.local or rc.boot. (These files and locations
will vary depending on your distribution.) For example, here is my script in
/etc/init.d/ on a Debian/GNU system.
#! /bin/bash
#
# apache Start the apache HTTP server.
#
NAME=apache
PATH=/bin:/usr/bin:/sbin:/usr/sbin
DAEMON=/usr/sbin/apache
SUEXEC=/usr/lib/apache/suexec
PIDFILE=/var/run/$NAME.pid
CONF=/etc/apache/httpd.conf
APACHECTL=/usr/sbin/apachectl
trap "" 1
export LANG=C
test -f $DAEMON || exit 0
test -f $APACHECTL || exit 0
if egrep -q -i "^[[:space:]]*ServerType[[:space:]]+inet" $CONF
then
exit 0
fi
Page 7 of 8
Republic of Iraq جمهورية العراق
Ministry of Higher Education وزارة التعليم العالي والبحث
and Scientific Research العلمي
University of Babylon جامع ــةباب ــل
College of Information كلي ـ ــةتكنولوجياالمعلومات
Technology قسم شبكات املعلومات
Department of Information التقرير النهائي
Network
case "$1" in
start)
echo -ne "Starting web server: $NAME.\n"
$APACHECTL start
;;
stop)
echo -ne "Stopping web server: $NAME.\n"
$APACHECTL stop
;;
exit 0
There will be as many ways to load Apache at boot time as there are versions of
Linux. You may need to consult your specific documentation if the above
suggestions do not work on your Linux system.
Conclusion
The Apache Web server, as with any full-featured program, has a variety of
configuration options. Stored in plain text files, the main configuration files are
easily accessible through the text editor of your choice. In addition to the
comments in the config files, Apache provides excellent documentation on
directives and configuration options at http://httpd.apache.org/docs.
Page 8 of 8