LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (http://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   setting up a web server using apache (http://www.linuxquestions.org/questions/linux-newbie-8/setting-up-a-web-server-using-apache-260151/)

Whatshisface 11-28-2004 09:44 AM

setting up a web server using apache
 
I've read many posts and have been working/playing with this for a few days now. I've got apache installed and running on my FC2 machine, and now I have some questions. When I open my browser and type in the address, "http://localhost", I get the test page and everything works fine so far.
1) The test page says I can make ServerName something I "have the right to use". What does that mean?
2) When I run the server settings program and type in a ServerName and web master email and click to save and exit, it doesn't exit or save the values.
3) I just want to have a website and be able to add, edit and maintain pages. I have an ISP (Verizon) and a DSL connection. Do I need anything else? Do I need to buy/rent a domain name? Can I host the site myself using this machine or do I need to get a host?
4) I read somewhere that I should use my ip address as my ServerName. IS that right? I didn't quite understand why.


I can post my httpd.conf file if that helps.

Here's ifconfig results:
eth0 Link encap:Ethernet HWaddr 00:20:35:B1:A1:4A
inet addr:192.168.1.102 Bcast:192.168.1.255 Mask:255.255.255.0
inet6 addr: fe80::220:35ff:feb1:a14a/64 Scope:Link
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:544 errors:0 dropped:0 overruns:0 frame:0
TX packets:445 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:245645 (239.8 Kb) TX bytes:75985 (74.2 Kb)
Interrupt:11 Base address:0xdf80

lo Link encap:Local Loopback
inet addr:127.0.0.1 Mask:255.0.0.0
inet6 addr: ::1/128 Scope:Host
UP LOOPBACK RUNNING MTU:16436 Metric:1
RX packets:2632 errors:0 dropped:0 overruns:0 frame:0
TX packets:2632 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:0
RX bytes:2969173 (2.8 Mb) TX bytes:2969173 (2.8 Mb)

pingswept 11-28-2004 11:11 AM

Re: setting up a web server using apache
 
1) The test page says I can make ServerName something I "have the right to use". What does that mean?

That means that you can call your server a name that you make up, but not, for example, "amazon.com," because that's taken already. That's not exactly right, because amazon.com is actually a domain name, not a server name, but that's the idea.

2) When I run the server settings program and type in a ServerName and web master email and click to save and exit, it doesn't exit or save the values.

This probably because you aren't running the server setting program as root. Try editing the httpd.conf file by hand if you really can't get the server setting program to work.

3) I just want to have a website and be able to add, edit and maintain pages. I have an ISP (Verizon) and a DSL connection. Do I need anything else? Do I need to buy/rent a domain name? Can I host the site myself using this machine or do I need to get a host?

You can host the site yourself for free right now, but you need to forward port 80 on your router (that box in between your DSL modem and your computer) to your computer. The bad news is that Verizon has probably given you a dynamic IP, which means that they change your IP address every now and then. You can get around this by signing up with a service like dyndns.org, which is free, or you can pay Verizon ~$15/mo for a static IP. Once you fix this problem, you can get a domain name for ~$30/year.


4) I read somewhere that I should use my ip address as my ServerName. IS that right? I didn't quite understand why.

You can, but you don't have to. It's an easy way to keep track of which computer is which, if you have a lot servers, but seeing as you only have one server, it doesn't really matter.

Reply with more questions if this isn't clear. I went through all this about a year ago, so I'm happy to help you bypass the suffering.

JoshSmith41 11-28-2004 11:13 AM

I will try to answer your questions as best as I can.

1) That means that you can only use a domain that you own and not someone else's, you can only use your own IP.
2) I'd suggest editing the httpd.conf file directly
3) You have everything you need to do what you want, you only need to buy a domain if you want to get a memorable address rather than 12.245.935.167 or whatever your IP is.
4) That is correct because you don't have a domain name, to visit your website you would have to enter your IP.

Using your IP as an address for your website will only work if it is static, never changes, if not you will have to use a service similar to DynIP.

See http://www.linuxhelp.ca/guides/apache/ for more configuration help.

Whatshisface 11-30-2004 07:27 PM

This begs the question: Why does my ISP use dynamic IP addressing? There must be some reason. Will using dyndns and changing to static do anything to my connnection?

Hangdog42 11-30-2004 08:49 PM

Quote:

Originally posted by Whatshisface
This begs the question: Why does my ISP use dynamic IP addressing? There must be some reason. Will using dyndns and changing to static do anything to my connnection?
There is not necessarily a 1:1 correlation between the number of users an ISP has and the number of IP addresses it has to hand out. By using dynamic IP addressing, they can keep the IP in more or less constant use, albeit pointing to different computers. Now in practice, your IP is likely to be more static than dynamic if you have a router you leave on all the time. In theory I've got a dynamic IP address from Comcast, but my router has had the same one for months. In fact I think the last time it changed was in response to a power outage.

Anyway, changing from dynamic to static (or the other way) does absolutely nothing to your connection. The only time it really matters is when someone is trying to find your box on the internet. If you have a dynamic IP, then it can be really difficult for your users to find you and that is where dyndns or no-ip.com come in. You can piggy-back off of their registered domains (for free, at least at no-ip) and give your users a constant name to point at. The downside is that you have to have a way to check your router for a changed IP address and then update your dyndns or no-ip account. I think both of these have programs that might be able to do this, or you can check on Google. Or you can update it by hand when it changes.

<edit>
Oh, and by the way, if you do this, be sure to do some reading on security. You need to make sure you have a fully patched box with a good firewall and a file monitor like Aide or Tripwire. If you are leaving your box exposed to the internet 24/7, you will be having people take a crack at it.
</edit>

Whatshisface 12-04-2004 05:56 PM

I have forwarded my port to 80 and have installed dynip on my Fedora box. I have a registered domain name now! Apache is running fine - the test page comes up when I enter my ip address. Now where do I put my web pages? This is to be a web server. I read in a Unix book to make a directory "public_html" with 0755 permissions and a file in there "index.html" with 0644 permissions. Is this correct? Why doesn't my web page come up?

<edit>
I can see my pages now that I have put them im /var/www/html. I'm still trying to get dynip to work with my new hostname. For some reason the connection is refused. I have even turned off my firewall.

Hangdog42 12-05-2004 07:59 AM

A couple of thoughts come to mind. First, double check that dynip has the correct domain name and IP address. The IP address should be the one that you ISP has given you. The way to tell if this is the problem is to forget about the domain name for a second and have someone outside your LAN try to connect to your IP address. If that works, but the domain name doesnt, then the problem is probably at dynip.

The second problem is a lot more troublesome to solve. Some ISPs block port 80 to prevent their users from doing what you are doing, running a server from their house. If the test run I mentioned above doesn't work with either the domain name or the ISP, and you are sure your internal configuration is correct, then port blocking may be the culprit. The way to test this would be to run Apache on a non-standard port or have your router forward a non-standard port to port 80 on your server. If a user can connect to say http://1.2.3.4:7001, but not to http://1.2.3.4, then your ISP is probably blocking port 80.

Whatshisface 12-06-2004 10:03 PM

dynip is working now! It seemed to be the port forwarding. I had entered both device addresses of my machines when I only needed to enter the server machine - 192.168.1.102... Thanks for all your help. Now I can think about what to put on my web pages and do a little cgi. dynip is a great service, but I don't know about paying after the first month. We'll see.

<edit>
Wait a minute. When I try to log on from a node outside of the lan, I get 'Page Cannot Be Displayed', so I guess it doesn't work yet. I can't remember my IP right now (I'm at work), so I will troubleshoot more tonight or tomorrow.

Hangdog42 12-07-2004 07:55 AM

Quote:

When I try to log on from a node outside of the lan, I get 'Page Cannot Be Displayed
I think the problem is that you've entered the wrong IP address at dynip. The whole 192.168 range of IP addresses are reserved for LAN use and are non-routable. That means on the internet at large, your 192.168.1.102 address is completely meaningless. For your domain name to be useful, it has to use the IP address your ISP assigns you.

I haven't used dynip, but no-ip.com has a similar basic service that is always free. It might be worth a look.

mark001 12-07-2004 08:39 AM

Hi,

I am interested in doing whatshisface does here - setting apache server and host a couple of website.

May I take the opportunity here to ask what is port forward and how can I do it?

I aslo have a router sitting between the dsl modem and my pc.
For all I can tell, there is no where I can do port forward at the routers config page - there is no mentioning about port forward anywhere.

My router isSsurecom EP-4504AX Cable/DSL Gateway Router plus 4-port switch.

Thanks in advance.

mark001

Hangdog42 12-08-2004 08:31 AM

If you understand the concept of a port, then port forwarding is pretty easy. I think originally, back in the stone age of computing, ports were physical beings and to get a computer to do something for you, you had to send the request to the right bit of hardware. With the advent of TCP/IP, ports became logical rather than physical, but the concept is the same. Your server sees lots of TCP/IP packets but has to have a way to figure out what to do with them, and it uses ports as the way of doing this. So if you have an http server and an ftp server running, they have to have a way to tell which packets are to be served by which server. So if a packet comes in destined for port 80, the ftp server knows not to bother with it, but the http server knows that it is now responsible for answering the request.

So the problem comes in with the fact that your router doesn't have the servers, but it holds the IP address that the rest of the world knows about. If your ISP gives you the IP 1.2.3.4, then someone outside your network is going to send their http requests to 1.2.3.4 port 80. The problem is that when that packet arrives at your router, it sees that it is destined for 1.2.3.4, and blindly sends it to port 80. However, your router doesn't have a server listenting at port 80 so effectively the packet is lost. By establishing port forwarding, when that packet arrives and is sent to port 80, there is now a bit of logic that says "Hey, anything headed to port 80 needs to be sent to a different computer". In this case that would be a computer on your LAN that DOES have a server listening to port 80 and knows how to deal with the packet.

How you forward your packets is going to be entirely dependant on your router. Personally, I can't imagine that anyone would sell a router that doesn't have port forwarding capabilities, but you never know. You really need to spend some quality time with the router's documentation and probably the companies web site to find out how to do this.

mark001 12-09-2004 04:50 AM

Hi, Hangdog42.

Thanks for the info on ports.

my router's config has a page like this:

Firewall Setting:
'This feature let your router act as a firewall.'
WEB MANAGEMENT PORT make you be able to change default port number of the Remote Management UI.

Web Management Port: [80].
(I can make change to the port no. 80)

Is the above info about port forward?

If yes, how do I do port forward and to which port it should forward to?

Further info would much be appreciated.

mark001

Hangdog42 12-09-2004 07:53 AM

Actually, without being able to look at your router's screen, I'm not going to be able to tell much. In general, you are looking for a place where, on a port by port basis, you can enter the IP address of the computer you want to act as your server. For example, you want to run a web server off your linux box and that has a LAN address of 192.168.1.50 (by the way, you are definitely going to want to set up your server to have a static IP address on your LAN). Somewhere in your router's software, you should be able to set it so it takes traffic on port 80 and sends it to IP address 192.168.1.50. If the part you posted has a place for you to enter an IP address, then it is likely to be the port forwarding section. If it doesn't, then you'll need to keep looking.

I strongly suggest spending some time with the documentation and company web site. Port forwarding is a pretty standard feature of routers, so somewhere they must have instructions on how to do it. You might even want to drop an email to the manufacturer if you can't find anything at their web site.


Quote:

Firewall Setting:
'This feature let your router act as a firewall.'
WEB MANAGEMENT PORT make you be able to change default port number of the Remote Management UI.

Web Management Port: [80].
(I can make change to the port no. 80)
OK, I'm pretty sure that this part is NOT the port forwarding section. It looks like your router is configured using a web browser and that means that it has its own little web server listenting on port 80 and this allows you to change that port. Personally, I don't see much point in doing that.

Whatshisface 12-11-2004 10:07 AM

I went to canyouseeme.org and found that the port was still closed I wonder if the problem is this:
My router and modem are connected to another machine (192.168.1.100). My server machine(192.168.1.102) is connected to one of the connections of the router. Would I have better chance if the server machine was directly connected with the router? When I did port forwarding I used the 192.168.1.102 address - port 80. Sould I also forward for the other machine's address?

Hangdog42 12-11-2004 03:01 PM

Um, I'm confused by a couple of statements

Quote:

My router and modem are connected to another machine (192.168.1.100)
And
Quote:

My server machine(192.168.1.102) is connected to one of the connections of the router. Would I have better chance if the server machine was directly connected with the router?
From the second statement it sounds like your server is connected directly to the router.

Unless you have a reason not to, your modem should only connect to your router and all of your computers should connect directly to the router. If your 192.168.1.100 machine is between your router and your modem, then yes, that can cause a problem. If you are passing through your .100 machine to get to your server, the .100 machine has to have a way to pass the packets on.

By the way, you really shouldn't post your real IP address. In fact, you should edit it out as soon as you can.


All times are GMT -5. The time now is 04:45 AM.