If you plan to start a website but don’t want to pay recurring monthly or annual hosting fees, you can host a website for free using any old laptop or desktop computer. This is a great way to take advantage of an old system instead of throwing it away.
In this guide, we’ll install and set up the service on our 10-year-old laptop to host a WordPress, Joomla, or custom HTML or PHP based website with a free SSL certificate.
Things you need to host your website
Here are the prerequisites for hosting a website for free at home using only your computer:
- An old laptop or PC running Ubuntu Server.
- The registered domain name of your website
- Ethernet cable for connecting a laptop or PC to the router for a reliable and fast connection
Step 1: Update and upgrade packages
After installing Ubuntu Server on your computer, execute the following commands to update the package list and upgrade existing packages. We recommend that you enable SSH on your macOS or Linux PC and access the server via Terminal or PuTTY.
sudo apt update && Sudo apt upgrade –y
This may take a while to complete. So, sit back and relax until the process is complete.
Step 2: Install Apache
Apache is a popular open source web server that is used with PHP to host dynamic websites, including WordPress sites. After the update is complete, execute the following command to install the Apache server.
sudo apt install apache2
When you see the prompt, press Yes then click Enter key to continue the installation. You can check the status by running the following command.
systemctl status apache2
It should show active (running) status. To verify, you can access the laptop’s IP or localhost.
Step 3: Install MySQL Server
MySQL is a database management system (DBMS) that helps organize and provide access to databases to store information. To install MySQL server, use the following command.
sudo apt install MariaDB-server MariaDB-client
according to Yes Then Enter key to confirm and continue the installation.
Next, secure the MySQL installation by running the following command.
Set root password? according to Yes and hit Enter key. Enter a secure password and keep it safe.
Remove anonymous users? Press Y, then press Enter key.
Disallow remote root login? Press Y Then Enter key.
Delete the test database and access it. Press Yes key followed by Enter button.
Reload the permission table now? Press Yes key, then Enter.
Step 4: Install PHP
PHP needs to process code to display dynamic content, run scripts, connect to a MySQL database, and display the processed content on a Web browser. To install PHP, run the following command.
sudo apt install PHP PHP-MySQL
Press Yes key to confirm and continue the installation. Create a test.php file with the following command to confirm the installation.
sudo nano /var/www/html/test.php
Now paste the following code into the Nano editor.
according to CTRL+X Followed by Yes and Enter key to save the changes. Now, access your laptop’s IP /test.php in the URL. This should load the PHP info page, indicating that PHP is installed and running.
Step 5: Create MySQL Database and User
We need to create a database and user account to access the database with all permissions. The command is as follows:
sudo MySQL –u root -p
Enter the password (the one you created when you secured your MySQL installation) and press Enter key. Then execute the following commands in the given order to create a database and a user with full access to the database.
CREATE DATABASE mysite;
CREATE USER ‘ravi’@’localhost’ IDENTIFIED BY ‘YourPassword’;
GRANT ALL ON mysite.* TO ‘ravi’@’localhost’ IDENTIFIED BY ‘YourPassword’;
This will create a database called “mysite” that can be accessed by user “ravi”. Of course, you can use any name you like.
You can now host custom HTML, PHP-based websites, or host CMS-based websites such as WordPress, PrestaShop, Joomla, and more. However, we will be setting up and hosting the WordPress site on an old laptop for this tutorial.
Step 6: Download and Set Up WordPress
Navigate to the /var/www/html path and download the latest WordPress package.
sudo wget "https://wordpress.org/latest.tar.gz">https:
Extract package contents.
Sudo tar xf latest.tar.gz
this will extract WordPress directory in /var/www/html Place.You can view the directory with the following command ls Order.Next, we will grant permissions www-data: www-data Use the following commands.
sudo chown -R www-data:www-data /var/www/html/wordpress
Once done, you can access your laptop’s IP, then /wordpress. input Name database, username and password We created in step 4.leave database host and table prefix default.click submit.
Now, click run the install.
Enter a site title.Also, create a new username and password For the WordPress backend (wp-admin), then click Install WordPress. This will install WordPress, after which you can visit the WordPress site: http://IP-address/wordpress (replace IP address field with your computer’s IP).
Next, we need to add the domain name and enable SSL for HTTPS connections. For this, we will use the secure Cloudflared Tunnel.
Step 7: Download and install the Cloudflared service
Sign up and add your domain to your Cloudflare account to get started. After adding the domain, run the following commands to download and install the Cloudflared service on your old laptop or PC-based web server.
sudo wget https:
sudo dpkg –I cloudflared-linux-amd64.deb
Step 8: Create Cloudflared Tunnel and Enable HTTPS
Follow the instructions and use the following commands to create a Cloudflared tunnel and enable a secure connection to your website.
Log in and authorize the domain you added to Cloudflare.
Cloudflared tunnel login
Copy the URL shown and open it in a web browser to authorize the domain.
After successful authorization, create a Cloudflared tunnel named “mysite”. You can name it, but keep that in mind.
Cloudflared tunnel create mysite
Copy the credential file path (JSON file path) and tunnel ID. keep them safe.
Now, create a configuration file with the following command.
Sudo nano ~/.cloudflared/config.yml
Next, paste the following code into it.Make sure to replace the tunnel ID and credential file (JSON file path).
credentials-file: /home/pi/.cloudflared/ a2efc6dg1-2c75-45f8-b529d3ee.json
- hostname: YourDomain.com
- service: http_status:404
according to CTRL+X Followed by Yes and hit Enter save Changes.
Now create a DNS entry for the hostname. You can host your WordPress site on the main domain or on a subdomain according to your needs. For this tutorial, we’ll create a subdomain DNS entry to host our WordPress site on an old laptop.
cloudflared tunnel route DNS <Tunnel Name> <YourDomain.com>
Here is an example:
cloudflared tunnel route DNS mysite mysite.smartghar.org
After the entry is successfully created, you can start the tunnel by running the following command.
Cloudflared tunnel run mysite
You can open a web browser and visit the hostname (mysite.smartghar.org in this example). You should be able to access the WordPress site. However, you may see broken CSS and HTTPS disabled.
To fix this issue, please log in https://yoursite.com/wp-admingo Settings > General Settingsand update the WordPress Address (URL) and Site Address (URL) fields to your domain.com or YourDomainName.com/wordpress according to your configuration.
Then, log into Cloudflare and go to SSL/TLS > Overview From the left pane, then select Flexible or Full for the domain you added.
Once done, go to the URL and visit your website. Your site should now be fully loaded over the HTTPS connection.
Is free DIY hosting worth it?
If you’re just starting out building an online service, portal or business, a local DIY server on an old PC or laptop can help. You can use it to present your project to clients or users and host a fully functional website.
Although hosting is free and safe, keep in mind that you have to pay for your computer’s power usage, which will vary based on its efficiency. Typically, laptops draw between 30-65W/hour at full load, but desktops consume more power. A cheaper and more energy efficient option is to use a Raspberry Pi to host your site as it runs on a 15W power supply.