Skip to content

suhaasd/multisite-static-server

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

13 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Multisite Static Server

A simple Apache-based setup for hosting multiple static websites on a single Ubuntu server using virtual hosts.

📋 Prerequisites

  • Ubuntu server (20.04 or later recommended)
  • Root or sudo access
  • Basic familiarity with terminal commands

🚀 Installation

Step 1: Install Required Packages

First, update your package list and install Apache2 and Git:

sudo apt update
sudo apt install -y apache2 git net-tools

Verify Apache2 is running:

sudo systemctl status apache2

Check your server's IP address:

ifconfig

Step 2: Clone the Repository

Clone this repository to your local machine:

git clone https://github.com/suhaasd/multisite-static-server.git

Step 3: Deploy the Sites

Copy the sites to the Apache web root with different names:

cd multisite-static-server
sudo cp -rf site-1 /var/www/html/
sudo cp -rf site-2 /var/www/html/

Step 4: Configure Virtual Hosts

Edit the Apache default configuration file:

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

Replace the contents with the following configuration:

<VirtualHost *:80>
    ServerName www.site-1.local
    ServerAlias site-1.local
    DocumentRoot /var/www/html/site-1

    ErrorLog ${APACHE_LOG_DIR}/error. log
    CustomLog ${APACHE_LOG_DIR}/access.log combined
</VirtualHost>

<VirtualHost *:80>
    ServerName www.site-2.local
    ServerAlias site-2.local
    DocumentRoot /var/www/html/site-2

    ErrorLog ${APACHE_LOG_DIR}/error.log
    CustomLog ${APACHE_LOG_DIR}/access. log combined
</VirtualHost>

Save and exit: Press CTRL + O, then ENTER to save, and CTRL + X to exit nano.

Step 5: Configure Hosts File

Edit your hosts file to map domain names to your server's IP:

sudo nano /etc/hosts

Add the following lines (replace YOUR_SERVER_IP with your actual IP from Step 1):

YOUR_SERVER_IP    site-1.local www.site-1.local
YOUR_SERVER_IP    site-2.local www.site-2.local

Example:

192.168.1.100    site-1.local www.site-1.local
192.168.1.100    site-2.local www.site-2.local

Save and exit: Press CTRL + O, then ENTER to save, and CTRL + X to exit nano.

Step 6: Restart Apache

Apply the configuration changes by restarting Apache:

sudo systemctl restart apache2

Verify Apache restarted successfully:

sudo systemctl status apache2

🌐 Access Your Sites

Open your web browser and navigate to:

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published