Apache service, or HTTPd service, how to start and how to start it.

Source: Internet
Author: User
Apache service, or HTTPd service, how to start and how to start it.

Operating System Environment: Red Hat 5, details:
# Uname-

Linux machine1 2.6.18-164. el5xen #1 SMP Tue Aug 18 15:59:52 EDT 2009 x86_64 x86_64 x86_64 GNU/Linux
# Cat/etc/RedHat-release

Red Hat Enterprise Linux Server Release 5.4 (tikanga)

Apache, or httpd, version:
#/Usr/sbin/httpd-V

Server version: Apache/2.2.3
Server built: Jul 15 2009 09:02:25
Or
#/Usr/sbin/apachectl-V

Server version: Apache/2.2.3
Server built: Jul 15 2009 09:02:25

I have been talking about Apache or httpd before;
In fact, httpd is a service, and Apache is a trademark;
Just like pure water is a product, while Wahaha is a brand;
But because Apache is too famous, it seems that Apache is talking about the HTTPd service.
Therefore, we will only talk about the HTTPd service later.

/Usr/sbin/apachectl is actually a script;


/Usr/sbin/httpd
Is the real program;

Next, how do I start the HTTPd service?
Script startup:
#/Usr/sbin/apachectl start

[Root @ radius guoq] # ps-Ef | grep Apache
Apache 6680 6679 0? 00:00:00/usr/sbin/httpd-K start
Apache 6681 6679 0? 00:00:00/usr/sbin/httpd-K start
Apache 6682 6679 0? 00:00:00/usr/sbin/httpd-K start
Apache 6683 6679 0? 00:00:00/usr/sbin/httpd-K start
Apache 6684 6679 0? 00:00:00/usr/sbin/httpd-K start
Apache 6685 6679 0? 00:00:00/usr/sbin/httpd-K start
Apache 6686 6679 0? 00:00:00/usr/sbin/httpd-K start
Apache 6687 6679 0? 00:00:00/usr/sbin/httpd-K start
Root 6689 5393 0 00:00:00 pts/1 grep Apache
Stop is #/usr/sbin/apachectl stop; You are right;

If you read the script/usr/sbin/apachectl, you will find two secrets:

1. parameters accepted by the script
Start, stop, restart, and
Graceful, graceful-stop;
2. In fact, the script still passes the parameter
/Usr/sbin/httpd;

Therefore, we can

#/Usr/sbin/httpd-K start
Start the service;


#/Usr/sbin/httpd-K stop
Stop the service;

The following answers how to start the instance at startup?
If you search
# Find/-name "httpd"

/Var/log/httpd
/Usr/sbin/httpd
/Usr/lib64/httpd
/Etc/rc. d/init. d/httpd

/Etc/logrotate. d/httpd
/Etc/httpd
/Etc/sysconfig/httpd
/Home/guoq/osrc/tcl8.4.19/tests/httpd
/Opt/soft/httpd-2.2.14/httpd
/Opt/soft/httpd-2.2.14/. libs/httpd
/Opt/apache2.2.14/bin/httpd

We will find that Apache has prepared the boot script for us,


/Etc/rc. d/init. d/httpd

You can check whether it is in the boot list:

# Chkconfig -- list | grep httpd
Httpd 0: Close 1: Close 2: Close 3: Close 4: Close 5: Close 6: Close

If needed, you can add it to the startup list:

# Chkconfig -- add httpd
Or, delete from the boot list:




# Chkconfig -- del httpd




In my system, it is already in the boot list:




Httpd 0: Close 1: Close 2: Close 3: Close 4: Close 5: Close 6: Close

But it is not allowed to start automatically

I want it to start automatically at the current running level. I recently learned Java and PHP;
# Chkconfig -- level 5 httpd on

# Chkconfig -- list httpd
Httpd 0: Disabled 1: Disabled 2: Disabled 3: Disabled 4: Disabled 5: Enabled
6: Disable

Wait, how do I know my running level?
# Runlevel

N 5

The full text is complete.




I don't know why the above method cannot run on my Ubuntu, So I went online and looked for it again.




Find the following method:

 

1) Add the program script to the/etc/init. d directory.

Sudo CP/home/cnscn/my_servd/etc/init. d/

2) Add to startup list

Sudo update-rc.d my_servd defaults

3) The following connections are generated:

Adding system startup for/etc/init. d/my_servd...
/Etc/rc0.d/k20my_servd-> ../init. d/my_servd
/Etc/rc1.d/k20my_servd-> ../init. d/my_servd
/Etc/rc6.d/k20my_servd-> ../init. d/my_servd
/Etc/rc2.d/s20my_servd-> ../init. d/my_servd
/Etc/rc3.d/s20my_servd-> ../init. d/my_servd
/Etc/rc4.d/s20my_servd-> ../init. d/my_servd
/Etc/rc5.d/s20my_servd-> ../init. d/my_servd

4) Specify the startup and shutdown levels (20 indicates a level) (note the following.
)

Sudo update-rc.d my_servd start 20
3 4 5.
Start at level 3, 4, and 5
Sudo update-rc.d my_servd start 20
0 1 2 6.

Close at level 3, 4, and 5

Or
Sudo update-rc.d my_servd start 20 3 4 5.

Stop 20 0 1 2 6.

5) Remove the service

Sudo update-rc.d-F my_servd remove

 

I tried it. It seems I can !!

 

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.