Ubuntu Forums ubuntu.com - launchpad.net - ubuntu help  

Go Back   Ubuntu Forums > The Ubuntu Forum Community > Other Community Discussions > Tutorials & Tips
Register Reset Password Forum Help Forum Council Search Today's Posts Mark Forums Read

Tutorials & Tips
The place to find Ubuntu related Tips & Tricks.

 
Thread Tools Display Modes
Old December 5th, 2007   #1
ubuntuman001
Chocolate-Covered Ubuntu Beans
 
Join Date: Mar 2006
Beans: 2,142
Ubuntu 9.10 Karmic Koala
HOWTO: Setup an Apache Web Server For Free ($0)

So here's what I did to get an Apache Web Server running in my house. I setup a very basic but totally cost-free server. Note: This guide is not for setting up LAMP servers (Linux, Apache, MySQL, PHP/Perl/Python), as I didn't need to run a database or scripting for my small website, so all we're using here is Ubuntu Linux and Apache Server.

1. Install the latest Ubuntu Server Edition on the computer you're setting up as a server. A great guide on these steps is here. Make sure to not select anything in the software selection screen (where it asks if you want to install a LAMP server, an Email server, etc.), unless you know what you're doing.

2. Now go to http://dyndns.com and make an account; I signed up for the Dynamic DNS service (because it's completely free) and made a hostname (my personal URL). Free hostnames cannot be top-level domains, such as yahoo.com, but you can make one like mydomain.dyndns.org)

You may already have a hostname; in that case, you might want to sign up for the Custom DNS service, or also if you want to buy your own top-level domain (for ex. mydomain.com instead of a lower level domain such as mydomain.dyndns.org). All the information you need to set up all the DynDNS stuff is at their website.

3. Log into your server, and install Apache and the DynDNS client:
Code:
sudo apt-get install apache2 ddclient
If you don't know what to put for certain dialogs, just go with defaults.

Now you have to restart the ddclient:
Code:
sudo /etc/init.d/ddclient restart
4. Open a web browser on another computer, type your router's IP address into the address bar (usually 192.168.1.1 or something similar - look in your router's manual if not sure). You might need to give it a password to log in (the most common default is admin).

You will need to change a few settings, including port forwarding port 80 to the static IP address that you're going to give your server (use the alternate ports 8080 or 8090 if you know that your ISP blocks port 80 by default).

You also have to make sure that the DHCP address range of the router does not conflict with the future static IP address you'll assign your sever. That means that if your DHCP hands out IP addresses starting at 192.168.1.100 till 192.168.1.110, then you'll want your static IP address of your server to be somewhere above that, like 192.168.1.125

If there is a DynDNS setting in your router (linksys has one, it calls it DDNS) then you should put your DynDNS account settings there.

5. Now we'll set the server to have a static IP address (assuming you went with 192.168.1.125 and that your router's IP address is 192.168.1.1):
Code:
sudo nano /etc/network/interfaces
and change
Code:
auto eth0
iface eth0 inet dhcp
to
Code:
auto eth0
iface eth0 inet static
address 192.168.1.125
netmask 255.255.255.0
gateway 192.168.1.1
Then restart the network process:
Code:
sudo /etc/init.d/networking restart
That's it! Now your server has a static IP address.

6. If your ISP blocks port 80, then you have to change the default Apache config file:
Code:
sudo nano /etc/apache2/ports.conf
Change the 80 to either 8080 or 8090, depending on which port you forward to your static IP address in your router settings. If you do this, you must restart Apache:
Code:
sudo /etc/init.d/apache2 restart
7. If your ISP blocks port 80, and if you chose your alternate port to be 8080, then your URL has to change accordingly; hence a sample host name you would make in dyndns.com could be name.home.dyndns.org:8080 (notice how you have to put a colon and the appropriate port number after the default URL).

In dyndns.com, you can use their "webhop" service (also free, just make another hostname) to redirect the host name you have (with the :8080) to a nicer looking one. For example, you could tell people your URL is name.dyndns.org but it redirects to the one with the :8080.

You can also "cloak" your website so that when you redirect, say, name.dyndns.org to name.home.dyndns.org:8080, it still shows name.dyndns.org in the address bar; the only bad thing about this is that you'll be stuck with a DynDNS banner at the top of your website.

8. Reboot, just to make sure everything is okay:
Code:
sudo reboot
and try going to your URL in a web browser, it should load instantly. Also try checking if your website shows up on a computer outside you local network, to see if it is actually visible on the World Wide Web, and not just your LAN. This can also be done by typing your URL in a proxy server, like this one: http://www.freeproxyserver.net/

9. (optional) If you want to easily transfer files from your windows box to your ubuntu server, use this guide: (it worked for me) http://ubuntuforums.org/showthread.php?t=202605

This is great for updating your website files in /var/www.

Thanks to everyone who helped me with all of this, especially p_quarles, dfreer, and crashmaxx.

Last edited by ubuntuman001; February 10th, 2009 at 08:47 PM..
ubuntuman001 is offline   Reply With Quote
Old December 13th, 2007   #2
ubuntuman001
Chocolate-Covered Ubuntu Beans
 
Join Date: Mar 2006
Beans: 2,142
Ubuntu 9.10 Karmic Koala
Re: HOWTO: Setup an Apache Web Server For Free ($0)

tech9, rouge568, and alwiap you wanted me to tell you how everything went for me, and as you can see I got it all to work, so if you want to follow this guide but have any questions, let me know.
ubuntuman001 is offline   Reply With Quote
Old December 18th, 2007   #3
tech9
100% Pure Ubuntu
 
tech9's Avatar
 
Join Date: Sep 2007
Location: 010101010101001101000001
Beans: 857
Ubuntu 9.10 Karmic Koala
Re: HOWTO: Setup an Apache Web Server For Free ($0)

Quote:
Originally Posted by ubuntuman001 View Post
tech9, rouge568, and alwiap you wanted me to tell you how everything went for me, and as you can see I got it all to work, so if you want to follow this guide but have any questions, let me know.
Wow! great job ubuntuman001!

Thank you for taking the time to put this guide together!

I am going to build a box/server special and dedicate it as an Apache Web Server ... powered by Ubuntu!
tech9 is offline   Reply With Quote
Old December 18th, 2007   #4
ubuntuman001
Chocolate-Covered Ubuntu Beans
 
Join Date: Mar 2006
Beans: 2,142
Ubuntu 9.10 Karmic Koala
Re: HOWTO: Setup an Apache Web Server For Free ($0)

Quote:
Originally Posted by tech9 View Post
Wow! great job ubuntuman001!

Thank you for taking the time to put this guide together!

I am going to build a box/server special and dedicate it as an Apache Web Server ... powered by Ubuntu!
Awesome!
ubuntuman001 is offline   Reply With Quote
Old December 13th, 2007   #5
dfreer
Chocolate Ubuntu Mocha Blend
 
dfreer's Avatar
 
Join Date: Jan 2006
Beans: 1,843
Ubuntu 7.10 Gutsy Gibbon
Re: HOWTO: Setup an Apache Web Server For Free ($0)

Very nice guide ubuntuman001, and congrats on getting your webserver up and running!

Quote:
Originally Posted by ubuntuman001 View Post
7) On the server, install the dyndns client:
Code:
sudo apt-get install ddclient
and give it the information it asks for.
When I ran the automatic configuration for ddclient, it set several variables incorrectly (I may have just done it wrong ). Here's what I started with:
Code:
pid=/var/run/ddclient.pid
protocol=dyndns2
use=if, if=eth0
server=members.dyndns.org
login=myusername
password='mypassword'
mydomainname.com
The main thing I had to change here is the line highlighted in bold. If you set it to use the interface it will grab your LAN's IP address, which is most likely your private IP address. In most cases you'll want to change it to this:
Code:
use=web, web=checkip.dyndns.com/, web-skip='IP Address'
This uses checkip.dyndns.com to grab your external IP address, and not your internal LAN IP.

Other useful things to add (see http://www.dyndns.com/support/kb/usi..._services.html for more details):
Code:
syslog=yes   ## logs information to /var/log/messages
mail-failure=root   ## you can replace this with your username if you wish
wildcard=YES  ## useful if you checked the "Use Wildcards" option, may not be available for the Free Dyndns service
custom=yes, yourdomainname.com  ## add the custom=yes option if you are using the "Custom DNS" service
Quote:
Originally Posted by ubuntuman001 View Post
Then change the default apache config file:
Code:
sudo nano /etc/apache2/ports.conf
and make it look like this after the Listen part (again, assuming you went with 192.168.1.125):
Code:
Listen 192.168.1.125:80
if your ISP blocks port 80, then after the colon you would change that to either 8080 or 8090.
Unless you have a particular reason to bind apache to your static IP address, you don't need to specify your static LAN IP address in the ports.conf file. You can just do this:
Code:
Listen 8080
It's really not important, but it's one less thing you have to change if you for some reason change your static IP address. Plus, if you have multiple IP addresses on your server (two ethernet cards for example), it will respond to any incoming request for port 8080, and not just requests to 192.168.1.125:8080.

Just my two cents

Last edited by dfreer; December 13th, 2007 at 11:58 PM..
dfreer is offline   Reply With Quote
Old December 13th, 2007   #6
tr333
Ubuntu Extra Shot
 
tr333's Avatar
 
Join Date: Aug 2005
Location: Sydney, Australia
Beans: 361
Ubuntu Development Release
Re: HOWTO: Setup an Apache Web Server For Free ($0)

Quote:
Originally Posted by ubuntuman001 View Post
2) Once you have rebooted and you've logged in to your new install, you'll first want to omit the CD ROM repository from the sources.list file, to prevent apt from asking you for your server CD every time you want to install software:
Code:
sudo nano /etc/apt/sources.list
Place an # in front of the CD repository (usually the first line, can't miss).

...

6) Now we'll set the server to have a static IP address (assuming you went with 192.168.1.125):
Code:
sudo nano /etc/network/interfaces
...

Then change the default apache config file:
Code:
sudo nano /etc/apache2/ports.conf
If you're editing config files with nano, you should use the '-w' option to disable wrapping of long lines. This will prevent issues from arising if you have a long comment line in a config file and it gets wrapped onto the next line.

Code:
sudo nano -w /path/to/file
It would be even easier to set the EDITOR environment variable in ~/.bashrc to "nano -w". This enables you to use the sudoedit command to edit files with nano.
Code:
# ~/.bashrc
export EDITOR="nano -w"
Code:
$ man sudoedit
$ sudoedit /path/to/file
__________________
Just another Perl hacker,

Last edited by tr333; December 13th, 2007 at 10:45 PM..
tr333 is offline   Reply With Quote
Old December 18th, 2007   #7
alwiap
Way Too Much Ubuntu
 
alwiap's Avatar
 
Join Date: Feb 2007
Location: detroit
Beans: 248
Ubuntu 8.04 Hardy Heron
Re: HOWTO: Setup an Apache Web Server For Free ($0)

I'm starting to do this right now, so I'll let ya know how it goes!
__________________
go wings geaux tigers go pistons
linuxmint/XP desktop/laptop, nokia n800 ( os2008 )
alwiap is offline   Reply With Quote
Old December 23rd, 2007   #8
ubuntuman001
Chocolate-Covered Ubuntu Beans
 
Join Date: Mar 2006
Beans: 2,142
Ubuntu 9.10 Karmic Koala
Re: HOWTO: Setup an Apache Web Server For Free ($0)

Quote:
Originally Posted by alwiap View Post
I'm starting to do this right now, so I'll let ya know how it goes!
alright, let me know if you're having any issues...

Last edited by ubuntuman001; December 26th, 2007 at 08:34 PM..
ubuntuman001 is offline   Reply With Quote
Old December 25th, 2007   #9
p_quarles
Midnight Commander
 
p_quarles's Avatar
 
Join Date: May 2007
Beans: 7,042
Kubuntu 9.04 Jaunty Jackalope
Send a message via AIM to p_quarles
Re: HOWTO: Setup an Apache Web Server For Free ($0)

All right, so just last night, my ISP decided to suddenly block my inbound port 80. Gah. Anyway, I remembered this tutorial, and followed the instructions for using webhop. Working nicely, thanks.

The problem: I seem to have to choose between two less-than-ideal options with this service. If I don't check the "cloak" box in the webhop setup options, the DNS server points to my site properly, but displays my IP address + port number rather than the URL. If I do check the "cloak" option, it displays the URL . . . as well as a banner advertising DynDNS's webhop service.

Yeah, I know there's only so much you can expect from a free DNS, but does anyone happen to know a way around this?
__________________
I am aware of all internet traditions. | Getting the best help | Text formatting codes | My last.fm profile
Should I PM support questions? NO!
p_quarles is offline   Reply With Quote
Old December 26th, 2007   #10
ubuntuman001
Chocolate-Covered Ubuntu Beans
 
Join Date: Mar 2006
Beans: 2,142
Ubuntu 9.10 Karmic Koala
Re: HOWTO: Setup an Apache Web Server For Free ($0)

Quote:
Originally Posted by p_quarles View Post
All right, so just last night, my ISP decided to suddenly block my inbound port 80. Gah. Anyway, I remembered this tutorial, and followed the instructions for using webhop. Working nicely, thanks.

The problem: I seem to have to choose between two less-than-ideal options with this service. If I don't check the "cloak" box in the webhop setup options, the DNS server points to my site properly, but displays my IP address + port number rather than the URL. If I do check the "cloak" option, it displays the URL . . . as well as a banner advertising DynDNS's webhop service.

Yeah, I know there's only so much you can expect from a free DNS, but does anyone happen to know a way around this?
yea that was the exact problem I was having, I couldn't find a way around it, so I decided that it showing my URL + port number was better than that banner at the top.
I know it looks sort of ugly, but it is the lesser of two evils, sotospeak (I think at least)
ubuntuman001 is offline   Reply With Quote

Bookmarks

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -4. The time now is 09:02 AM.


vBulletin ©2000 - 2009, Jelsoft Enterprises Ltd. Ubuntu Logo, Ubuntu and Canonical © Canonical Ltd. Tango Icons © Tango Desktop Project. bilberry