How To Install Apache On Debian 13 Trixie

How To Install Apache On Debian 13 Trixie

Apache is one of the most popular and reliable web servers in the world. Many developers and system administrators still choose Apache because of its stability, flexibility, and wide community support. If you're running a VPS or dedicated server based on Debian 13 (Trixie), installing Apache is straightforward and only takes a few minutes.

This guide will walk you step-by-step through the full installation and basic configuration of Apache on Debian 13.

1. Update Your System

Before installing any packages, always update your system repository to ensure you get the latest stable version of software.

sudo apt update
sudo apt upgrade -y

2. Install Apache Web Server

Debian 13 provides Apache through its official repository. Install it using :

sudo apt install apache2 -y

This command installs :

  • apache2
  • apache2-utils
  • apache2-bin
  • required dependencies

3. Start And Enable Apache

After installation, Apache usually starts automatically. You can check its status :

sudo systemctl status apache2

To ensure Apache starts automatically at boot :

sudo systemctl enable apache2

To manually control the service :

sudo systemctl start apache2
sudo systemctl stop apache2
sudo systemctl restart apache2
sudo systemctl reload apache2

4. Allow Apache Through the Firewall (UFW)

If your server uses UFW, allow HTTP and HTTPS traffic :

sudo ufw allow 'Apache Full'
sudo ufw reload

Check allowed rules :

sudo ufw status

5. Verify Apache Installation

Open your browser and visit your server IP address :

http://YOUR_SERVER_IP

If Apache is working, you will see the default Apache2 Debian Default Page.

Alternatively, test with :

curl http://localhost

6. Manage Virtual Hosts

Virtual hosts allow you to host multiple domains on one server.

Create a directory for your website :
sudo mkdir -p /var/www/example.com/public_html
Set ownership :
sudo chown -R $USER:$USER /var/www/example.com/public_html
Create a sample index.html :
echo "Welcome to example.com" > /var/www/example.com/public_html/index.html
Create a new virtual host file :
sudo nano /etc/apache2/sites-available/example.com.conf

Add the following :

<VirtualHost *:80>
    ServerName example.com
    ServerAlias www.example.com
    DocumentRoot /var/www/example.com/public_html

    <Directory /var/www/example.com/public_html>
        AllowOverride All
        Require all granted
    </Directory>

    ErrorLog ${APACHE_LOG_DIR}/example_error.log
    CustomLog ${APACHE_LOG_DIR}/example_access.log combined
</VirtualHost>
Enable the virtual host :
sudo a2ensite example.com.conf
Disable the default site (optional) :
sudo a2dissite 000-default.conf
Reload Apache :
sudo systemctl reload apache2

7. Enable .htaccess Support (Optional)

If you need '.htaccess' support (for CMS like WordPress or frameworks like Laravel) :

sudo nano /etc/apache2/apache2.conf

Find :

AllowOverride None

Change to :

AllowOverride All

Save and reload :

sudo systemctl reload apache2

8. Enable Useful Apache Modules

Common modules you may want :

Enable rewrite module (SEO-friendly URLs) :
sudo a2enmod rewrite
sudo systemctl restart apache2
Enable SSL module :
sudo a2enmod ssl
Enable headers module :
sudo a2enmod headers

9. Check Apache Configuration

Before restarting Apache, always check for syntax errors :

sudo apache2ctl configtest

Expected result :

Syntax OK

10. Uninstalling Apache (If Needed)

If you ever need to remove Apache :

sudo apt remove apache2 -y
sudo apt purge apache2 -y
sudo apt autoremove -y

Conclusion

Installing Apache on Debian 13 is simple and fast. Once installed, you can begin deploying websites, configuring virtual hosts, enabling modules, and securing your server with SSL. Apache remains a powerful and flexible solution for small websites, enterprise-level applications, and everything in between.

ahmad

Ahmad

I am just began write something this similar tips website, and hope you like it what I just began.