How to Install and Set Up NginX Proxy Manager & Apache Virtual Hosts Web Servers on Debian Linux.


1. A Debian 12 or higher server or Proxmox CT for NginX proxy server.

2. A Debian 12 or higher server or Proxmox CT for each Apache2 servers.

3. Root access to the servers, via the terminal.

4. Update system and install dependencies.

Before starting, it’s important to have the systems up-to-date. So, run the following commands on your servers to update them:

sudo apt update && sudo apt upgrade -y

After the system is updated, you need to install the dependencies:

sudo apt install gnupg2 curl -y

Part 1: Setup NginX Proxy Manager to control Domains

First go to this site:

Now, follow the the instructions, to install NginX Proxy Manager on your first server. You will see this link, copy and paste it into your server terminal.

sh -c "$(wget --no-cache -qO-" -s --app nginx-proxy-manager

Once done, enter into a web browser:

http://ip-of-your-server :81 , to run the control panel.

Initial login is admin@example.comPassword is changeme. You can change this once logged in.

Part 2: Installing and configuring Apache

Now, we will proceed with the Apache installation and configuration it to run on port 8080. First of all, you need to install it on another server with this command:

sudo apt install apache2 -y

Once it’s installed, you need to edit the port from 80 to 8080 in the ports.conf and the 000-default.conf files:

sudo nano /etc/apache2/ports.conf

sudo nano /etc/apache2/sites-enabled/000-default.conf

sudo systemctl restart apache2

Once it’s restarted, you should see the default page on the following link in any web browser:

http://ip-of-your-server :8080

Part 3: Setup Virtual Hosts on the Apache Web Server

Step 1: Create the Directory Structure

By default, the top-level directory for apache is /var/www and we will be setting them to the individual directories under the /var/www directory for each site/domain.

The default site will be: (Replace with your own domain name).


We modify our permissions a little bit to ensure that read & write access is permitted to the general web directory and all of the files and folders it contains so that pages can be served correctly:

$ sudo chown -R $USER:$USER /var/www/

$ sudo chmod -R 777 /var/www/

Step 2: Create the Site Directory

For each of our sites, we are going to make site directories –

$ sudo mkdir -p /var/www/

Step 3: Grant Permissions

Now, we have the directory structure of our site/domain, but they are created and owned by our root user.

If we want our normal user to be able to modify files in our web directories, then we have to change the ownership to other normal users.

$ sudo chown -R $USER:$USER /var/www/

Your web server should now have the permissions it needs to serve the site, and your user should be able to create content within the necessary folders.

Step 4: Create Demo Pages for Each Virtual Host

First, we create an index.html file in our editor, and paste in this basic HTML script which indicates the site it is connected to.

$ sudo nano /var/www/

                <title>My new website</title>

                <h1>Welcome to The Virtual Host</h1>

Save and close the index.html file.

Step 5: Create New Virtual Host Files

Virtual host files are the configuration files that specify the virtual host and instructs the Apache Server to respond to various domain requests.

$ sudo nano /etc/apache2/sites-available/

Paste this in the file:

<VirtualHost *:8080>
        DocumentRoot /var/www/
        ErrorLog ${APACHE_LOG_DIR}/error.log
        CustomLog ${APACHE_LOG_DIR}/access.log combined

Save & close this Virtual Host file.

Step 6: Enable the New Virtual Host Files

Now that we have already created our virtual host files, we must enable these sites. Apache has its own tools that allow us to do this.

$ sudo a2ensite

Once we have done that, we need to restart Apache to make these changes take effect:

$ sudo systemctl restart apache2

We can now test the site in our web browser, by going to:

This should now go to the new site, and you can upload your site files to it via any sftp client.