问题
I'm developing a CodeIgniter app on Win 7, using WampServer v2.0 - I've edited my local HOSTS file so that I can access it here: ht_tp://testdomain/ instead of ht_tp://localhost/testdomain/ to help make it work the same locally as it does when deployed live, with a line like this: 127.0.0.1 testdomain
This set up is working fine when I access the pages in browser on the same PC.
Now I'm developing some new pages for mobile use, e.g. iPhone, and I want to be able to view my site directly on the iPhone. The phone is connected to the LAN, and I've opened up port 80 on the PC.
I want to be able to go to ht_tp://testdomain/ on the iphone, but it tells me it can't find the server.
// edit - an extra part I need is that I need to be able to run more than one site on my localhost at the same time, and they all work from the root - this is why I wanted to use testdomain/.
I'm not sure what to Google for now, can someone help me out?
Thanks, Dan
(ht_tp means http in case that wasn't obvious)
回答1:
ok this is how we've worked it out here and it's working fine for my requirements. In a nutshell it's open up port 80 for private requests, and config apache to handle the requests. Each site gets its own IP address within the LAN. Then the iPhone, and other computers, can access the webpages hosted by your computer. If you're running Apache on a port other than 80, use that number instead.
To open up Port 80 on Windows 7
Go to Control Panel -> System and Security -> Windows Firewall Open up Advanced Configuration and open Inbound Rules, create a New Rule. Choose Port, click Next, choose TCP and enter 80 as the port, click Next. Choose "Allow the connection" and click Next. Check the Private box only, clear the Domain and Public ones. Click Next. Give it a name and a description, here I added a note that I'd made this rule to help remind me what it was for in the future. Ok all of that and exit the window.
What's my LAN IP address?
Now you need to know what the IP is of your hosting computer, and it needs to be static. This depends on your router I understand, so check in your router admin if you need to. To get your IP address open Command Line, type
ipconfig /all
scroll back up through the output and find the line showing Address IPv4 - this should state your LAN IP address, e.g. 192.168.2.100 - make a note of it, close the Command window.
Assign Multiple IP addresses to your host PC
You need to do this to be able to run more than one website from the root, each site will have its own IP address on the LAN. Open Network and Sharing Centre, you'll see a link to Local Area Connection next to your active network, click that link, and click on Properties in the popup. Click the item "Internet Protocol Version 4 (TCP/IPv4)", and then Properties. Now choose the option "Use the following IP address:" and enter your IP, e.g. 192.168.2.100. Leave the default subnet mask, and then enter the IP of your router on the LAN, mine was 192.168.2.1. Also add that IP for the Preferred DNS Server in the table below.
Click on "Advanced...". Now you enter your IP address again in this table, and also add the other IP addresses you want to use to host your sites. They must be vacant IPs on your LAN. I just needed one more IP, and there are only 2 PCs and one iPhone using my network so I just added 10 to the IP, 192.168.2.100 and 192.168.2.110. Make a note of the IPs you set up. Click OK and save all the way out of those popups.
Configure Apache
Now Apache needs to know what to do with these IP addresses, so find the httpd.conf file first, mine was here:
C:\wamp\bin\apache\Apache2.2.11\conf\httpd.conf
Find the line:
Listen 80
and change it to add your IP addresses with the port:
Listen 192.168.2.100:80
Listen 192.168.2.110:80
Further down in this file you need to configure the access to the directories that host your sites, like this:
<Directory "c:/wamp/www/test_website_aaaaaa/">
allow from all
</Directory>
<Directory "c:/wamp/www/test_website_bbbbbb/">
allow from all
</Directory>
Save and close the file. Now find the httpd-vhosts.conf file, mine was here:
C:\wamp\bin\apache\Apache2.2.11\conf\extra\httpd-vhosts.conf
Here you need to add VirtualHost directives to point the IP address at your folders, like this:
<VirtualHost 192.168.2.110:80>
DocumentRoot "C:/wamp/www/test_website_aaaaaa"
</VirtualHost>
<VirtualHost 192.168.2.110:80>
DocumentRoot "C:/wamp/www/test_website_bbbbbb"
</VirtualHost>
Save and close the file, and restart Apache.
You should now be able to access those sites on your iPhone via the IPs, e.g. http://192.168.2.110
回答2:
well same was the problem with me , now sloved. what u have to do is to go in apache and then httpd.confg. set the port to 8080 and allow all acess to " allow form all" every where and then go to ipconfig in comnd prompt and see ip form there and give the same ip in ur mobile browser which is followed by a colon and port exmple" 192.168.0.2:8080/exmple.php" and u can access ur php page in ur mobile.
回答3:
Wamp > Apache > httpd.conf
Change the line
Deny from all
to
Allow from all
回答4:
There are a few solutions for that problem to be found here.
回答5:
On your iPad go to you wifi settings and turn Off your http proxy. It worked for me
来源:https://stackoverflow.com/questions/6695785/setting-up-wamp-to-run-on-lan-including-mobile-access-iphone