How To Build a Linux Web Server With An Old Computer [Part 2]

Ads by Google

linux web server softwareYou’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

Ads by Google

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.

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 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, 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 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!

Join live MakeUseOf Groups on Grouvi App Join live Groups on Grouvi
Master the Linux Command Line
Master the Linux Command Line
38 Members
Best Linux Apps
Best Linux Apps
35 Members
Linux for New Switchers
Linux for New Switchers
34 Members
Linux Distros Talk
Linux Distros Talk
29 Members
Ads by Google
Comments (26)
  • ryn_90

    Thanks Dav, that solved that issue.

    Now it’s working from my network too, if i type: //192.168.2.11/ the index page comes up, but I cannot view //192.168.2.11/www for some reason.

    What will you use next to upload files from your main computer to your old computer/web server ? Something like FTP? Preferably something which can be dont even not from the same network.

    Update: I have a fixed ip, should I be able to access my web pages from everywhere if i write my external ip. instead of using dyndns.org because using my ip is not working for me.

  • Anonymous

    Hi Dave,

    I ran into some problems, mainly with sharing the file it returned me this error:

    ‘net usershare’ returned error 255: net usershare add: cannot share patch /var/www as we are restricted to only sharing directories we own.
    Ask administrator to add the line “users have owner only = false” to the [global] section of the smb.conf to allow this.

    Then I tried to to do that, but it didn’t let me edit the smb.conf file either because it said that the file is read only.

    I am kind of a newb when it comes to linux so I may be doing something wrong, but i did do “sudo chmod 777 /var/www”.

    • Dave Drager

      You will have to run sudo gedit /etc/smb/smb.conf to edit that file as the root user. It should let you edit it and then change permissions on that /var/www file as well.

    • Anonymous

      Thanks Dav, that solved that issue.

      Now it’s working from my network too, if i type: //192.168.2.11/ the index page comes up, but I cannot view //192.168.2.11/www for some reason.

      What will you use next to upload files from your main computer to your old computer/web server ? Something like FTP? Preferably something which can be dont even not from the same network.

      Update: I have a fixed ip, should I be able to access my web pages from everywhere if i write my external ip. instead of using dyndns.org because using my ip is not working for me.

  • ryn_90

    Hi Dave,

    I ran into some problems, mainly with sharing the file it returned me this error:

    ‘net usershare’ returned error 255: net usershare add: cannot share patch /var/www as we are restricted to only sharing directories we own.
    Ask administrator to add the line “users have owner only = false” to the [global] section of the smb.conf to allow this.

    Then I tried to to do that, but it didn’t let me edit the smb.conf file either because it said that the file is read only.

    I am kind of a newb when it comes to linux so I may be doing something wrong, but i did do “sudo chmod 777 /var/www”.

  • Dave Drager

    First step is to confirm myhostname.dyndns.org forwards to your real external IP address, you can confirm this by going to a site like icanhazip.com. The second is to make sure your router is forwarding port 80 to your local server’s port 80. The third is to check to see if your ISP blocks port 80 – some do. You can usually get around this by using port 8080 externally and forwarding it to port 80 locally.

  • Dave Drager

    I haven’t had that error message pop up when trying to share the folder. It should prompt you for the root password to share the folder if it needs further permission. It could be a bug in the sharing code, will have to look at that.

    Confirm that yourhostname.dyndns.org actually points to your local IP address, you can confirm your local external IP by going to icanhazip.com – this will display your public address.

Load 10 more
Affiliate Disclamer

This review may contain affiliate links, which pays us a small compensation if you do decide to make a purchase based on our recommendation. Our judgement is in no way biased, and our recommendations are always based on the merits of the items.

For more details, please read our disclosure.
Affiliate Disclamer

This review may contain affiliate links, which pays us a small compensation if you do decide to make a purchase based on our recommendation. Our judgement is in no way biased, and our recommendations are always based on the merits of the items.

For more details, please read our disclosure.