Creating Your Own Apache Server

1. Overview

Apache is an open-source web server available for Linux servers free of charge.

This tutorial guides you through setting up your Apache server.

What You'll Learn

What You'll Need

2. Installing Ubuntu Server

To install Ubuntu Server, you'll need a USB stick for the installation.

Install Ubuntu Server from the following links based on your computer type (requires Etcher installed):

Boot from the USB stick and follow the instructions to install Ubuntu server on your computer.

3. Installing Apache

To install Apache, install the latest meta-package apache2 by running:

sudo apt update
sudo apt install apache2

After running the command, all required packages are installed. Test it by entering your server's IP address in the web browser.

Apache test page

If you see the page above, Apache is successfully installed! Let's move on.

4. Installing Samba

Install Samba to modify files from your computer.

To install Samba, run the following commands:

sudo apt update
sudo apt install samba

Add a user for Samba:

sudo adduser samba_user

And then:

sudo smbpasswd -a samba_user

Set permissions for the user:

sudo chown -R samba_user:samba_user /var/www/html
sudo chmod -R 755 /var/www/html

Modify the Samba configuration file:

sudo nano /etc/samba/smb.conf

Add the following code snippet to the end of the file:

   comment = HTML Directory
   path = /var/www/html
   browseable = yes
   read only = no
   guest ok = yes
   create mask = 0777
   directory mask = 0777
   valid users = samba_user

Save and exit by pressing CTRL+O, Enter, and then CTRL+X.

Execute the following command:

sudo systemctl restart smbd

You should now be able to go to your files on your computer by writing: \\your_ubuntu_server_ip\html. Connect with the user "samba_user" and the password you set earlier.

5. Make your website publicly accessible

You have to port forward the ip address of your server and it's port 80 and 443.

You can follow this guide to set up port forward:

We will now set up the DDNS to be able to access our website with a domain name (ex:

No-IP is a popular DDNS service that provides a free solution for dynamic IP users.

Step 1: Create a No-IP Account and Add a Hostname

  1. Go to the No-IP website.
  2. Sign up for a new account or log in if you already have one.
  3. After logging in, click on "Dynamic DNS" in the navigation menu.
  4. Click on "Add a Hostname."
  5. Choose a hostname that you want to associate with your dynamic IP address and select a domain from the dropdown menu.
  6. Select the free plan and click on "Add Hostname."

Step 2: Install the No-IP Dynamic Update Client (DUC) on Ubuntu

Now, let's install the No-IP DUC on your Ubuntu server to keep your dynamic IP address updated with No-IP's servers.

  1. Open a terminal on your Ubuntu server.
  2. Download the No-IP DUC:
    sudo wget
  4. Extract the downloaded files:
    sudo tar xf noip-duc-linux.tar.gz
  6. Navigate to the extracted directory:
    cd noip-2.1.9-1

    Note: The version number may vary based on the current release.

  8. Install the No-IP DUC:
    sudo make install
  10. During the installation, you'll be prompted to enter your No-IP username and password. Provide the information associated with your No-IP account.

Step 3: Configure the No-IP DUC

  1. Start the No-IP DUC:
    sudo /usr/local/bin/noip2

    This will run the No-IP DUC in the foreground. You can stop it by pressing Ctrl+C.

  3. To make the No-IP DUC run at system startup, create a systemd service:
    sudo nano /etc/systemd/system/noip2.service
  5. Add the following content to the file:
    Description=No-IP Dynamic Update Client

    Save and close the file.

  7. Enable and start the No-IP DUC service:
    sudo systemctl enable noip2.service
    sudo systemctl start noip2.service

Now, your Ubuntu server is configured to use No-IP DDNS. The No-IP DUC will automatically update your hostname with the current dynamic IP address. You can access your server using the No-IP hostname you created earlier.

6. Make Your Website Secure

Secure your website with Certbot.

Install snapd with the following command:

sudo apt install snapd

Install Certbot:

sudo snap install --classic certbot

Create a symbolic link for Certbot:

sudo ln -s /snap/bin/certbot /usr/bin/certbot

Get a certificate and edit your Apache configuration for HTTPS:

sudo certbot --apache

Test automatic renewal:

sudo certbot renew --dry-run

7. Customize Webpages

Modify your HTML, CSS, and Javascript files using the Samba share. The changes will be displayed on your webserver!