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

webserveroldpc1   How To Build a Linux Web Server With An Old Computer [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.

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

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.

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

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.

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

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.

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

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!

The comments were closed because the article is more than 180 days old.

If you have any questions related to what's mentioned in the article or need help with any computer issue, ask it on MakeUseOf Answers—We and our community will be more than happy to help.

26 Comments -

Asheridan

Thanks, But Is it possible to do what you’ve explained on Ubuntu server?

Dave Drager

Yes – it is very possible. I chose Desktop because most users are familiar with the GUI. There are commands to do the same tasks via command line as well.

Paul G

Nice article(s) with clear and simple instructions.

I have a a request though – not everyone has a spare PC. I would like to do local testing before committing to a live hosted server. Is it possible to do this with a virtual machine? If so, what are the chances of a similar article for that scenario?

Paul G

Nice article(s) with clear and simple instructions.

I have a a request though – not everyone has a spare PC. I would like to do local testing before committing to a live hosted server. Is it possible to do this with a virtual machine? If so, what are the chances of a similar article for that scenario?

Dave Drager

In this situation, you would run the install in a virtual instance, for example “VirtualBox.” The instructions would be the same, but one thing you will need to pay attention to is the Networking setup. Instead of using “NAT” which is the default, you would use bridged networking so that you can set up the IP address on the server to be reachable from other locations on your network or even outside of your network. Once it is in bridged mode and you assign it an IP address, it will act just like another machine on the network. Note that you will need to keep the Guest running to reach your web server.

Paul G

Thanks Dave. I am cheating and downloading the CentOS VM as I have VMware installed. The networking tips should come in handy though as I would probably have stumbled on that.

Desiagui

Great article, did it on Ubuntu Server and just hit a couple snags. First, I could not share www because I was not the owner. Since I am not great on Linux command line had to log in as root to change ownership to my user. Then I can see mi IP on the browser (It works!…) but get not found when tried to see my IP/www, changed the permissions a bit but all I got was a change form not found to forbidden.
Finally, a question, once I am past the issue I am having, how do you add content to your web server?

Thanks

Desiagui

Great article, did it on Ubuntu Server and just hit a couple snags. First, I could not share www because I was not the owner. Since I am not great on Linux command line had to log in as root to change ownership to my user. Then I can see mi IP on the browser (It works!…) but get not found when tried to see my IP/www, changed the permissions a bit but all I got was a change form not found to forbidden.
Finally, a question, once I am past the issue I am having, how do you add content to your web server?

Thanks

Dave Drager

To add content, you simply place it into that directory. Test with a simple .html file (Maybe Hello world!) to ensure you are putting it in the right spot.

Frankie_82

Great tutorial,especially for newbies(like me ;-) ) to Linux …I have Ubuntu 10.10 installed,I followed every step ,but I have some problems…First , when I try to check ”Share This Folder” under Sharing Options,I get this message : ‘net usershare’ returned error 255: net usershare add: cannot share path /var/www as we are restricted to only sharing directories we own.
Ask the administrator to add the line “usershare owner only = false”
to the [global] section of the smb.conf to allow this.
Then ,there is another thing : I went in my web browser to http://192.168.x.xx ;I enabled Port Forwarding and I still can’t access to http://yourhostname.dyndns.org and it says that the server is not responding.I tried few more times,but with no success …I really don’t know what should I do,so all help that I can get would be highly appreciated…
Thanks…

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.

Frankie_82

Great tutorial,especially for newbies(like me ;-) ) to Linux …I have Ubuntu 10.10 installed,I followed every step ,but I have some problems…First , when I try to check ”Share This Folder” under Sharing Options,I get this message : ‘net usershare’ returned error 255: net usershare add: cannot share path /var/www as we are restricted to only sharing directories we own.
Ask the administrator to add the line “usershare owner only = false”
to the [global] section of the smb.conf to allow this.
Then ,there is another thing : I went in my web browser to http://192.168.x.xx ;I enabled Port Forwarding and I still can’t access to http://yourhostname.dyndns.org and it says that the server is not responding.I tried few more times,but with no success …I really don’t know what should I do,so all help that I can get would be highly appreciated…
Thanks…

Henry_marsudianto

hello, i have ubuntu 10.10 installed, i have the same problems i followed every step.. i still can’t access to http://myhostname.dyndns.org and it says ‘The connection has timed out’ ‘The server myhostname.dyndns.org ‘ at is taking too long to respond. i tried few more times.. still can’t access. Is there any configuration that i don’t know?? i ‘m really need this solution . thanks …

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.

Henry_marsudianto

hello, i have ubuntu 10.10 installed, i have the same problems i followed every step.. i still can’t access to http://myhostname.dyndns.org and it says ‘The connection has timed out’ ‘The server myhostname.dyndns.org ‘ at is taking too long to respond. i tried few more times.. still can’t access. Is there any configuration that i don’t know?? i ‘m really need this solution . thanks …

HackThePow

Can anybody provide any more info for further administration past this? I have it running and what not but I feel like theres a ton going on behind the scenes that I have no clue of.

I would also like to be able to administer the server while I’m out in colorado. Any way to do this with FileZilla or something like that?

HackThePow

Can anybody provide any more info for further administration past this? I have it running and what not but I feel like theres a ton going on behind the scenes that I have no clue of.

I would also like to be able to administer the server while I’m out in colorado. Any way to do this with FileZilla or something like that?

Dave Drager

There is a ton more you can learn in this space, but is beyond the scope of this article. For a good start, check out http://www.howtoforge.com/ or http://ubuntuguide.org which both provide great howtos. Consider installing something like Webmin (http://www.webmin.com/) for remote web administration.

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.

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.

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

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

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.