link

Apache

Apache commands for managing web servers, load balancers, and reverse proxies

30 commands

Commands

30 commands available
Resources

Learn Apache Deeper

Master Apache web server with comprehensive resources

apache

Start Apache

Start Apache web server

sudo systemctl start apache2
service
management
apache

Stop Apache

Stop Apache web server

sudo systemctl stop apache2
service
management
apache

Restart Apache

Restart Apache web server

sudo systemctl restart apache2
service
management
apache

Reload Apache

Reload Apache configuration

sudo systemctl reload apache2
service
configuration
apache

Check Apache Status

Check Apache service status

sudo systemctl status apache2
service
monitoring
apache

Test Configuration

Test Apache configuration syntax

sudo apachectl configtest
configuration
debugging
apache

List Enabled Sites

List enabled virtual hosts

sudo apache2ctl -S
configuration
virtualhost
apache

Enable Site

Enable a virtual host

sudo a2ensite example.com
configuration
virtualhost
apache

Disable Site

Disable a virtual host

sudo a2dissite example.com
configuration
virtualhost
apache

Enable Module

Enable an Apache module

sudo a2enmod rewrite
configuration
module
apache

Disable Module

Disable an Apache module

sudo a2dismod rewrite
configuration
module
apache

View Access Log

View Apache access logs

sudo tail -f /var/log/apache2/access.log
logs
monitoring
apache

View Error Log

View Apache error logs

sudo tail -f /var/log/apache2/error.log
logs
debugging
apache

Rotate Logs

Rotate Apache log files

sudo apache2ctl graceful
logs
maintenance
apache

List Modules

List loaded Apache modules

sudo apache2ctl -M
module
configuration
apache

Generate SSL Certificate

Generate self-signed SSL certificate

sudo openssl req -x509 -nodes -days 365 -newkey rsa:2048 -keyout /etc/ssl/private/apache-selfsigned.key -out /etc/ssl/certs/apache-selfsigned.crt
ssl
security
apache

Create Virtual Host

Create virtual host configuration

sudo nano /etc/apache2/sites-available/example.com.conf
virtualhost
configuration
apache

Default Virtual Host

Edit default virtual host

sudo nano /etc/apache2/sites-available/000-default.conf
virtualhost
configuration
apache

Create Password File

Create password protected directory

sudo htpasswd -c /etc/apache2/.htpasswd username
security
authentication
apache

Add Security Headers

Add security headers to Apache

sudo nano /etc/apache2/conf-available/security-headers.conf
security
headers
apache

Enable Gzip Compression

Enable mod_deflate for compression

sudo a2enmod deflate
performance
compression
apache

Enable Caching

Enable mod_expires for caching

sudo a2enmod expires
performance
caching
apache

Change Listening Port

Change Apache listening port

sudo nano /etc/apache2/ports.conf
configuration
network
apache

Check MPM Status

Check Multi-Processing Module status

sudo apache2ctl -V | grep -i mpm
performance
configuration
apache

Change MPM

Change Multi-Processing Module

sudo a2dismod mpm_prefork && sudo a2enmod mpm_event && sudo systemctl restart apache2
performance
configuration
apache

Enable .htaccess

Allow .htaccess overrides

sudo nano /etc/apache2/apache2.conf
configuration
security
apache

URL Rewriting

Enable URL rewriting

sudo a2enmod rewrite
configuration
seo
apache

Directory Indexing

Enable/disable directory listing

sudo nano /etc/apache2/mods-available/autoindex.conf
configuration
security
apache

PHP Configuration

Configure PHP settings

sudo nano /etc/php/7.4/apache2/php.ini
configuration
php
apache

SSL Configuration

Configure SSL/TLS settings

sudo nano /etc/apache2/mods-available/ssl.conf
security
ssl