Cheat-sheet for Apache2 commands Linux Mint / Ubuntu / Debian

The Apache HTTP Server is called Apache, Apache is a Web server application which is suitable for All LINUX and UNIX distribution and also support for windows. Apache support IP based virtual hosting & Name based virtual hosting. Its serving .html, .php, .pl, .cgi, etc ,..Apache is developed and maintained by open community of developers under Apache Software Foundation. Here i added mostly using apache2 commands for instant purpose.
cheat-sheet-for-apache2-commands-linux-mint-ubuntu-debian

Apache Installation & Configuration

+----------------------------------------+----------------------------------------+
| Apache2 Service Commands               | Apache2 Important Files                |
+----------------------------------------+----------------------------------------+
| Starting Apache2                       | Apach2 Syntax check                    |
| $ sudo /etc/init.d/apache2 start       | $ apachectl configtest                 |
| $ sudo service apache2 start           | $ apachectl -t                         |
| $ sudo apachectl -k start              |                                        |
+----------------------------------------+----------------------------------------+
| Restarting Apache2                     | Apache2 Web root                       |
| $ sudo /etc/init.d/apache2 restart     | $ /var/www/html - default              |
| $ sudo service apache2 restart         | $ /var/www/ - New domain location      |
| $ sudo apachectl -k restart            |                                        |
+----------------------------------------+----------------------------------------+
| Stopping Apache2                       | Enable / Disable Virtual Hosts         |
| $ sudo /etc/init.d/apache2 stop        | $ sudo a2ensite xxxx.conf              |
| $ sudo service apache2 stop            | $ sudo a2dissite xxxx.conf             |
| $ sudo apachectl -k stop               |                                        |
+----------------------------------------+----------------------------------------+
| Status Apache2                         | Loaded apache2 Modules                 |
| $ sudo /etc/init.d/apache2 status      | $ apachectl -M                         |
| $ sudo service apache2 status          | $ apache2ctl -M                        |
+----------------------------------------+----------------------------------------+
| Reload Apache                          | Apache2 Config file's                  |
| $ sudo /etc/init.d/apache2 reload      | $ /etc/apache2/apache2.conf            |
| $ sudo service apache2 reload          | $ /etc/apache2/ports.conf              |
| $ sudo apachectl -k reload             | $ /etc/apache2/sites-available/xxx.conf|
+----------------------------------------+----------------------------------------+
| Apache2 Graceful                       | Available apache2 Modules              |
| $ sudo apachectl -k graceful           | $ /usr/lib/apache2/modules/            |
| $ sudo apachectl -k graceful-stop      |                                        |
|                                        +----------------------------------------+
|                                        | Apache2 log file's                     |
|                                        | $ /var/log/apache2/error.log           |
|                                        | $ /var/log/apache2/access.log          |
+----------------------------------------+----------------------------------------+
  • Start : To start apache2 service/daemon
  • Stop : To stop apache2 service/daemon
  • Restart : To restart apache2 service/daemon
  • Status : To check apache2 status whether its running or not
  • Reload : To reload the apache2.conf file
  • Graceful : Graceful operation is completely different compare with normal operation. For example, When you use service apache2 restart It will kill all the children & parant process immediately and restart the daemon completely. when you doing that action all your current connection got aborted But if you are using Graceful option while restarting apache daemon, Graceful or USR1 signal causes the parent process to advise the children to exit after their current request (or to exit immediately if they’re not serving anything). The parent re-reads its configuration files and re-opens its log files. As each child dies off the parent replaces it with a child from the new generation of the configuration, which begins serving new requests immediately.
  • Enable Virtual Hosts : To enable newly added virtual host
  • Disable Virtual Hosts : To disable enabled virtual host
  • Syntax check : This will help you to dignoest the syntax error on apache2.conf file.

Magesh Maruthamuthu

Love to play with all Linux distribution

You may also like...

  • Thanks for this. Very helpful. I spotted one typo–you need to add “sudo” in front of “apachectl -k restart.”

Close
Please support the site
By clicking any of these buttons you help our site to get better