Tools: Essential Guide: Installing Apache Web Server on Ubuntu 26.04

Tools: Essential Guide: Installing Apache Web Server on Ubuntu 26.04

Install Apache

Manage the Apache Service

Configure Firewall Rules

Create a Virtual Host

Secure with Let's Encrypt SSL

Next Steps Apache is one of the most widely deployed web servers, with native support in Ubuntu 26.04's default APT repository requiring no external sources. This guide covers the full setup from installation to production readiness, including virtual host configuration for domain-based routing and SSL termination with a free Let's Encrypt certificate backed by automatic renewal. Apache is available directly from Ubuntu 26.04's default APT repository. 1. Update the APT package index: 3. Verify the installed version: Enable Apache as a systemd service so it starts automatically on every boot. 1. Enable and start the service: 2. Check the service status: 3. Stop or restart the service when needed: Open ports 80 and 443 to allow HTTP and HTTPS traffic through the firewall. Open http://YOUR-SERVER-IP in a browser. The Apache default page confirms the service is running. Virtual hosts allow Apache to serve multiple domains from the same server. Replace app.example.com with your actual domain throughout this section. 1. Create the web root directory: 2. Create a sample HTML page: 3. Disable the default site: 4. Create the virtual host configuration: 5. Enable the site, test the configuration, and reload: Verify the virtual host is serving correctly: Certbot automates certificate issuance and renewal through Let's Encrypt, with an Apache plugin that handles virtual host configuration directly. 1. Install Certbot with the Apache plugin: 2. Generate and install the certificate: Certbot obtains the certificate, updates the virtual host to enable HTTPS, and configures an HTTP-to-HTTPS redirect automatically. 3. Test the auto-renewal timer: A dry run without errors confirms automatic renewal is configured correctly. Apache is now running and serving your domain over HTTPS. From here you can: For the complete guide, visit the original article on Vultr Docs. Templates let you quickly answer FAQs or store snippets for re-use. Hide child comments as well For further actions, you may consider blocking this person and/or reporting abuse

Command

Copy

$ -weight: 600;">sudo -weight: 500;">apt -weight: 500;">update $ -weight: 600;">sudo -weight: 500;">apt -weight: 500;">update $ -weight: 600;">sudo -weight: 500;">apt -weight: 500;">update $ -weight: 600;">sudo -weight: 500;">apt -weight: 500;">install apache2 -y $ -weight: 600;">sudo -weight: 500;">apt -weight: 500;">install apache2 -y $ -weight: 600;">sudo -weight: 500;">apt -weight: 500;">install apache2 -y $ apachectl -v $ apachectl -v $ apachectl -v $ -weight: 600;">sudo -weight: 500;">systemctl -weight: 500;">enable apache2 $ -weight: 600;">sudo -weight: 500;">systemctl -weight: 500;">start apache2 $ -weight: 600;">sudo -weight: 500;">systemctl -weight: 500;">enable apache2 $ -weight: 600;">sudo -weight: 500;">systemctl -weight: 500;">start apache2 $ -weight: 600;">sudo -weight: 500;">systemctl -weight: 500;">enable apache2 $ -weight: 600;">sudo -weight: 500;">systemctl -weight: 500;">start apache2 $ -weight: 600;">sudo -weight: 500;">systemctl -weight: 500;">status apache2 $ -weight: 600;">sudo -weight: 500;">systemctl -weight: 500;">status apache2 $ -weight: 600;">sudo -weight: 500;">systemctl -weight: 500;">status apache2 $ -weight: 600;">sudo -weight: 500;">systemctl -weight: 500;">stop apache2 $ -weight: 600;">sudo -weight: 500;">systemctl -weight: 500;">restart apache2 $ -weight: 600;">sudo -weight: 500;">systemctl -weight: 500;">stop apache2 $ -weight: 600;">sudo -weight: 500;">systemctl -weight: 500;">restart apache2 $ -weight: 600;">sudo -weight: 500;">systemctl -weight: 500;">stop apache2 $ -weight: 600;">sudo -weight: 500;">systemctl -weight: 500;">restart apache2 $ -weight: 600;">sudo ufw allow 80/tcp $ -weight: 600;">sudo ufw allow 443/tcp $ -weight: 600;">sudo ufw allow 80/tcp $ -weight: 600;">sudo ufw allow 443/tcp $ -weight: 600;">sudo ufw allow 80/tcp $ -weight: 600;">sudo ufw allow 443/tcp $ -weight: 600;">sudo mkdir -p /var/www/app.example.com $ -weight: 600;">sudo chown -R www-data:www-data /var/www/app.example.com $ -weight: 600;">sudo mkdir -p /var/www/app.example.com $ -weight: 600;">sudo chown -R www-data:www-data /var/www/app.example.com $ -weight: 600;">sudo mkdir -p /var/www/app.example.com $ -weight: 600;">sudo chown -R www-data:www-data /var/www/app.example.com $ -weight: 600;">sudo nano /var/www/app.example.com/index.html $ -weight: 600;">sudo nano /var/www/app.example.com/index.html $ -weight: 600;">sudo nano /var/www/app.example.com/index.html <!DOCTYPE html> <html> <head><title>My App</title></head> <body><h1>Hello World from Apache on Ubuntu 26.04</h1></body> </html> <!DOCTYPE html> <html> <head><title>My App</title></head> <body><h1>Hello World from Apache on Ubuntu 26.04</h1></body> </html> <!DOCTYPE html> <html> <head><title>My App</title></head> <body><h1>Hello World from Apache on Ubuntu 26.04</h1></body> </html> $ -weight: 600;">sudo a2dissite 000-default.conf $ -weight: 600;">sudo a2dissite 000-default.conf $ -weight: 600;">sudo a2dissite 000-default.conf $ -weight: 600;">sudo nano /etc/apache2/sites-available/app.example.com.conf $ -weight: 600;">sudo nano /etc/apache2/sites-available/app.example.com.conf $ -weight: 600;">sudo nano /etc/apache2/sites-available/app.example.com.conf <VirtualHost *:80> ServerName app.example.com DocumentRoot /var/www/app.example.com <Directory /var/www/app.example.com> AllowOverride All Require all granted </Directory> ErrorLog ${APACHE_LOG_DIR}/app.example.com-error.log CustomLog ${APACHE_LOG_DIR}/app.example.com-access.log combined </VirtualHost> <VirtualHost *:80> ServerName app.example.com DocumentRoot /var/www/app.example.com <Directory /var/www/app.example.com> AllowOverride All Require all granted </Directory> ErrorLog ${APACHE_LOG_DIR}/app.example.com-error.log CustomLog ${APACHE_LOG_DIR}/app.example.com-access.log combined </VirtualHost> <VirtualHost *:80> ServerName app.example.com DocumentRoot /var/www/app.example.com <Directory /var/www/app.example.com> AllowOverride All Require all granted </Directory> ErrorLog ${APACHE_LOG_DIR}/app.example.com-error.log CustomLog ${APACHE_LOG_DIR}/app.example.com-access.log combined </VirtualHost> $ -weight: 600;">sudo a2ensite app.example.com.conf $ -weight: 600;">sudo apachectl configtest $ -weight: 600;">sudo -weight: 500;">systemctl -weight: 500;">restart apache2 $ -weight: 600;">sudo a2ensite app.example.com.conf $ -weight: 600;">sudo apachectl configtest $ -weight: 600;">sudo -weight: 500;">systemctl -weight: 500;">restart apache2 $ -weight: 600;">sudo a2ensite app.example.com.conf $ -weight: 600;">sudo apachectl configtest $ -weight: 600;">sudo -weight: 500;">systemctl -weight: 500;">restart apache2 $ -weight: 500;">curl http://app.example.com $ -weight: 500;">curl http://app.example.com $ -weight: 500;">curl http://app.example.com $ -weight: 600;">sudo -weight: 500;">apt -weight: 500;">install certbot python3-certbot-apache -y $ -weight: 600;">sudo -weight: 500;">apt -weight: 500;">install certbot python3-certbot-apache -y $ -weight: 600;">sudo -weight: 500;">apt -weight: 500;">install certbot python3-certbot-apache -y $ -weight: 600;">sudo certbot --apache -d app.example.com --agree-tos $ -weight: 600;">sudo certbot --apache -d app.example.com --agree-tos $ -weight: 600;">sudo certbot --apache -d app.example.com --agree-tos $ -weight: 600;">sudo certbot renew --dry-run $ -weight: 600;">sudo certbot renew --dry-run $ -weight: 600;">sudo certbot renew --dry-run - Add PHP via PHP-FPM to serve dynamic content alongside Apache - Configure Apache as a reverse proxy in front of a Node.js or Python application - Enable HTTP/2 support with -weight: 600;">sudo a2enmod http2