How does I start, restart, or stop Apache 2.x Web server on Ubuntu Linux operating systems using the 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 |
- /etc/init.d/apache2-A SYS v INIT style script to start/stop/restart the Apache2 service under Debian or Ubuntu Linux.
- serviceCommand-this command work on most Linux distributions including Debian and Ubuntu.
- upstartCommand-only works on latest version of Ubuntu.
- apache2ctlCommand-this method should work on all Linux and Unix like operating systems.
Method #1:/etc/init.d/apache2Command 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:serviceCommand 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:upstartCommand 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:apache2ctlCommand 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
Ubuntu Server Start/stop/restart apache2 Web server