Setting up a web server with Apache and Linux

On how I learned how to do it:

I’ve always had this strong desire to take charge of my own corner of the web. However, the reality is that pursuing this aspiration can often lead to hefty costs or restrictive limitations that hinder me from fully realizing my vision. Perhaps down the line, my financial situation allows for such an endeavor. In the meantime, though, I find solace in honing my skills through local practices.

Currently, I’ve managed to establish a web server within my virtual machine. This setup enables me to host a website on my personal URL, granting me complete control over its accessibility. Through extensive trial and error, I’ve come to appreciate the distinction between public and private IP addresses. While I could theoretically open port 80 to my public IP address, it’s a risky proposition as it exposes my home network to potential threats. This, obviously, is not an option.

On the flip side, there’s the private address, accessible exclusively when I’m connected to my home Wi-Fi network. Unfortunately, this confines access solely to those moments when I’m within the confines of my own space, leaving me without the capability to connect remotely. It’s at times like these that I understand the rationale behind the widespread adoption of Virtual Private Servers (VPS). In all likelihood, I’ll be exploring that avenue further in the future. But for now, I believe it’s imperative to cultivate a strong foundation by tinkering with my own virtual machine.

Thus, my current approach revolves around maintaining a private setup. This allows me to experiment extensively and develop a profound understanding of deploying APIs, servers, and web applications on my own terms.

Setting up the Linux Environment

I decided to give a few different Linux distributions a shot: Mint, CentOS, Ubuntu, Fedora, and eventually, Debian. To be honest, my excitement waned when I realized that Debian, despite all the buzz, came with a considerable load of unnecessary packages. It was a bit of a letdown. However, my journey took an intriguing turn when I stumbled upon CrunchBangPlusPlus—a distro built upon Debian’s core strengths. What’s intriguing is that this entire project is the brainchild of one individual who shares my passion for simplicity. This distro was carefully crafted, selecting packages with precision. It was a breath of fresh air, especially for someone like me who was focused on setting up a server and SSH access. Unlike my previous experiences, the distros I experimented with required manual installation. The only item missing was Git, which is fairly straightforward to add. So, I went ahead and obtained the latest version. Interestingly, it was the most recent release, based on Debian’s Bookworm.

For the setup process, I’ve been utilizing Oracle’s VirtualBox. Let me tell you, it’s like a dream come true! I had no idea such a magical tool existed until I took a Linux course on Udemy. It’s a sandbox where I can experiment and break things without a care in the world. And yes, I do break things quite a bit. I still remember my teenage years, when I caused quite a scene by messing up the only computer in the house, much to the dismay of my family. Then spending hours fixing it.

Operating within the VM VirtualBox Manager, the procedure is simple. Just click on “New,” assign a cute name, and choose the appropriate ISO file.

Then we set up this with our credentials:

I am using my own subdomain URL for the domain name. Which I provided my local IP to, so I can just use SSH with that, because I suck at remembering long numbers.

After that is all set up and installed, I make sure I set up 2 networks under settings:

Adapter one is Bridge, while adapter 2 is Host-only. The Host only will serve as the access IP and the bridge one will allow us to use the internet (installing packages and updates).

Sadly, this next part is not automated, but I took good notes of what worked about a night of tinkering.

Configure the network files:

Interfaces configuration:

 $ sudo nano /etc/network/interfaces

Once we open the config file, we add the 2 adapters like this:

# The loopback network interface
auto lo
iface lo inet loopback

# The primary network interface
allow-hotplug enp0s8
iface enp0s8 inet dhcp

# The secondary network interface
allow-hotplug enp0s3
iface enp0s3 inet dhcp

After registering the adapters, we need to configure them:

DHCP access

$ sudo nano enp0s3.conf
iface enp0s3 inet dhcp


$ sudo nano enp0s8.conf

iface enp0s8 inet static

Restart the network:

$ sudo systemctl restart networking

To now access the static IP, just test on the browser or on another terminal:

$ ssh user@ip 

To test that you have access to the internet, write the following:

$ ping

If it all works, great! Now the final step.

Setting up the webpage

If you are using #!++, you will have everything set up for this. Hence, this is the easiest distro I’ve found so far.

All web files are stored in

$ cd /var/www/html

The easiest way to use this is via commands. My favorite way is Git. But let’s say you have the files on the documents already. My web files are under:

$ cd ~/web/playground

So I will copy the files from there to my web folder:

$ sudo cp ~/web/playground/. /var/www/html

Load now the page on your browser and tada! Your own hosted webpage, though local. Unless you use your own IP, that’s up to you.

Leave a Reply

Your email address will not be published. Required fields are marked *