For example, if you are logged in as root and want to switch to user sshah with all of his login and shell configurations, type the following: [root@ford /root]# su - sshah Chapter Summa
Trang 1357 Chapter 21: Introduction to Linux Systems Administration
You can use the dash (-) as an optional parameter This character tells su not only to
switch identities, but to run the login scripts for that user as well For example, if you
are logged in as root and want to switch to user sshah with all of his login and shell
configurations, type the following:
[root@ford /root]# su - sshah
Chapter Summary
In this chapter, you first learned about setting some of the key server settings using the
built-in graphical tools in Fedora Linux Then you learned about the Linux command
line and how to control the system using it
Of course, this chapter didn’t cover everything you need to know about Linux
system administration But given what you learned here, you should be able to perform
basic administrative duties and find your way through the operating system
The easiest way to gain more information is to spend time playing with both the
command-line tools and the various System Tools programs The graphical tools are
capable of so much more than was shown here In fact, for simple servers it is possible
to perform system maintenance using the graphical tools alone! The command line, on
the other hand, is the core of Linux’s flexibility
If you want to learn more about systems administration for Linux, be sure to
check out Linux Administration: A Beginner’s Guide, Third Edition, by Steven Graham
(McGraw-Hill/Professional, 2002)
Now that you’ve learned about installing Linux and about administering a Linux
system, in the next chapter you learn about installing one of the most common network
services that are run under Linux; an Apache web server
Trang 2This page intentionally left blank
Trang 3Chapter 22
Setting Up a Linux Web Server with Apache
Trang 4360 Networking: A Beginner’s Guide
One of the most popular web server applications is the Apache web server,
a free program that runs under a variety of operating systems, including Linux, Windows, Mac OS X, Solaris, and NetWare The Apache web server is
a robust, proven platform on which to host a web site The fact that it is open source and available for free, running on the UNIX-like operating system Linux, which is also often available for free, is a huge plus, and no doubt helps drive its continuing popularity
This chapter introduces the Apache web server You learn the basics that you need
to install it, find web-based resources to support it, and set up a basic web site on a Fedora Linux system
Overview of Apache Web Server
The Apache web server started out as a small development at the National Center for Supercomputing Applications (NCSA) in the early 1990s Beginning as a very simple
UNIX daemon (pronounced the same as “demon”), it was initially programmed by
Rob McCool McCool left NCSA in 1994, and the project began to be extended by a number of different programmers, some of whom added packages (modules) to the core program to enable it to support new web technologies In those days, the web server was referred to as “patchy,” because it kept getting new patches to correct problems or extend functionality Eventually, it came to be called the Apache web server
Version 1.0 of the Apache web server was released to the public at the end of 1995, and by 1996 was the most popular web server on the Internet The latest statistics at the time this chapter was written (available from http://news.netcraft.com/archives/web_ server_survey.html) reveal that Apache is being used to host approximately 50 percent (more than 113 million web sites) of the active web sites on the Internet Microsoft’s IIS
is in second place, with around 25 percent (about 56 million web sites)
The Apache HTTP Server project is presently coordinated through the Apache Software Foundation (http://www.apache.org), a nonprofit corporation formed in 1999 Apache is unlike most other server applications in that it is not a graphical program (despite the fact that its main purpose is to serve up graphical web pages) and has
no graphical installation routine Instead, Apache runs as a background process, or daemon, on the operating system, which is typically called httpd (Hypertext Transfer Protocol daemon) The management of an Apache web server is handled by editing its text-based configuration files, and by stopping and starting the daemon to cause any changes to those configuration files to take effect
The fact that Apache is text-based and is administered through a command-line interface should not daunt you It is straightforward to install and administer an Apache web server, and you should have no trouble doing so In fact, if you followed the Fedora Linux installation instructions in Chapter 20, you already have Apache installed on that computer, and you just need to activate it (it is not turned on by default in a Fedora installation), as described in the next section
Trang 5361 Chapter 22: Setting Up a Linux Web Server with Apache
Activating Apache Web Server Under Fedora
The simplest way to install Apache web server under Fedora Linux is to perform a default
installation using the Fedora Linux installation routine, as described in Chapter 20 After
Fedora is installed, you can start and test Apache with the following steps:
1 Open a terminal emulation window
2 Change to the superuser (root):
su
3 Provide the root password when prompted
4 Type the following command to start Apache:
apachectl start
5 Create a simple HTML file in the location /var/www/html/ and save the file
as index.html (Note that, by default, you must be the root user to create or
modify files in /var/www/html.)
6 Open a web browser and navigate to the address http://localhost/ The file
you saved as index.html should appear in the web browser, showing that
Apache is up and running
Downloading and Installing Apache Web Server
If you did not install Apache under Linux (for example, if you are using a distribution
of Linux that does not come with Apache), you can download the latest version and
install it manually
To download the latest version of Apache, use a web browser to go to http://
www.apache.org/dist/httpd/ Open the Binaries folder, open the folder representing
the operating system you are using (Linux or RPM, for Red Hat Package Manager),
and then choose the appropriate package from the list that appears The packages are
organized by the Apache version (which is also shown as part of the filenames), the
processor, and the operating system For example, you might download a file called
httpd-2.2.3-i386.rpm (representing version 2.2.3 of Apache for 32-bit Intel-based systems
running Linux and that use the RPM installation format) into a temporary directory on
your Linux system
After you’ve downloaded the package, you can install the Apache web server and
start it, as follows:
1 Open a terminal emulation window
2 Type the following to change to the directory that contains the downloaded
Apache binary file:
cd / directory