Linux

How to Build a Linux Web Server With an Old Computer

Christian Cawley Updated 10-12-2019

Interested in building a home web server? The simplest way is to install Linux on a spare computer.  Thanks to the simplicity of Linux, this is straightforward, giving you an affordable way to host a website or blog.

Advertisement

Here’s how to set up a Linux web server.

How to Make Your Own Web Server With Linux

To build a Linux web server that can be run from home, you’ll need the hardware and an operating system. In addition, web server software should be installed, and a means of accessing the server from the internet se up.

We can break that down into four easy steps you can follow to build your own Linux webserver.

  1. Find an old/unwanted computer
  2. Install a Linux operating system
  3. Set up the application web server software (Apache, PHP, MySQL)
  4. Reach the server from the internet

Let’s get started.

1. Find an Old Computer for Your Linux Web Server

Before choosing a computer to use as a web server, you’ll need to know the minimum requirements of the OS. While Ubuntu is popular, it isn’t lightweight enough. Instead, Lubuntu 19.04 is a stronger option. This is a lighter alternative to Ubuntu, built on the same code.

Download: Lubuntu 19.04

Lubuntu System Requirements

Lubuntu 19.04 has a minimum requirement of:

  • 512MHz dual core processor or better (1GHz recommended, as opposed to 2GHz for Ubuntu)
  • 4GB system memory
  • 25GB of free hard drive space
  • Choice of 32-bit (for older PCs) and 64-bit versions

You might have a suitable old PC at the back of a drawer or picked one up at a thrift store. It’s worth noting that you can install a Linux web server on a Raspberry Pi How to Host Your Own Website on a Raspberry Pi Need to run a website but can't afford the hosting costs? Build your own LAMP-capable web server with a low-powered Raspberry Pi. Read More . This little computer costs under $30 and is a smart option if you run into trouble with old hardware.

Also, don’t be limited to old Windows PCs. Apple Macs and MacBooks from the pre-2006 era with PowerPC processors can run Linux.

Like Ubuntu, Lubuntu supports a wide variety of video cards, hard drives, and other hardware. To check if the distro will work on your chosen hardware, run the Live CD.

If you plan on running the server 24/7, make sure it is in a well-ventilated area. It is better to place it in an air-conditioned room during the summer when heat will be your server’s enemy.

2. Install a Linux Operating System

Set up a Linux web server with Lubuntu

Installing Lubuntu is straightforward. Simply grab the ISO file and write it to DVD or a USB flash device, to begin.

Download: Lubuntu

These disk images have the latest versions of software, so only a small upgrade should be required after installation. Use the 64-bit version if your computer supports it or the 32-bit version otherwise.

When you’re ready, insert the installation media in your computer and reboot. If you need to change the BIOS settings to boot from the optical drive or USB, then do so. In some cases, a boot media selection menu can be opened.

With the installation media booted, select Install Lubuntu. When prompted, select Download updates while installing and Install 3rd Party Software and then Erase and Use the Entire Disk.

Note that this will erase any other operating systems you have on this computer. Follow through the other options per your desired settings. Encrypting your home folder isn’t wise for a web server project. Reboot after the installation is complete.

Upon reboot, check for updates. Go to System > Administration > Update Manager > Install Updates. You may need to reboot after installing any updates it has found.

3. Install Linux Web Server Software

While alteratives are available, most websites run on a combination of Apache, MySQL, and PHP (known as LAMP). This is similar to what we recommended installing on Windows How to Set Up Your Own WAMP Server WAMP server is the easiest and most pain-free way to set up Apache, MySQL, and PHP on Windows for hosting a website. Read More .

All three tools can be installed via the Software Center. Launch this via System > Administration > Synaptic Package Manager. This is where we install the software we need.

Search for and install the following package names, each of which will include various prerequisites: apache2, php5, php5-mysql, and mysql-server. Apply the changes to install the packages.

The packages will download and install shortly. The installer will prompt you for the MySQL “root” password. No reboot is necessary.

You can alternatively install these tools in the command line. Open a Terminal then:

sudo apt install lamp-server^ -y

Set up a Linux web server on an old PC

Test Your Web Server!

You can test the installation by opening the Firefox browser on your server and heading to the URL http://127.0.0.1/. Alternatively, input http://localhost/.

You should see an “It works!” message meaning that your web server is running! Both Apache and MySQL will be running in the background and will start on bootup. With the web server now working you can edit the files in /var/www. Simply refresh the browser to see the changes live on your website.

Finding the Server’s Local IP Address

While the server is functional, it needs to be visible to the outside world. As such, it is important to keep the server up to date with all regular patches.

First, find the server’s local IP address and set it to something you will later be able to reference. You’ll find the current IP address—assigned by your router—in the Network Information box.

Find this by clicking on your network connection, then selecting Connection Information. This will pop up a box with your current IP address, network adapter card, broadcast address, gateway, and DNS server. Make a note of the IP address.

Next, edit your connection information to give you a static IP address on your local network. Right click again, but this time go to Edit Connections. Select the appropriate adapter name (e.g. eth1) and edit those settings.

Select the IPv4 tab and switch the Method to Manual. Click Add then enter the information from your connection settings. Note, however, the IP address will need to be entered differently. Retain the first three octets (the numbers between the dots) but change the last to a high number under 254.

It is important that the manually assigned IP address is not already in use on your network. If you are unsure, pick a high IP address like 250. This will be your static, local IP address.

Sharing the Web Folder

Several options are available to access and upload files onto your server. To illustrate the importance of folder permissions, consider sharing the web folder as an option.

It is important to only use this method if your server is on a private network. Be certain no one can connect to it and access your shared folder.

Start by relaxing permissions on the web folder. Open a terminal by pressing Ctrl + Alt + T, then enter:

sudo chmod 777 /var/www

You will be prompted your for your password. If correct, the permissions will be updated.

Now go to the file browser and find /var/. Right click the www folder and then select Sharing options and uncheck it. For security options, you can share it with or without a password. Select Guest access to share the folder without requiring a username and password.

Now, you or anyone else will be able to access the files without a password. For this reason, sharing with a password is recommended for security purposes. Also take a moment to check Allow others to create and delete files in this folder. This allows write access from the shared directory.

To view your files, go to the network location //localhost/www.

Set up a Linux web server

It will either prompt for your password or allow you access straight to your files, depending on your security settings. These are the same files accessible in your web browser via http://localhost/ (or whatever static IP address you set).

Get Your Linux Server Online With Port Forwarding

Now you have an IP address, an important concept to understand is port forwarding. Every single person connected to the internet is behind an IP address. For most home connections (and many business connections) your computer’s IP is not actually exposed to the internet. –

So how do visitors to your website contact your server? We do this with port forwarding.

Ports on a server are like doors or windows on a house and as such have security implications. Each port will give you access to a different service running on the server. Web servers use port 80 by default.

To enable this, you’ll need to log into your router’s administrator page. Check the device’s documentation for details of this (some routers have the IP address printed on the back). Here, you should find a section called Port Forwarding, or Applications which will allow you to forward ports properly.

Forward TCP port 80 to inside your network to the static IP address you set earlier. Each router is different, so refer to your router’s operations manual on how to set this up properly.

Give Your Linux Web Server a Static Hostname

Most home routers connect to an ISP via what is called a dynamic IP What Is A Dynamic IP Address & How Do I Get One? [Technology Explained] Read More . This means the public-facing IP address for your router will change after a set period, usually a week or so.

A way around this is the fantastic DynDNS server which lets you set a DynDNS URL for your site. Thanks to a client app, whenever your public IP address changes, the URL will still point to your Linux server.

So, visitors should be able to visit your web server from the outside world by going to http://yourhostname.dyndns.org. Some ISPs will block port 80 to your router. In this case, forward something like port 8080 to port 80. This will allow you to visit your website by going to http://yourhostname.dyndns.org:8080.

You Built a Linux Web Server!

Now that your web server is set up, you can focus on programming or installing your own software!

Perhaps you’ll run blog software or host a forum or bulletin board. You might be more interested in hosting a social network like Mastodon, a portfolio, whatever. It’s up to you.

These days, you can host a website on just about anything. Here’s how to turn your Android device into a web server How to Turn an Android Device Into a Web Server Want to host a simple website without an expensive hosting plan? Here's how to host a website on your Android phone or tablet. Read More to prove it.

Explore more about: DIY Project Tutorials, Ubuntu, Web Server.

Whatsapp Pinterest

Enjoyed this article? Stay informed by joining our newsletter!

Enter your Email

Leave a Reply

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

  1. Dheeraj Verma
    November 26, 2018 at 5:52 am

    Will i need to install any antivirus to secure my websites hosted on my own server?

  2. Kevin
    September 16, 2016 at 7:02 pm

    Hey, could you explain how can we do same thing without having GUI form of linux

  3. Imix
    July 1, 2016 at 5:42 am

    Great and simple tutorial.
    Is there a part 2?

  4. anildhaked
    January 24, 2016 at 1:12 pm

    thank you so much

  5. fred
    January 13, 2015 at 5:27 am

    It's a nice thought..... but for the life of me I can't get Ubuntu installed on an asus eeebox. been at it 3 days. Searched forums where others identified the same issue and symptoms, but never a reply on any forum. Used all linux tools from a ubuntu machine to make the iso image bootable, and installed on an identical eeebox. Is there any other linux based installs which do work other than Ubuntu?

    • Martin Dimmock
      May 29, 2015 at 6:00 pm

      Well, this is embarrassing but, I had the same problem, which took me 3 days to work out. I was trying to install a 64 bit version of Ubuntu on a 32 bit machine. A real face-palm moment that one! In my defence I had the .iso on a computer magazine coverdisk - they only offered the 64 bit and didn't really make it clear, PLUS I'm completely new to Linux. Still feel daft though.

    • Joku Toinen
      April 16, 2017 at 9:18 am

      Maybe try some other versions of Linux, many of them can be tested with an USB stick (if your eeebox can boot from one, ofc). One of them might succeed better than Ubuntu, maybe.

  6. Webmasterintexas
    January 30, 2011 at 2:25 pm

    I have Ubuntu already installed on this pc. Should I do a complete re-installation of whatever Linux version I want to use if I want to try that clear-OS? THank you for your comprehensible tutorial Dave, I am learning Linux after 10 years of Windows, and what a relief!

  7. Dave Drager
    November 12, 2010 at 2:42 am

    You can open a window in explorer and type in the url of the server, for example: "\\192.168.1.20" or "\\servername". This should list the shares on your server and let you access them from Windows.

  8. Chrishill16
    November 12, 2010 at 1:14 am

    Thanks for your help. I've got it all set up as the articles suggest and I'm able to connect to my server using dyndns.

    How do I access files on the server (music, movies) from my Windows pc on the same network? I tried to add a new network location but that didn't work. Ideally I want to be able to store all my music and movies on the server and access them from my pc - is this something to do with the shared folder?

    Thanks again.

  9. Chrishill16
    November 10, 2010 at 9:05 pm

    Dave, great article - currently following it to setup my server.

    Just wondering... if i set my system up as described in the article, will i also be able to use it as a file server and stream movies from it? I'd also like to be able to grab files from it when I'm away from home, which I guess I could do with ftp?

    • Dave Drager
      November 10, 2010 at 9:12 pm

      Yes, using the "share this folder" option in part 2 will allow you to enter your computer share on another computer, allowing you to stream movies from it using something like Boxee or another computer. FTP will work, but it is an insecure protocol, I would recommend using SSH or SCP to transfer files to/from the server remotely. Just make sure to forward the correct ports.

      • Chrishill16
        November 12, 2010 at 12:14 am

        Thanks for your help. I've got it all set up as the articles suggest and I'm able to connect to my server using dyndns.

        How do I access files on the server (music, movies) from my Windows pc on the same network? I tried to add a new network location but that didn't work. Ideally I want to be able to store all my music and movies on the server and access them from my pc - is this something to do with the shared folder?

        Thanks again.

        • Dave Drager
          November 12, 2010 at 1:42 am

          You can open a window in explorer and type in the url of the server, for example: "\192.168.1.20" or "\servername". This should list the shares on your server and let you access them from Windows.

  10. Chrishill16
    November 10, 2010 at 10:05 pm

    Dave, great article - currently following it to setup my server.

    Just wondering... if i set my system up as described in the article, will i also be able to use it as a file server and stream movies from it? I'd also like to be able to grab files from it when I'm away from home, which I guess I could do with ftp?

  11. Jormamakela
    November 8, 2010 at 10:34 pm

    Another option is to use Slackware... even less resources, older computer... ;)

    • Dave Drager
      November 9, 2010 at 1:51 pm

      Ah yes, good old slackware. The options are endless as so many platforms run Apache or other web servers!

  12. Ken
    November 8, 2010 at 3:56 pm

    Excellent article Dave!! I am fairly new to Linux and was able to follow through without a hitch. Looking forward to part 2.

  13. Wanderson
    November 8, 2010 at 3:13 pm

    I recommend a much, much easier process for setting up a web server on an older PC - which author did not specify as to hardware specifications.

    I used a Dell P3-667mhz, with 384MB RAM, and 10GB HD. I installed ClearOS 5.2 - from http://www.clearfoundation.com - which is vanilla CentOS 5.x with considerable additional server configuration and server tools and has Apache/MySQL,PhP for Web, FTP, Windows Shares and much, much more already in packaged install. It even has browser admin GUI-type interface.

    I enabled MySQL and Web Server- with simple button click, then from browser on another PC on my network typed in server ipaddress. Voila! - a web page of ClearOS logo. Administration is a piece of cake - from browser, enter https://ipaddress:81 and you are at secure (SSL) admin login.

    The most sophisticated, easy-to-use Web/other server setup and use I have experienced in more than twenty years as a technologist.

    W. Anderson
    wanderson@kimalcorp.org

    • Dave Drager
      November 9, 2010 at 1:50 pm

      Thanks for the link! Looks like a great way to get started with a Web Server.

  14. Wanderson
    November 8, 2010 at 4:13 pm

    I recommend a much, much easier process for setting up a web server on an older PC - which author did not specify as to hardware specifications.

    I used a Dell P3-667mhz, with 384MB RAM, and 10GB HD. I installed ClearOS 5.2 - from http://www.clearfoundation.com - which is vanilla CentOS 5.x with considerable additional server configuration and server tools and has Apache/MySQL,PhP for Web, FTP, Windows Shares and much, much more already in packaged install. It even has browser admin GUI-type interface.

    I enabled MySQL and Web Server- with simple button click, then from browser on another PC on my network typed in server ipaddress. Voila! - a web page of ClearOS logo. Administration is a piece of cake - from browser, enter https://ipaddress:81 and you are at secure (SSL) admin login.

    The most sophisticated, easy-to-use Web/other server setup and use I have experienced in more than twenty years as a technologist.

    W. Anderson
    wanderson@kimalcorp.org

  15. Kichaas2003
    November 8, 2010 at 12:09 pm

    how to do it offline. ie with UBUNTU Desktop and Server CD ???

    • Dave Drager
      November 8, 2010 at 12:49 pm

      You do not need to be online to do the install, when you are installing do not check off the "download updates" section.

  16. Anonymous
    November 8, 2010 at 6:05 am

    The article should be titled "How To Build An Ubuntu Web Server..."- there's a lot more to Linux than Ubuntu.

    • Dave Drager
      November 8, 2010 at 10:33 am

      Yes - but you will have to forgive me because writing an article covering all linux distributions and permutations would be near impossible! Just trying to get neophytes up and running on linux, and Ubuntu is probably the easiest way to get them started.

  17. Anonymous
    November 5, 2010 at 4:43 pm

    looking forward to the next part

    • Dave Drager
      November 5, 2010 at 5:05 pm

      Thanks - in part two I go over connectivity to the web.

  18. Shubham
    November 5, 2010 at 11:17 am

    very nice article dave . Just one question . Can we use other distributions of linux such as Puppylinux or DSL to make a server? if yes then is the process same ?

    • Dave Drager
      November 5, 2010 at 12:29 pm

      Steps are basically the same but each package might have a slightly different name. Also each distribution has different methods of distributing software, for example Fedora would use RPM.

  19. Heri NXI
    November 5, 2010 at 6:54 am

    good practice to start into linux, don't scare them with command line, nice guide article :)

  20. Gamaware
    November 4, 2010 at 7:23 pm

    I think everything in this post is great except for the idea to use Ubuntu Desktop as the server I would recomend to use Open Suse (since it has more packages already available) or Ubuntu Server (sinces is designated completely for servers) but if the Idea is to learn how to set up a web server with no experience at all, Cent OS or Fedora is a good place to start, Ubuntu Desktop has a lot of apps that doesn't necesarly need to be there to set up the server

    this is just my opinion, but great job I love the posts

    • Dave Drager
      November 4, 2010 at 7:31 pm

      I chose the desktop version because of the ease of use of the GUI. For someone not used to command line, I thought that would be the easiest way to get started - also familiarizing them with the Ubuntu system along the way.

      I agree that there are a lot of apps that a server does not need, but in general ease of use it is the best place to start on linux.

  21. Vance Denial
    November 4, 2010 at 7:16 pm

    Why are you using the desktop version (which has a full and completely unnecessary GNOME implementation) rather than the server version?

    • Dave Drager
      November 4, 2010 at 7:31 pm

      I chose the desktop version because of the ease of use of the GUI. For someone not used to command line, I thought that would be the easiest way to get started - also familiarizing them with the Ubuntu system along the way.

  22. Dave Drager
    November 4, 2010 at 8:31 pm

    I chose the desktop version because of the ease of use of the GUI. For someone not used to command line, I thought that would be the easiest way to get started - also familiarizing them with the Ubuntu system along the way.

    I agree that there are a lot of apps that a server does not need, but in general ease of use it is the best place to start on linux.

  23. Gamaware
    November 4, 2010 at 8:23 pm

    I think everything in this post is great except for the idea to use Ubuntu Desktop as the server I would recomend to use Open Suse (since it has more packages already available) or Ubuntu Server (sinces is designated completely for servers) but if the Idea is to learn how to set up a web server with no experience at all, Cent OS or Fedora is a good place to start, Ubuntu Desktop has a lot of apps that doesn't necesarly need to be there to set up the server

    this is just my opinion, but great job I love the posts