欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页

Ubuntu Linux: Start / Restart / Stop Apache Web Server

程序员文章站 2022-03-06 23:49:58
...

Ubuntu Linux: Start / Restart / Stop Apache Web Server

by NIX CRAFT on FEBRUARY 6, 2008 · 20 COMMENTS· LAST UPDATED NOVEMBER 2, 2013

in APACHECOMMANDSDEBIAN / UBUNTU

 

Ubuntu Linux: Start / Restart / Stop Apache Web Server
            
    
    博客分类: linux UbuntuStartRestartStopApache 
How do I start, restart, or stop Apache 2.x web server on Ubuntu Linux operating systems using command line options?

You can use any one of the following method to restart / start / stop your Apache (httpd) sever on Ubuntu:

 

 

Tutorial details  
Difficulty Easy (rss)
Root privileges Yes
Requirements Shell
Estimated completion time 1m
  1. /etc/init.d/apache2 - A sys v init style script to start / stop / restart the Apache2 service under Debian or Ubuntu Linux.
  2. service command - This command work in most Linux distributions including Debian and Ubuntu.
  3. upstart command - Only works on latest version of Ubuntu.
  4. apache2ctl command - This method should work on all Linux and Unix like operating systems.

Method #1: /etc/init.d/apache2 command examples

You need to login as root user or use the sudo command to control Apache web-server.

Task: Start Apache 2 Server

# /etc/init.d/apache2 start
or
$ sudo /etc/init.d/apache2 start

Task: Restart Apache 2 Server

# /etc/init.d/apache2 restart
or
$ sudo /etc/init.d/apache2 restart

Task: Stop Apache 2 Server

# /etc/init.d/apache2 stop
or
$ sudo /etc/init.d/apache2 stop

Method #2: service command examples

To restart Apache 2, enter:
$ sudo service apache2 restart
To stop Apache 2, enter:
$ sudo service apache2 stop
To start Apache 2, enter:
$ sudo service apache2 start
To gracefully reload Apache 2, enter:
$ sudo service apache2 reload

Method #3: upstart command examples

To start Apache 2 on Ubuntu, run:
$ sudo start apache2
To stop Apache 2 on Ubuntu, run:
$ sudo stop apache2
To restart Apache 2 on Ubuntu, run:
$ sudo restart apache2
To gracefully reload Apache 2 on Ubuntu, run:
$ sudo restart apache2

Method #4: apache2ctl command examples

apache2ctl is Apache HTTP server control interface command, which can be used to stop or start web server under any Linux distribution or UNIX.
To start Apache 2 on Ubuntu, type:
$ sudo apache2ctl start
To stop Apache 2 on Ubuntu, type:
$ sudo apache2ctl stop
To restart Apache 2 on Ubuntu, type:
$ sudo apache2ctl restart
To gracefully reload Apache 2 on Ubuntu, type:
$ sudo apache2ctl graceful