Overview
Apache HTTP Server (package apache2 on Debian/Ubuntu, httpd on RHEL family) is a
mature, flexible web server. It is a common choice for PHP sites, WordPress and
traditional LAMP stacks. This article shows how to install Apache, serve a first site and
manage the service on an ALYPOD CPU Pod.
Before you begin
- A CPU Pod with root/sudo access.
- Ports 80 and 443 reachable (allow them in the ALYPOD firewall).
- A domain or the Pod's IP for testing.
Steps
Install
```bash
Debian / Ubuntu
sudo apt update && sudo apt install -y apache2
RHEL / AlmaLinux / Rocky
sudo dnf install -y httpd ```
Start and enable
bash
sudo systemctl enable --now apache2 # or httpd
sudo systemctl status apache2
Allow through the local firewall (if firewalld is used)
bash
sudo firewall-cmd --permanent --add-service=http --add-service=https
sudo firewall-cmd --reload
Create a virtual host
- Create the directory and a test page:
bash
sudo mkdir -p /var/www/example.com/html
echo "<h1>Hello from ALYPOD</h1>" | sudo tee /var/www/example.com/html/index.html
sudo chown -R www-data:www-data /var/www/example.com # apache:apache on RHEL
- Add a vhost config. Debian/Ubuntu —
/etc/apache2/sites-available/example.com.conf:
apache
<VirtualHost *:80>
ServerName example.com
ServerAlias www.example.com
DocumentRoot /var/www/example.com/html
ErrorLog ${APACHE_LOG_DIR}/example.com-error.log
CustomLog ${APACHE_LOG_DIR}/example.com-access.log combined
</VirtualHost>
- Enable the site (Debian/Ubuntu) or drop it in
/etc/httpd/conf.d/(RHEL):
bash
sudo a2ensite example.com.conf
sudo a2dissite 000-default.conf
sudo systemctl reload apache2
- Test the configuration before reloading in future:
bash
sudo apachectl configtest
Troubleshooting
- Problem:
Address already in use. Solution: Another web server (nginx) is bound to port 80 — stop it or change the vhost port. - Problem: 403 Forbidden. Solution: Check file ownership and directory
Executepermission, and confirm theDocumentRootpath. - Problem: Config not applied. Solution: Reload, do not restart, after
configtestpasses; a broken config will not be loaded.
Related articles
- [Installing the Nginx web server]
- [Installing PHP and common extensions]
- [Setting up a free Let's Encrypt SSL certificate]
