Starting Stopping and Testing the Apache Web Server

The core of the Apache web server is the httpd process. This process is started from the script /etc/init.d/apache2; the easiest way to activate Apache using this script from the command line is to use the rcapache2 start command. When this command finishes without errors, your web server is up and running. You can check to see whether it's running with the ps aux | grep http command; as you can see in Listing 22-1, this command shows that different instances of the Apache web server are ready and waiting for the incoming connections.

Listing 22-1. Several Instances of the httpd Process Start Automatically ATL:~# ps aux | grep http

root 7371 1.3

1.1 45408 5852 ?

Ss

15

51

0:

00

/usr/

sbin/httpd2-prefork -

f

/etc/apache2/httpd.conf

wwwrun 7372 0.0

0.9 45408 4800 ?

S

15

51

0:

00

/usr/

sbin/httpd2-prefork

f

/etc/apache2/httpd.conf

wwwrun 7373 0.0

0.9 45408 4788 ?

S

15

51

0:

00

/usr/

sbin/httpd2-prefork

f

/etc/apache2/httpd.conf

wwwrun 7374 0.0

0.9 45408 4788 ?

S

15

51

0:

00

/usr/

sbin/httpd2-prefork

f

/etc/apache2/httpd.conf

wwwrun 7371 0.0

0.9 45408 4788 ?

S

15

51

0:

00

/usr/

sbin/httpd2-prefork

f

/etc/apache2/httpd.conf

wwwrun 7371 0.0

0.9 45408 4788 ?

S

15

51

0:

00

/usr/

sbin/httpd2-prefork

f

/etc/apache2/httpd.conf

As you can see from the output of ps aux, the first Apache process that is started has root as its owner. This process immediately forks five processes that listen to incoming connections. This behavior comes from the mod_prefork module that is used by Apache. This module makes sure several individual processes to which users can connect are started. The Apache parent process automatically, as needed, launches these child processes. This way, in all situations, the right number of processes are available for incoming connections. In the "Performance Tuning the Web Server" section, you will learn how to manage the minimum amount of child processes that are always ready and waiting for new connections, as well as the maximum amount of processes that can be started.

After starting the Apache web server, you have several ways to test its availability. The best way to do it is to just try to connect; after installation, a default web server is listening for incoming requests. So, wait no longer—launch a browser, and connect to HTTP port 80 on your local host. It should show you the Apache welcome page shown in Figure 22-2. It is important to try it from the server itself, the local host, because the firewall may be preventing access from other systems.

Fi I

File Edit View Go Bookmarks Tools Help a

SU5E Linux - Entertainment" News - Internet Search

Reference â–¼ Maps and Directions r Shopping- People and Com par

It works!

Figure 22-2. To verify it's working, just connect to it.

Did it work? Well, good. As the next step, you probably want to make sure it comes up automatically the next time you reboot your server. To make sure this happens, use the insserv apache2 command.

Was this article helpful?

0 0

Post a comment