php 如何从另一台连接在局域网中的计算机访问php页面

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/20652051/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-25 03:22:30  来源:igfitidea点击:

How to access php page from another computer both are connected in LAN

phpapachexampp

提问by user3114172

I created my php page by netbeans ide and xampp server and its running in local web browser as index.php.

我通过 netbeans ide 和 xampp 服务器创建了我的 php 页面,它在本地 Web 浏览器中作为 index.php 运行。

now the problem is i want to access the index.php page by another computer and update mysql database, both are connected in lan.

现在的问题是我想通过另一台计算机访问 index.php 页面并更新 mysql 数据库,两者都在局域网中连接。

回答by Mahmood Rehman

Yes you can access your server from other machine. In that case two issue is possible. 1. If you just need to access from local network 2. If you need to access from internet i.e. from anywhere on earth.

是的,您可以从其他机器访问您的服务器。在这种情况下,两个问题是可能的。1. 如果您只需要从本地网络访问 2. 如果您需要从互联网访问,即从地球上的任何地方访问。

for 2 you would have to have real(public) IP address.

对于 2,您必须拥有真实的(公共)IP 地址。

for 1: you can access only from local network. Local ip address is enough.

对于 1:您只能从本地网络访问。本地ip地址就够了。

in both case you need to make a small change in httpd.conffile.

在这两种情况下,您都需要对httpd.conf文件进行小的更改。

 #your root directory address in full 
<Directory "C:/Program Files/*/www">
 Order allow, deny
 Allow from all
</Directory>

After changing, you need to restart your apache server. then you can access from out side your own machine

更改后,您需要重新启动您的apache服务器。然后你可以从你自己的机器外面访问

回答by Dinesh

Take for example there are 5 PC's connected to Lan. The IP address to all the computer will be as:

以有 5 台 PC 连接到 LAN 为例。所有计算机的 IP 地址将如下所示:

PC 1 have IP Address 192.168.1.2

PC 2 have IP Address 192.168.1.3

PC 3 have IP Address 192.168.1.4

PC 4 have IP Address 192.168.1.5

PC 5 have IP Address 192.168.1.6

now take for example you have installed Apache or IIS in PC 1 which have an IP address of 192.168.1.2, now all the other computer connected to netowrk will be able to access your web directory from the address 192.168.1.2. via a web browser. this will work regardless of what PHP application you are using. it is your Web server which is responsible for routing incoming request not your PHP application :)

现在以您在 PC 1 上安装了 Apache 或 IIS 为例,它们的 IP 地址为 192.168.1.2,现在所有其他连接到 netowrk 的计算机都可以从地址 192.168.1.2 访问您的 Web 目录。通过网络浏览器。无论您使用什么 PHP 应用程序,这都将起作用。负责路由传入请求的是您的 Web 服务器,而不是您的 PHP 应用程序 :)

回答by denismathew

Set an ip address to the PC running xampp server and access the application from other computer through this IP.

为运行xampp服务器的PC设置一个IP地址,并通过该IP从其他计算机访问应用程序。

回答by minas

create a virtual host of the project in the original pc, then on the other pc create a host entry by the ip address of the original pc and the virtual host name of the original pc. This virtual host name can be used in the other pc

在原pc上创建项目的虚拟主机,然后在另一台pc上通过原pc的ip地址和原pc的虚拟主机名创建一个host表项。这个虚拟主机名可以在其他电脑上使用