English translation
Apache2 Web Deployment Tutorial #15: Configure Automatic Startup and Service Management
In the previous article, we learned how to start, stop, and restart the Apache2 service. In this article, we will explore how to configure Apache2 for automatic startup—ensuring that Apache2 is ready to serve web requests immediately after system boot. This configuration is critical for maintaining high website availability. Below, we’ll walk through the Apache2 auto-start configuration process in detail, including practical examples and code snippets.
What Is Automatic Startup Configuration?
Automatic startup configuration refers to automatically loading and launching the Apache2 service during operating system boot. This means that even after a server reboot, Apache2 starts up automatically—without manual intervention. Such automation significantly improves operational efficiency and minimizes website downtime.
Configuring Apache2 for Automatic Startup
On most modern Linux distributions, Apache2 is managed via systemd. Below, we explain how to use the systemctl command to configure Apache2 for automatic startup.
Check the Apache2 Service Status
First, verify the current status of the Apache2 service:
systemctl status apache2
If Apache2 is not running, start it with:
sudo systemctl start apache2
Enable Apache2 Automatic Startup
To ensure Apache2 starts automatically at boot time, run:
sudo systemctl enable apache2
This command creates a symbolic link in the appropriate systemd directory (e.g., /etc/systemd/system/multi-user.target.wants/apache2.service), instructing the system to launch Apache2 during the boot sequence.
Disable Apache2 Automatic Startup
To later disable automatic startup, use:
sudo systemctl disable apache2
This removes the symbolic link created earlier, preventing Apache2 from starting automatically on boot.
Practical Example
Assume you’re using Ubuntu Server 20.04 with Apache2 already installed. Here’s how to configure Apache2 for automatic startup:
-
Confirm Apache2 is installed and start the service:
sudo apt update sudo apt install apache2 -y sudo systemctl start apache2 -
Verify the service is active and running:
systemctl status apache2 -
Enable automatic startup at boot:
sudo systemctl enable apache2 -
Reboot the system and confirm Apache2 starts automatically:
sudo rebootAfter rebooting, check again whether Apache2 is running:
systemctl status apache2
Summary
In this article, we covered how to configure Apache2 for automatic startup using systemd, ensuring the service resumes operation seamlessly after system reboots. This capability is essential for maintaining service continuity and high availability.
In the next article, we’ll dive into Apache2 log management and monitoring—equipping you with tools and techniques to effectively maintain, troubleshoot, and secure your Apache2 deployment. Stay tuned!
Continue