Skip to content

Instantly share code, notes, and snippets.

@jagwarthegreat
Last active January 19, 2021 08:18
Show Gist options
  • Save jagwarthegreat/aae54e22b3b4eae4d217276c78099abe to your computer and use it in GitHub Desktop.
Save jagwarthegreat/aae54e22b3b4eae4d217276c78099abe to your computer and use it in GitHub Desktop.
APACHE2 COMMANDS

#Restart Apache 2 web server, enter:

# /etc/init.d/apache2 restart

#OR

$ sudo /etc/init.d/apache2 restart

#OR

$ sudo service apache2 restart

#To stop Apache 2 web server, enter:

# /etc/init.d/apache2 stop

#OR

$ sudo /etc/init.d/apache2 stop

#OR

$ sudo service apache2 stop

#To start Apache 2 web server, enter:

# /etc/init.d/apache2 start

#OR

$ sudo /etc/init.d/apache2 start

#OR

$ sudo service apache2 start

#A note about Debian/Ubuntu Linux systemd users

## Start command ##
systemctl start apache2.service
## Stop command ##
systemctl stop apache2.service
## Restart command ##
systemctl restart apache2.service

#CentOS/RHEL (Red Hat) Linux version 4.x/5.x/6.x or older specific commands

## Start ##
service httpd start
## Stop ##
service httpd stop
## Restart ##
service httpd restart

#CentOS/RHEL (Red Hat) Linux version 7.x or newer specific commands _Most modern distro now using systemd, so you need to use the following systemctl command:

## Start command ##
systemctl start httpd.service
## Stop command ##
systemctl stop httpd.service
## Restart command ##
systemctl restart httpd.service

#Alpine Linux start / stop / restart Apache 2 using openrc _We need to use the service command as root user:

# service apache2 start
# service apache2 stop
# service apache2 status
# service apache2 restart

#Session:

 * Stopping apache2 ...
 * Starting apache2

#Generic method to start/stop/restart Apache on a Linux/Unix _The syntax is as follows (must be run as root user):

## stop it ##
apachectl -k stop
## restart it ##
apachectl -k restart
## graceful restart it ##
apachectl -k graceful
## Start it ##
apachectl -f /path/to/your/httpd.conf
apachectl -f /usr/local/apache2/conf/httpd.conf
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment