We all know how complicated and frustrating it can get when it comes to hosting sites on a local machine. Today, I am going to share how I hosted sites from my Windows PC. You can do it fairly easily on Mac or Linux, having tons of resources on the internet about it. Hopefully this article will help you make it easier for the Windows operating system.
I previously shared my experience with a similar topic on this site where I tried to make my sites created with Local WP software, faster. You can check that article here.
Why Did We Try This?
At our office, we are building new apps and working on various projects all the time. We used to get subscription of VPS servers for them. The cost gets higher as we start working on more stuff and more servers are needed to be deployed. So, we needed a solution that will be:
- Cost effective
- Easy to maintain
- Easily scalable
- Easy to use
My old gaming PC is not getting enough use, although it is has good resources like- Intel Core-i7 processor, 32GB RAM, 500GB SSD storage. While we use the computer for running apps that require Windows OS, we can make use of the hardware very easily.
Instead of using VPS, we can create virtual machines on the PC fairly easily. Our office also have backup power so we have protection against power losses and keep the machine running 24/7. Plus, as we are going to use virtual machine (VM), we can still use the computer as a regular computer.
About CloudPanel
We are going to use CloudPanel on our server. CloudPanel is a free software to configure and manage a server with an obsessive focus on simplicity. You can use CloudPanel to run static websites, PHP, Node.js and, Python applications.
CloudPanel uses ultra-fast lightweight components for maximum performance. The technology stack is built with NGINX, PHP-FPM, Redis, Node.js, and more. You can learn more about CloudPanel and how awesome it is visiting their website at cloudpanel.io.
Things We Will Need
- A decent computer/laptop that you can possibly run 24/7. It should have enough RAM (4GB+), fast storage (50GB+) and CPU power (2+ cores) to run a virtual machine (VM). The more the better but you should keep enough resource for your Windows OS as well. Additionally, you will need to make sure your computer hardware supports virtualization as well. Sometimes it needs to be turned on from your computer’s BIOS setting.
- Virtual Machine software for running the virtual machine on your computer. I am using VMware Workstation Pro as I already have a license key.
- To keep using the server without changing DNS settings every time, you should have a Static IP Address provided by your internet service provider. If you are not sure, ask your ISP if you already have it. Incase you don’t have a Static IP, you may get a good router that supports DDNS (Dynamic DNS). That can take care of the IP changes but it is always best to have a Static IP Address.
- Ubuntu 22.04 ISO file for installing Ubuntu on the VM. You can download the ISO following this link. Remember, we need the 22.04 version for installing CloudPanel.
The Build Process
- Install VMware on your computer. You can download the software from the official website.
- Setup a Virtual Machine. You should give enough resource to it so you can use the VM for a long time without any issue. It is best to give it more than 4GB RAM, 50GB or more storage space, at least 2 Processors. I assigned 4 Processors, 8GB RAM and 60GB storage on mine.
- Set the network mode to ‘Bridge’. This will make the VM act like any other client on your network.
- Install Ubuntu 22.04 on the VM. Once installation is done, run the following command using terminal or logging in to your VM via SSH using the username and password you used during Ubuntu installation.
apt update && apt -y upgrade && apt -y install curl wget sudo
Code language: Bash (bash)
- Install CloudPanel using the code below. this process can take a while, depending on your assigned hardware and internet connection speed.
curl -sS https://installer.cloudpanel.io/ce/v2/install.sh -o install.sh; \
echo "85762db0edc00ce19a2cd5496d1627903e6198ad850bbbdefb2ceaa46bd20cbd install.sh" | \
sha256sum -c && sudo bash install.sh
Code language: Bash (bash)
The above code will install CloudPanel with MySQL 8.0 as the database engine. If you wish to choose MariaDB, you can check the CloudPanel documentation for more instruction.
- Once installation is done, you will see a confirmation message along with a link for accessing CloudPanel dashboard. That address is usually your public IP address plus port 8443. Example: https://123.89.46.72:8443. If you try visiting the URL, it most probably will not load because, we did not set up port forwarding.
- As we are using a VM, we will need to configure port forwarding on our router so when we visit that link, it is pointed to the VM’s IP address. You will need to forward some ports to the IP address of your VM. Ports are 80 (HTTP), 443 (HTTPS), 8433 (CloudPanel), 21 (FTP), 22 (SFTP). This setting can vary depending on your router. On my Asus router its like the following image. For the Internal IP Address you should choose the IP address you see assigned for the VM by the router. It would be a good idea to turn on MAC and IP Address binding so the router always assign the same IP to the VM even after restarts. Once this is done, you should be able to visit the CloudPanel dashboard URL you were given in the confirmation message.
- Ignore the “Your connection is not private” warning and proceed to the dashboard. We will fix this issue on the next step.
Image from CloudPanel Docs Website
- Register or configure an existing domain so it points to your Static IP Address or the DDNS domain. Once it is done, set the domain for CloudPanel from the settings page inside the CloudPanel dashboard shown below. This will also issue Free Let’s Encrypt Certificate so we will no longer see the warning message and our URL for accessing CloudPanel will no longer require using the IP Address.
Image from CloudPanel Docs Website
That’s it! Enjoy CloudPanel and your own hosting setup right on your windows PC! This not only helps accessing sites locally (LAN) but also serves the hosted website and applications over the internet. So, you can treat this setup as any other hosting.
However, this does not mean that you can leave your current hosting subscriptions and switch to this. Typical hosting setups are more secure and managed by professionals to deploy applications with priority. Our setup is mainly for local development with the added bonus of wide accessibility. We don’t plan to use this setup for any production sites.
1 comment
technotes
Great article! I use virtualbox.
happy travels