Install
sudo apt update
sudo apt upgrade apache2
sudo service apache2 start
sudo service apache2 stop
sudo service apache2 restart
Create Site Directories Cheat Sheet
sudo mkdir -p /var/www/example.com
sudo chown -R $USER:$USER /var/www/example.com
Create Virtual Host Files Cheat Sheet
sudo vim /etc/apache2/sites-available/example.com.conf
<VirtualHost *:80>
ServerName example.com
ServerAlias www.example.com
ServerAdmin webmaster@example.com
DocumentRoot /var/www/example.com
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
</VirtualHost>
Enable Virtual Host Files Cheat Sheet
sudo a2ensite example.com.conf
sudo service apache2 reload
Configure Logrotate Cheat Sheet
/var/log/apache2/*.log {
monthly
missingok
rotate 12
compress
notifempty
create 640 root adm
sharedscripts
dateext
dateformat -%Y-%m
dateyesterday
postrotate
if /etc/init.d/apache2 status > /dev/null ; then \
/etc/init.d/apache2 reload > /dev/null; \
fi;
endscript
prerotate
if [ -d /etc/logrotate.d/httpd-prerotate ]; then \
run-parts /etc/logrotate.d/httpd-prerotate; \
fi;
endscript
}