accessing my website on local network

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
sweenyman
Forum Commoner
Posts: 29
Joined: Fri Feb 04, 2005 11:28 am
Location: Ireland

accessing my website on local network

Post by sweenyman »

Hi
Up until now I was quite happily using my machine with php/mysql/apache and everything was fine. I accessed my pages as usual with http:// localhost/mywebsite/index.php etc. Now i've networked 2 computers what do I type in the address bar of the new computer to access my old machine with my website. If I use localhost the machine thinks its referring to itself (localhost). The answer is probably staring me in the face but I'm looking the other way :(

Sweenyman
User avatar
BDKR
DevNet Resident
Posts: 1207
Joined: Sat Jun 08, 2002 1:24 pm
Location: Florida
Contact:

Post by BDKR »

What's the IP address of your old machine?
sweenyman
Forum Commoner
Posts: 29
Joined: Fri Feb 04, 2005 11:28 am
Location: Ireland

accessing web pages locally

Post by sweenyman »

BDKR wrote:What's the IP address of your old machine?
Thanks for your prompt reply.

I looked on a website and it told me it was 195.218.107.82

The last 2 numbers seem to change. Where would I find my IP adress on my PC?

Thanks

Sweenyman
User avatar
s.dot
Tranquility In Moderation
Posts: 5001
Joined: Sun Feb 06, 2005 7:18 pm
Location: Indiana

Post by s.dot »

Several IP addresses might work for you..

127.0.0.1 - should be the same as local host
Open a command prompt, type ipconfig, you should see an IP address along with other network settings.
http://www.myipaddress.com/ , this could give you an external IP address to your computer, rather than within your network.

If you're on dial up, your IP address will be dynamic. However if you're on a permanent connection, or one such as cable or DSL, you will have a static IP address.

Also, make sure your router has a port open for viewing webpages (usually port 80)
Set Search Time - A google chrome extension. When you search only results from the past year (or set time period) are displayed. Helps tremendously when using new technologies to avoid outdated results.
sweenyman
Forum Commoner
Posts: 29
Joined: Fri Feb 04, 2005 11:28 am
Location: Ireland

Post by sweenyman »

scrotaye wrote:Several IP addresses might work for you..

127.0.0.1 - should be the same as local host
Open a command prompt, type ipconfig, you should see an IP address along with other network settings.
http://www.myipaddress.com/ , this could give you an external IP address to your computer, rather than within your network.

If you're on dial up, your IP address will be dynamic. However if you're on a permanent connection, or one such as cable or DSL, you will have a static IP address.

Also, make sure your router has a port open for viewing webpages (usually port 80)
Right, I found ip address using ipconfig, thanks for that. So now should I type in the address bar something like.
http://195.126.0.5/localhost/mysite/index.php, where the ip address is that of my old computer where the website lives.

Thanks
Sweenyman
User avatar
BDKR
DevNet Resident
Posts: 1207
Joined: Sat Jun 08, 2002 1:24 pm
Location: Florida
Contact:

Post by BDKR »

Let us know how it worked out.
sweenyman
Forum Commoner
Posts: 29
Joined: Fri Feb 04, 2005 11:28 am
Location: Ireland

Post by sweenyman »

BDKR wrote:Let us know how it worked out.
No. That does not seem to work. Just get cant find page error.
Do you think that the address syntax above is correct? If I was sure that this was the right thing to do then I might look at other things like permissions etc

sweenyman
User avatar
BDKR
DevNet Resident
Posts: 1207
Joined: Sat Jun 08, 2002 1:24 pm
Location: Florida
Contact:

Post by BDKR »

Errr...., are you trying to use ....
? If so, that's not going to work. Take the localhost part out then try.

Cheers
sweenyman
Forum Commoner
Posts: 29
Joined: Fri Feb 04, 2005 11:28 am
Location: Ireland

Post by sweenyman »

BDKR wrote:Errr...., are you trying to use ....
? If so, that's not going to work. Take the localhost part out then try.

Cheers
No doesn't work, the thing is that the new computer that I have networked wouldn't know where my root folder was for serving out the webpages ie wwwroot in the apache folder. On my original machine, it was configured to know that 'localhost' meant C/apache/htdocs or whatever.......or am I getting the "wrong end of the stick"?
I suppose i mean basically that I need the apache web server on my old machine to serve webpages to my new computer.

Hope that makes sense

Thanks
Sweenyman
User avatar
BDKR
DevNet Resident
Posts: 1207
Joined: Sat Jun 08, 2002 1:24 pm
Location: Florida
Contact:

Post by BDKR »

sweenyman wrote: I suppose i mean basically that I need the apache web server on my old machine to serve webpages to my new computer.

Hope that makes sense
Wow! You're a hardcore Apache noob! :lol:

Normally Apache will serve pages to any computer that hits it at the right IP address and port. Let's just forget all about ports
for the time being. If your old machine with the Apache server is at 192.168.0.X, then any machine on the same network should
have access to your old machine via it's IP address. That said, it doesn't matter what your document root is ( c:/apache/htdocs
as an example ). All that's needed by any other computer is the correct IP address.
sweenyman wrote: On my original machine, it was configured to know that 'localhost' meant C/apache/htdocs or whatever.......
Actually, it was configured to know that localhost was the same thing as your IP address. Localhost does not refer to the document
root of a web server. Localhost refers to 127.0.0.1.

What is the IP address of your new computer?
127.0.0.1
Forum Newbie
Posts: 22
Joined: Mon Sep 12, 2005 8:59 pm

Post by 127.0.0.1 »

Could be a router issue.

Do you have nat enabled?

can you ping from and to between the two pc's?
User avatar
John Cartwright
Site Admin
Posts: 11470
Joined: Tue Dec 23, 2003 2:10 am
Location: Toronto
Contact:

Post by John Cartwright »

or a firewall issue
timvw
DevNet Master
Posts: 4897
Joined: Mon Jan 19, 2004 11:11 pm
Location: Leuven, Belgium

Post by timvw »

A couple of important settings in my httpd.conf

Code: Select all

Listen 80

LoadModule php5_module "C:/Program Files/php-5.0.5-Win32/php5apache2.dll"
PHPIniDir "C:/Program Files/php-5.0.5-Win32/"
AddType application/x-httpd-php .php

ServerName localhost:80
UseCanonicalName Off


NameVirtualhost *:80

<VirtualHost *:80>
  ServerName localhost
  DocumentRoot "F:/websites/localhost"
  <Directory "F:/websites/localhost">
    AllowOverride All
    Options All
  </Directory>
</Virtualhost>

<VirtualHost *:80>
  ServerName test
  DocumentRoot "F:/websites/test"
  <Directory "F:/websites/test">
    AllowOverride All
    Options All
  </Directory>
</Virtualhost>
Now, if i have on a different machine the following in my c:/windows/system32/drivers/etc/hosts i can surf to http://test from there...

Code: Select all

192.168.1.11        test
sweenyman
Forum Commoner
Posts: 29
Joined: Fri Feb 04, 2005 11:28 am
Location: Ireland

Post by sweenyman »

Jcart wrote:or a firewall issue
Phew!

Yip it was a firewall problem. I had to allow Apache as an exception in the "exceptions tab" of the firewall.
Thank for all the help

Sweenyman
Post Reply