This is an old revision of the document!
apachesurvival
This tutorial is for users of Debian GNU/Linux using the LAMP stack, wanting TLS encryption, multiple self-hosted websites, feature rich content management, etc., without sacrificing ownership or security. This tutorial will cover:
There is probably a bit more … but this will get us started. With the exception of Cacti, these are skills I learned on BSD / macOS and then migrated to Debian GNU/Linux which runs them better, has better implementations of the LAMP stack, more feature control, and most importantly is #freesoftware.
Installing apache, setting up two ore more websites.
sudo apache2ctl configtest
sudo apt install apache2
sudo mkdir -p /var/www/site1.com/public_html
sudo mkdir -p /var/www/site2.com/public_html
sudo chown -R $USER:$USER /var/www/site1.com/public_html
sudo chown -R $USER:$USER /var/www/site2.com/public_html
sudo chmod -R 755 /var/www
nano /var/www/site1.com/public_html/index.html
<html>
<head>
<title>site1</title>
</head>
<body>
<h1>site1</h1>
</body>
</html>
nano /var/www/site2.com/public_html/index.html
<html>
<head>
<title>site2</title>
</head>
<body>
<h1>site2</h1>
</body>
</html>
sudo cp /etc/apache2/sites-available/000-default.conf /etc/apache2/sites-available/site1.com.conf
sudo cp /etc/apache2/sites-available/000-default.conf /etc/apache2/sites-available/site2.com.conf
sudo nano /etc/apache2/sites-available/site1.com.conf
<VirtualHost *:80>
ServerAdmin netcmnd@site1.com
ServerName site1.com
ServerAlias www.site1.com
DocumentRoot /var/www/site1.com/public_html
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
</VirtualHost>
sudo nano /etc/apache2/sites-available/site2.com.conf
<VirtualHost *:80>
ServerAdmin netcmnd@site2.com
ServerName site2.com
ServerAlias www.site2.com
DocumentRoot /var/www/site2.com/public_html
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
</VirtualHost>
sudo a2ensite site1.com.conf
sudo a2ensite site2.com.conf
sudo cp -r /var/www/html /root/
sudo rm -r /var/www/html
sudo a2dissite 000-default.conf
sudo nano /etc/hosts
127.0.0.1 localhost
127.0.1.1 host.domain.com hostname
# The following lines are desirable for IPv6 capable hosts
::1 localhost ip6-localhost ip6-loopback
ff02::1 ip6-allnodes
ff02::2 ip6-allrouters
#Virtual Hosts - NOT Optional - replace xxx etc., with external IP
xxx.xxx.xxx.xxx site1.com xxx.xxx.xxx.xxx www.site1.com xxx.xxx.xxx.xxx site2.com xxx.xxx.xxx.xxx www.site2.com
sudo systemctl restart apache2.service
Visit site1.com and site2.com - debug, set up TLS - repeat this for additional sites, set up firewall w/ common exceptions.
sudo ufw install sudo ufw allow ssh sudo ufw allow 22 sudo ufw allow 222 sudo ufw allow http sudo ufw allow 80 sudo ufw allow https sudo ufw allow 443 sudo ufw allow 'WWW Secure' sudo ufw allow 'WWW Full' sudo ufw allow 'WWW' sudo ufw allow 1194/udp sudo ufw allow 1194 sudo ufw allow git sudo ufw allow openvpn sudo ufw allow samba sudo ufw allow nfs sudo ufw allow vnc sudo ufw allow 21 sudo ufw allow ftp sudo ufw enable