How to host a website for free from your PC or laptop

If you’re planning to start a website but don’t want to pay recurring monthly or yearly hosting fees, you can use any old laptop or desktop computer to host a website for free. It’s a great way to use your old system instead of throwing it away.

In this guide, we will be installing and configuring services on our 10 year old laptop to host a WordPress, Joomla, or custom HTML or PHP website with a free SSL certificate.

Things you will need to host a website

Here are the prerequisites to host a website for free from home with just your computer:

  • An old laptop or PC running Ubuntu Server.
  • A registered domain name for your website
  • Ethernet cable to connect the 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, run the following command to update the list of packages and upgrade existing packages. We recommend that you enable SSH and access the server via Terminal or PuTTY on your macOS or Linux computer.

sudo apt update && Sudo apt upgrade y

It may take some time 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 works with PHP to host dynamic websites, including WordPress sites. Once the update is complete, run the following command to install the Apache server.

sudo apt install apache2

When you see a prompt, press Yes then press the Walk in key to continue the installation. You can check the status by running the following command.

systemctl status apache2

It should show the active (running) state. To check, you can visit your laptop’s IP address or localhost.

Step 3: Install MySQL Server

MySQL is a database management system (DBMS) that helps organize and provide access to the database to store information. To install the MySQL server, use the following command.

sudo apt install MariaDB-server MariaDB-client

Hurry Yes then the Walk in button to confirm and proceed with the installation.

Next, secure the MySQL installation by running the following command.

sudo mysql_secure_installation

Set root password? Hurry Yes and hit it Walk in key. Enter a secure password and keep it safe.

Delete anonymous users? Press Y then press Walk in key.

Forbid remote root login? Press Y then the Walk in key.

Delete the test database and access it. press the Yes key followed by Walk in Press the key.

Reload privilege tables now? press the Yes key and then Walk in.

Step 4: Install PHP

PHP is needed to process code to display dynamic content, run scripts, connect to MySQL database and display processed content on web browser. To install PHP, run the following command.

sudo apt install PHP PHP-MySQL

press the Yes button to confirm and proceed with the installation. Create a test.php file using the following command to confirm installation.

sudo nano /var/www/html/test.php

Now paste the following code into the Nano editor.


Hurry CTRL+X followed by Yes and the Walk in button to save changes. Now visit your laptop IP address with /test.php in the URL. This should load the PHP information page, indicating that PHP is installed and running.

Step 5: Create a MySQL database and user

We need to create a database and a user account with access to the database with full privileges. The commands are as follows:

sudo MySQL u root -p

Type the password (the one you created when securing the MySQL installation) and press the key Walk in key. Then run the following commands in the given order to create a database and a user with full access to the database.

CREATE USER ravi@localhost IDENTIFIED BY YourPassword;
GRANT ALL ON mysite.* TO ravi@localhost IDENTIFIED BY YourPassword;

This will create a database named “mysite” with user “ravi” having access to the database. Of course, you can use any name you like.

You can now host a custom HTML, PHP-based website or host CMS-based sites, such as WordPress, PrestaShop, Joomla, etc. However, we will be setting up and hosting a WordPress website on our old laptop for this tutorial.

Step 6: Download and configure WordPress

Navigate to the path /var/www/html and download the latest WordPress package.

cd /var/www/html/
sudo wget "">https:

Extract the package contents.

Sudo tar xf latest.tar.gz

This will extract the wordpress directory to /var/www/html location. You can display the directory using the ls ordered. Then we will grant permission to www-data:www-data using the following command.

sudo chown -R www-data:www-data /var/www/html/wordpress

Once done, you can visit your laptop’s IP address followed by /wordpress. Enter the Name of the data base, username and Password we created in step 4. Let Database host and Array prefix by default. Click on Submit.

Now click on Run the installation.

Enter the 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 access the WordPress site at http://ip-address/wordpress (Replace the IP adress field with your computer’s IP address).

Next, we need to add the domain name and enable SSL for the HTTPS connection. For this, we will use the Cloudflared secure 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 a Cloudflared tunnel and enable HTTPS

Follow the instructions and use the commands below 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 displayed URL and open it in a web browser to authorize the domain.

Once successfully authorized, create a Cloudflared tunnel called “mysite”. You can give it any name, but remember this name.

Cloudflared tunnel create mysite

Copy the credential file path (JSON file path) and the tunnel ID. Keep them safe.

Now create a configuration file using the command below.

Sudo nano ~/.cloudflared/config.yml

Then paste the following code into it. Be sure to replace the tunnel ID and credentials-file (JSON file path).

tunnel: a2efc6dg1-2c75-45f8-b529d3ee
credentials-file: /home/pi/.cloudflared/ a2efc6dg1-2c75-45f8-b529d3ee.json
- hostname:
service: http:
- service: http_status:404

Hurry CTRL+X followed by Yes and knock Walk in to save changes.

Now create a DNS entry for the hostname. You can host your WordPress site on the main domain or the subdomain depending on your needs. For this tutorial, we will create a subdomain DNS entry to host our WordPress site on the old laptop.

cloudflared tunnel route DNS <Tunnel Name> <>

Here is an example :

cloudflared tunnel route DNS mysite

Once the entry is successfully created, you can start the tunnel by running the following command.

Cloudflared tunnel run mysite

You can open the web browser and visit the hostname ( in this case). You should be able to access the WordPress site. However, you can see that the CSS is broken and the HTTPS is disabled.

To resolve this issue, log in to to Settings > General Settingsand update the WordPress Address (URL) and Site Address (URL) fields to Where depending on your setup.

Next, log in to Cloudflare, go to SSL/TLS > Overview in the left pane and choose “Flexible” or “Full” for the domain you added.

Once done, visit the URL and navigate to your website. Your site should now load completely with an HTTPS connection.

Is Free DIY Hosting Worth It?

If you are just starting to build an online service, portal or business, a local DIY server on an old PC or laptop can help. You can use it to showcase your projects to clients or users and host a fully functional website.

Although hosting is free and secure, remember that you will have to pay for your computer’s electricity consumption, which will vary depending on its efficiency. Typically, it’s between 30 and 65 W/hour at full load for laptops, but desktops use a lot more power. A cheaper and more power efficient option would be to use a Raspberry Pi to host your site, as it runs on a 15W power supply.