How to Host a Website for Free From Your PC or Laptop

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

In this guide, we will install and set up services on our 10-year-old laptop to host a WordPress, Joomla, or custom HTML or PHP-based website with a free SSL certificate.

4

Things You Will Need to Host a Website

Following are the pre-requisites to host a website for free from home with just your computer:

Step 1: Update and Upgrade the Packages

Afterinstalling Ubuntu Server on your computer, execute the following command to update the package list and upgrade existing packages. We recommend you enable SSH and access the server via Terminal or PuTTY on your macOS or Linux PC.

This may take a while to finish. So, sit back and relax until the process completes.

Mint Mobile SIM Protection Number Lock with SIM cards on table

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, execute the following command toinstall the Apache server.

When you see a prompt, pressYand then hit theEnterkey to continue the installation. You can check the status by running the following command.

A laptop with an Excel spreadsheet open and the Excel logo with a checkbox in front of the screen.

It should show active (running) status. To verify, you may visit the IP of your laptop or localhost.

Step 3: Install MySQL Server

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

PressYand then theEnterkey to confirm and proceed with the installation.

Open Source App Icons on a BENQ Minitor

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

Set root password?PressYand hit theEnterkey. Enter a secure password and keep it safe.

host website for free from home pc or laptop

Remove anonymous users?Press Y and then theEnterkey.

Disallow root login remotely?Press Yand then theEnterkey.

Remove the test database and access it.Press theYkey followed by theEnterkey press.

Reload privilege tables now?Press theYkey and thenEnter.

Step 4: Install PHP

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

Press theYkey to confirm and proceed with the installation. Create a test.php file using the following command to confirm the installation.

Now, paste the following code into the Nano editor.

PressCTRL+Xfollowed byYand theEnterkey to save the changes. Now, visit the IP of your laptop with/test.phpin the URL. This should load the PHP information page, indicating PHP is installed and working.

Step 5: Create a MySQL Database and User

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

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

This will create a database named “mysite” with user “ravi” having access to the database. Of course, it’s possible to 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 willset up and host a WordPress websiteon our old laptop for this tutorial.

Step 6: Download and Setup WordPress

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

Extract the package contents.

This will extract thewordpressdirectory at/var/www/htmllocation. You can view the directory using thelscommand. Next, we will grant permission towww-data:www-datausing the following command.

Once done, you can visit the IP of your laptop followed by/wordpress. Enter theDatabase Name,UsernameandPasswordwe created in Step 4. LeaveDatabase HostandTable Prefixto default. Click onSubmit.

Now, click onRun the installation.

Enter the Site Title. Also, create a newUsernameandPasswordfor the WordPress backend (wp-admin), and then clickInstall WordPress. This will install WordPress, after which you may access the WordPress site athttp://IP-Address/wordpress(Replace theIP-Addressfield with your computer’s IP).

Next, we need to add the domain name and enable SSL for the HTTPS connection. For this, we are going to use the secure Cloudflared Tunnel.

Step 7: Download and Install Cloudflared Service

Sign up and add your domain to yourCloudflare accountto 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.

Step 8: Create 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.

Copy the URL displayed and open it in a web browser to authorize the domain.

Once authorized successfully, create a Cloudflared tunnel called “mysite”. You may name it anything but remember that name.

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

Now, create a configuration file using the command below.

Next, paste the following code into it. Make sure to replace the tunnel ID andcredentials-file(JSON file path).

PressCTRL+Xfollowed byYand hitEnterto save the changes.

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

Here’s an example:

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

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

To fix this, log in tohttps://yoursite.com/wp-admin, go toSettings > General Settings, and update the WordPress Address (URL) and Site Address (URL) fields toYourDomainName.comorYourDomainName.com/wordpressas per your configuration.

Then, log in to Cloudflare, head over toSSL/TLS > Overviewfrom the left pane, and choose either “Flexible” or “Full” for the domain you added.

Once done, visit the URL and access your website. Your site should now load fully with an HTTPS connection.

Is Free DIY Hosting Worth It?

If you’re just getting started with building an online service, portal, or business, a local DIY server on an old PC or laptop can help you. You can use it to showcase your projects to clients or users and host a fully functional website.

Although the hosting is free and secure, remember that you will have to pay for your computer’s electricity usage, which will vary based on its efficiency. Typically, it’s between 30-65W/hour at full load for laptops, but desktop PCs will consume much 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.

Use the free Cloudflare Tunnel service to host a secure WordPress site on your Raspberry Pi.

Tor spoiled me forever.

When your rival has to bail out your assistant.

Goodbye sending links via other apps.

Freeing up vital memory on Windows only takes a moment, and your computer will feel much faster once you’re done.

Not all true crime is about hacking, slashing, and gore.

Technology Explained

PC & Mobile