How to install Apache2 on a BoxToPlay Linux VPS

How to install Apache2 on a BoxToPlay Linux VPS

#VPS #Tutorial
April 30, 2026

Installing Apache2 on a BoxToPlay Linux VPS is a solid way to host websites, web apps, or internal tools. In this article, we walk you through each step, from preparing the VPS to testing your first page.


1. Requirements on your BoxToPlay VPS

Before you start, make sure:

  • You already have a BoxToPlay Linux VPS created.
  • You can access the VPS:
    • via SSH from your local machine, or
    • via the console available in your BoxToPlay panel.
  • You have an account with administrator rights (root or a user with sudo).

The commands below are designed for Debian/Ubuntu-based systems, which are commonly used on our Linux VPS.


2. Connect to your VPS

From your local machine, connect via SSH:

ssh user@YOUR_VPS_IP
  • Replace user with your actual username.
  • Replace YOUR_VPS_IP with the IP address of your VPS (visible in your BoxToPlay panel).

Once logged in, you can prepare the system for Apache2.


3. Update the system

Before installing Apache2, update the package list and system packages:

sudo apt update
sudo apt upgrade

Confirm if asked. When the update is finished, you are ready to install Apache2.


4. Install Apache2

On Debian/Ubuntu, install Apache2 with:

sudo apt install apache2

Confirm installation if prompted. At the end of the process:

  • Apache2 is installed.
  • The service usually starts automatically.
  • It is configured to start when the VPS boots.

5. Check the Apache2 service status

Check that Apache2 is running correctly:

sudo systemctl status apache2

You should see active (running).

Useful commands:

  • Start Apache2 if it is stopped:
    sudo systemctl start apache2
    
  • Enable Apache2 at boot:
    sudo systemctl enable apache2
    

6. Test access to Apache2

6.1. From your browser

On your computer, open a browser and type your VPS IP in the address bar:

http://YOUR_VPS_IP

If everything is working, you should see the default Apache2 welcome page.

6.2. From the VPS (command line)

You can also test locally on the VPS:

curl http://localhost

You should see the HTML code of the default page.


7. Default site files location

On Debian/Ubuntu, the default site is stored here:

  • Document root directory:
    /var/www/html
    
  • Main default file:
    /var/www/html/index.html
    

To replace the default page:

sudo nano /var/www/html/index.html

Example minimal content:

<!DOCTYPE html>
<html>
  <head>
    <meta charset="utf-8">
    <title>My site on BoxToPlay</title>
  </head>
  <body>
    <h1>Apache2 is running on my BoxToPlay VPS!</h1>
  </body>
</html>

Save, exit, then refresh the page in your browser.


8. Using VirtualHosts to host multiple sites

Apache2 allows you to host several websites on the same VPS using VirtualHosts.

8.1. Create a directory structure

Example for a site called mysite:

sudo mkdir -p /var/www/mysite/public_html
sudo chown -R $USER:$USER /var/www/mysite/public_html

Create an index file:

nano /var/www/mysite/public_html/index.html

With a simple content:

<!DOCTYPE html>
<html>
  <head>
    <meta charset="utf-8">
    <title>My Apache site</title>
  </head>
  <body>
    <h1>Welcome to my site hosted on BoxToPlay</h1>
  </body>
</html>

8.2. Create a site configuration file

Site configuration files are stored in:

/etc/apache2/sites-available/

Create a new file, for example mysite.conf:

sudo nano /etc/apache2/sites-available/mysite.conf

Example basic configuration (replace mysite.com with your own domain if you use one):

<VirtualHost *:80>
    ServerAdmin webmaster@localhost
    ServerName mysite.com
    ServerAlias www.mysite.com
    DocumentRoot /var/www/mysite/public_html

    ErrorLog ${APACHE_LOG_DIR}/mysite_error.log
    CustomLog ${APACHE_LOG_DIR}/mysite_access.log combined
</VirtualHost>

Save and exit the editor.

8.3. Enable the site

Enable the new site:

sudo a2ensite mysite.conf

Then reload Apache2:

sudo systemctl reload apache2

To disable the site later if needed:

sudo a2dissite mysite.conf
sudo systemctl reload apache2

9. Firewall configuration (if in use)

If you use ufw (the uncomplicated firewall), ensure HTTP traffic is allowed.

Check the status:

sudo ufw status

Allow Apache:

sudo ufw allow 'Apache'
sudo ufw reload

When you later add HTTPS, you can allow the profile:

sudo ufw allow 'Apache Full'

10. Enable useful Apache modules

Some Apache2 modules are commonly used. For example, the rewrite module for URL rewriting:

sudo a2enmod rewrite
sudo systemctl restart apache2

You can then configure rewrite rules in your site configuration or in an .htaccess file (if allowed in your configuration).


11. Reloading and restarting Apache2

After changes to configuration files, you usually need to reload or restart Apache2:

  • Reload (applies changes without interrupting current connections):
    sudo systemctl reload apache2
    
  • Restart:
    sudo systemctl restart apache2
    

12. Common troubleshooting steps

  • Apache2 fails to start after a change
    Check configuration syntax:

    sudo apache2ctl configtest
    

    Fix the errors indicated, then reload or restart Apache.

  • You see the default Apache page instead of your site

    • Confirm your site is enabled with a2ensite.
    • Check that ServerName matches the domain or address you use in the browser.
    • Make sure the default site (000-default.conf) is not overriding your configuration.

By following these steps, you have a fully functional Apache2 web server on your BoxToPlay Linux VPS, ready to host your websites and web applications. From here, you can go further with HTTPS, performance tuning, or installing server-side languages like PHP according to your needs.

Join the Discussion
🍪