Apache Web Server Installation and Configuration
Apache Web Server Installation and Configuration
Overview
This page provides instructions for setting up and configuring Apache on buzz.deome.net. It includes steps for installing Apache, configuring virtual hosts for multiple sites, securing with SSL certificates, and basic performance tuning.
1. Apache Installation
-
Update System Packages:
- Start by updating the package list and upgrading existing packages:
sudo apt update && sudo apt upgrade -y
- Start by updating the package list and upgrading existing packages:
-
Install Apache:
- Install Apache with the following command:
sudo apt install apache2 -y
- Install Apache with the following command:
-
Start and Enable Apache:
- Start the Apache service and enable it to run on boot:
sudo systemctl start apache2 sudo systemctl enable apache2
- Start the Apache service and enable it to run on boot:
-
Verify Installation:
- Check the Apache status to ensure it’s running:
sudo systemctl status apache2
- Check the Apache status to ensure it’s running:
2. Basic Apache Configuration
-
Main Configuration File:
- The main Apache configuration file is located at:
/etc/apache2/apache2.conf
- The main Apache configuration file is located at:
-
Enable Recommended Modules:
- Enable commonly used modules:
sudo a2enmod rewrite ssl headers - Restart Apache to apply the changes:
sudo systemctl restart apache2
- Enable commonly used modules:
3. Setting Up Virtual Hosts
-
Create a New Virtual Host:
- For each site, create a configuration file in
/etc/apache2/sites-available/. For example, for wiki.deome.net:sudo nano /etc/apache2/sites-available/wiki.deome.net.conf - Add the following configuration:
<VirtualHost *:80> ServerName wiki.deome.net DocumentRoot /var/www/wiki <Directory /var/www/wiki> AllowOverride All </Directory> ErrorLog ${APACHE_LOG_DIR}/wiki_error.log CustomLog ${APACHE_LOG_DIR}/wiki_access.log combined </VirtualHost>
- For each site, create a configuration file in
-
Enable the Virtual Host:
- Use
a2ensiteto enable each virtual host:sudo a2ensite wiki.deome.net.conf - Reload Apache to apply changes:
sudo systemctl reload apache2
- Use
-
Repeat for Additional Sites:
- Create similar configuration files for gallery.deome.net, buzz.deome.net, and any other sites you plan to host.
4. SSL Configuration with Let’s Encrypt
-
Install Certbot:
- Install Certbot to automate SSL certificate generation:
sudo apt install certbot python3-certbot-apache -y
- Install Certbot to automate SSL certificate generation:
-
Generate SSL Certificates:
- Use Certbot to obtain SSL certificates for each virtual host:
sudo certbot --apache -d wiki.deome.net sudo certbot --apache -d gallery.deome.net - Certbot will automatically configure SSL for the specified domains.
- Use Certbot to obtain SSL certificates for each virtual host:
-
Set Up Auto-Renewal:
- To ensure certificates renew automatically:
sudo certbot renew --dry-run
- To ensure certificates renew automatically:
5. Performance and Optimization
-
Adjust Apache Settings:
- Open the main Apache configuration file:
sudo nano /etc/apache2/apache2.conf - Consider modifying these settings under the
mpm_prefork_moduleormpm_worker_module:KeepAlive On MaxKeepAliveRequests 100 KeepAliveTimeout 5
- Open the main Apache configuration file:
-
Enable Caching:
- Install and enable Apache caching modules if desired:
sudo a2enmod cache sudo a2enmod cache_disk sudo systemctl restart apache2
- Install and enable Apache caching modules if desired:
-
Optimize Logging:
- Adjust log levels or configure centralized logging if needed. Logging configuration is in each virtual host file and
/etc/apache2/apache2.conf.
- Adjust log levels or configure centralized logging if needed. Logging configuration is in each virtual host file and
6. Maintenance and Monitoring
-
Monitor Apache Status:
- Check Apache’s status periodically:
sudo systemctl status apache2
- Check Apache’s status periodically:
-
Check Logs:
- Access logs for each virtual host in
/var/log/apache2/, e.g.:sudo tail -f /var/log/apache2/wiki_access.log sudo tail -f /var/log/apache2/wiki_error.log
- Access logs for each virtual host in
-
Restarting Apache:
- Restart Apache after any configuration changes:
sudo systemctl restart apache2
- Restart Apache after any configuration changes:
This wiki page provides a thorough guide for Apache installation, virtual host setup, SSL configuration, and performance tuning. Let me know if you’d like any additional details or further customization for your setup!
No Comments