How to Build a Linux Web Server With an Old Computer
Pinterest Whatsapp
Advertisement

Interested in learning about Linux or running a home web server? Installing Linux on a spare old computer is a pretty easy thing to do these days with many consumer friendly distributions such as Ubuntu and Mint Linux. After getting up and running you will have a platform for hosting your website in-house either for development or to self-host a website.

This how-to article is broken down into 4 major steps: 1. Acquire an old computer, 2. Install Operating system, 3. Set up the application web server software (Apache, PHP, MySQL), and 4. Reaching the computer from the internet.

Acquire an Old Computer

Linux is a versatile operating system in that it can be run on the slowest of PCs, at least in command line mode. For simplicity’s sake, we are going to be running Ubuntu 10.10 “Maverick Meercat” which was just released and reviewed by Justin.

System Requirements

The Ubuntu 10.10 lists 256MB of RAM as the minimum amount it will work on. The installation itself takes up 3.3GB and then you want to leave space for the additional software and any files you need to work with, so I would peg that minimum at 10GB.

Ubuntu supports a wide variety of video cards, hard drives and other hardware; if you want to check before downloading the install disk, look at the Linux hardware compatibility list for both complete systems and individual components in your system to see if it will work. Before getting too caught up in this though, it is pretty quick and simple to test things out with a Live CD to make sure everything will work on your system.

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 as heat will be your system’s main enemy.

Install Ubuntu

linux web server software

Installing Ubuntu is a cinch with the latest 10.10 installer. My favorite feature of the installer is that while you are still making choices about the installation, it is working to format and copy files over to your hard drive.

Head on over to the Ubuntu Desktop CD Download site to get the ISO file. These disk images have the latest versions of software so you should only have to do a minimum of upgrading after the install. Use the 64-bit version if your computer supports it or the 32-bit version otherwise. Burn the ISO to a CD or DVD, plug it into the drive of the computer and boot up.

If you need to change the BIOS settings to boot off of a CD then do so, or sometimes you need to press a key to select an alternative boot media. Boot off of the CD drive and select the “Install Ubuntu.” Generally speaking, we will be installing the least amount of software as possible for two reasons: the first is that the more software you install and services you run in the background, the slower your system will be. The second is that it also opens your system up to more potential security holes in the future.

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. I do not recommend encrypting your home folder. Reboot after the installation is complete.

linux server

Upon reboot, your install is essentially complete! The first thing you need to do after an install, similar to a Windows machine, is to apply any updates. Go to System->Administration->Update Manager and “Install Updates”. You may need to reboot after installing any updates it has found.

You now have a fully-functional Ubuntu install.

Set Up Application Services

You have a number of options here, but since most websites run on a combination of Apache, MySQL and PHP, we are going to install those. This is similar to what we recommended installing on Windows How To Set Up Your Own WampServer How To Set Up Your Own WampServer Read More .

These applications are installed via the Ubuntu Software Center. Launch the software center 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 a number of prerequisites: apache2, php5, php5-mysql, and mysql-server. Apply the changes to install the packages.

linux server

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

Test Your Web Server!

You can test your web server by opening the Firefox web browser on your server and heading to the URL http://127.0.0.1/.

linux web server software

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. Your web server is now essentially working and you can edit the files in /var/www and see the changes live on your website.

Part two of this series, to be published shortly, will go over how to upload files to your Linux web server; and how to access your web server both over your local network and via the internet. Check back to see how to complete your setup. The setup is pretty straight forward but there are always hiccups along the way.

Part 2

You’ve learned how to install Ubuntu and the Linux web server software including Apache, PHP and MySQL in part one of this series. Now learn how to upload your files and finally view your web server from anywhere in the world!

Now that our server is functional, we have to take care of the part where we can actually use it. Basically we need to expose the server to the outside world, so from here on out it is important to keep the server up to date with all of its patches – the Ubuntu Update Manager will take care of this for you.

Finding The Server’s Local IP Address

First thing you need to do is to find the server’s local IP address and set it to something you will later be able to reference. Let’s find the server’s currently set IP address – found via the dynamic DHCP protocol – in the Network Information box.

Right click on your network connection which will be an up/down array and go to “Connection Information.” This will pop up a box with your current IP address, network adapter card, broadcast address, gateway, and DNS server. Write this down as we will use it in the next step.

linux web server software

What we need to do is edit your connection information to give you a static IP address on your local network. Right click that menu but this time go to “Edit Connections.” Select the adapter name from the previous step – in my case it is eth1, and edit those settings. Select the IPv4 tab and switch “Method” to “Manual” rather than “Automatic (DHCP)” which is what it defaults to when you install. Type in the information from your connection settings.

How to Build a Linux Web Server With an Old Computer connectionedit1

The one difference we will have this time will be your IP address. Keep the first three octets (the numbers between the dots) and change the last one to a high number under 254. It is important that this number not be in use on your network, and if you are not sure, pick a high IP address like 250. For our example I know that .10 is free, so let’s say our new IP address is 192.168.2.10. This will be your static, local IP address.

Sharing The Web Folder

Sharing a folder is probably the easiest way to access and upload files onto your server. However, and this is a big one, this also opens your server up security-wise and it is important to only use this method if your server is on a private network and you do not run the risk of anyone connecting to it, via wired or wireless, and accessing your shares.

First we need to relax the permissions on our web folder. Open a terminal by going to Applications->Accessories->Terminal. Enter the following command:

$ sudo chmod 777 /var/www

It will prompt your for your password and then change the permissions, which will have no message returned if it went successfully.

linux server for web hosting

Now go to the file browser (Places->Computer) and go to File System->/var/. Right click the www folder and then “Sharing options.” Check off “Share this folder“. For security options, you can either share it with or without a password. Select “Guest access” to share the folder without requiring a username and password.

This means that you or anyone else will be able to access the files without a password. For this reason, I recommend sharing with a password. It will be more of a pain because you will need to enter this information, but it is certainly more secure. Also check off “Allow others to create and delete files in this folder.” This allows write access from the shared directory.

linux web server software

To view your files, go to the network location //192.168.2.10/www. It will either prompt you for your password or allow you access straight to your files, depending on your security settings. This is the same set of files that you can access in your web browser by going to http://192.168.2.10/.

Port Forwarding

Now that we have our 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 also some business connections, the IP of your local computer is not actually exposed to the internet – it will be in a private range that is either 192.168.x.x or 10.x.x.x. So how do visitors to your website actually contact your server? We do this with port forwarding.

Ports Open Router Ports & Their Security Implications [Technology Explained] Open Router Ports & Their Security Implications [Technology Explained] Read More on a server are similar to doors or windows on a house – each one will give you access to a different service running on the server. Web servers use port 80 by default.

Your router should have a section called “Port Forwarding“, or “Applications” which will allow you to forward ports properly. Forward TCP port 80 to inside your network on the IP address we specified above. Each router is different, so refer to your router’s operations manual on how to set this up properly.

Getting A Static Hostname

Most home connections have what is called a dynamic IP What Is A Dynamic IP Address & How Do I Get One? [Technology Explained] What Is A Dynamic IP Address & How Do I Get One? [Technology Explained] Read More , which means that it will change after a set period, usually a week or so. We have covered the fantastic DynDNS server here on MakeUseOf Connect To Your Home PCs From Anywhere With DynDNS Connect To Your Home PCs From Anywhere With DynDNS Read More last year, so check out that article for more information on using the DynDNS service. Make sure you use the Linux client for updating your dynamic IP with the DynDNS servers. For our web server you will want to forward TCP port 80. Forward this port to the local static IP address, in our case this is 192.168.2.10.

You should now be able to visit your web server from the outside world by going to the URL: 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.

The World Is Your Oyster

That is it for our down and dirty guide to running your own web server on an old computer. It can be as simple or as complicated as you want and there are many variables thrown into the process so it is easy to get caught up on something. If you run into any problems, feel free to leave a response below and we’ll guide you through the process as best as we can.

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

Questions from new system administrators? Ask away in the comments and I’ll be sure to get back to you!

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. Kevin
    September 16, 2016 at 7:02 pm

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

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

    Great and simple tutorial.
    Is there a part 2?

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

    thank you so much

  4. 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.

  5. 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!

  6. 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.

  7. 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.

  8. 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.

  9. 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?

  10. 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!

  11. 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.

  12. 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.

  13. 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

  14. 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.

  15. 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.

  16. 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.

  17. 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.

  18. 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 :)

  19. 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.

  20. 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.

  21. 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.

  22. 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