Open Source Web Development with LAMP Using Linux, Apache, MySQL, Perl, and PHP [Electronic resources] نسخه متنی

اینجــــا یک کتابخانه دیجیتالی است

با بیش از 100000 منبع الکترونیکی رایگان به زبان فارسی ، عربی و انگلیسی

Open Source Web Development with LAMP Using Linux, Apache, MySQL, Perl, and PHP [Electronic resources] - نسخه متنی

James Lee, Brent Ware

| نمايش فراداده ، افزودن یک نقد و بررسی
افزودن به کتابخانه شخصی
ارسال به دوستان
جستجو در متن کتاب
بیشتر
تنظیمات قلم

فونت

اندازه قلم

+ - پیش فرض

حالت نمایش

روز نیمروز شب
جستجو در لغت نامه
بیشتر
لیست موضوعات
توضیحات
افزودن یادداشت جدید










3.2 Starting, Stopping, and Restarting Apache


If you installed Linux as suggested in Chapter 2, Apache should be running when you start your machine. To check, load this URL in your browser:

http://localhost/

You should see the Apache welcome page, as shown in Hatch+ 02]). To check whether Apache is running, try the following:


Figure 3.2. Apache welcome page



# ps ax | grep httpd

Although the program is called Apache, the daemon's name is httpd on Red Hat, apache on some others. You should see something like this:


1922 ? S 0:00 /usr/sbin/httpd
1927 ? S 0:00 /usr/sbin/httpd
1928 ? S 0:00 /usr/sbin/httpd
1929 ? S 0:00 /usr/sbin/httpd
1930 ? S 0:00 /usr/sbin/httpd
1932 ? S 0:00 /usr/sbin/httpd
1933 ? S 0:00 /usr/sbin/httpd
1935 ? S 0:00 /usr/sbin/httpd
1937 ? S 0:00 /usr/sbin/httpd

Several copies of the server are running, so Apache can process more than one request at a time.

If you don't see a number of httpd PIDs, start the server as follows:


# /etc/init.d/httpd start

In addition to using the ps command, you can check the status of your server by executing the following command:


# /etc/init.d/httpd status

The output of this command should resemble this:
[5]

[5] Reformatted to fit the page. We often have to do this, so don't sweat small differences like this.



httpd (pid 1937 1935 1933 1932 1930
1929 1928 1927 1922) is running...

If you didn't get this sort of result, or you got an error message, review the logs in /var/log/httpd for error messages, specifically error_log, and read the man page (man httpd, not man apache). Unfortunately, the number of possible errors is great, and we can't possibly cover all of themthe logs are key to narrowing down the problem.

If httpd is running, and you didn't see the welcome page when you loaded http://localhost/, you have a problem.

First, try restarting it. There are several ways to do thisthe easiest is to use the provided start-up script:


# /etc/init.d/httpd stop
# /etc/init.d/httpd start

Also good to know is this:


# /etc/init.d/httpd help

The option help is not a defined option, but if you pass an invalid option to /etc/init.d/httpd, it will tell you all the valid ones.

You can also do thisit sends the USR1 signal to all occurrences of httpd, making the daemon reload the configuration file:


# /etc/init.d/httpd graceful

or:


# killall -USR1 httpd

Killall may not be installed on your system. If it isn't, consider finding it and installing it; it's invaluable. It saves the step of finding the process ID and passing that to the kill command. The parameter USR1 (man kill and man signal) is the graceful way to reload a processit allows the process and its children to exit after serving existing requests before starting again. If all else fails, there's always kill -9.

N

The gentlest way to restart apache is to use the graceful option to the start-up script. Therefore, hereafter when we need to restart the server (usually to reread the configuration file), we will execute the following command:


# /etc/init.d/httpd graceful

If all this doesn't work, you may need to adopt sterner measures. See the Apache documents at httpd.apache.org/docs/. The Linux Documentation Project at www.linuxdoc.org/ is another excellent place to waste a few hours. Another excellent way to figure out how to fix errors, or to find a support group to commiserate with, is to paste the error (enclosed in quotes) into Google or Google's group interface.

Once you have Apache running, make sure it starts at boot. Execute chkconfig:


# chkconfig --list httpd
httpd 0:off 1:off 2:off 3:on 4:on 5:on 6:off

If you do not see output indicating that 3, 4, and 5 are on, turn them on:


# chkconfig httpd on
# chkconfig --list httpd
httpd 0:off 1:off 2:off 3:on 4:on 5:on 6:off

Next time you reboot the machine (shutdown -r now as root or with sudo), check that httpd starts with ps or /etc/init.d/httpd status.


/ 136