1

我有四台 Windows PC 无线连接到本地网络,我想在服务器上托管我的 PHP 网站,以便所有连接到服务器的 PC 都可以通过 IP 地址访问 Web 应用程序。

4

2 回答 2

2

首先使用路由器连接网络中的PC。

这是图表

                _____________
                |   Router  |  Router IP 10.0.0.2
                |           |
                -------------
                 ;   ;   ;   ;
                ;     ;   ;     ;      
               ;       ;    ;       ;     
              ;        ;      ;         ;   
             ;         ;         ;           ;   
            ;           ;            ;            ;  
           ;             ;              ;                ;   
_____________       _____________      ______________     ___________
|   PC 1    |       |   PC 2    |      |    PC 3    |     | PC 4    |
|           |       |           |      |            |     |         |
-------------       -------------      --------------     -----------
IP 10.0.0.2         IP 10.0.0.3        IP 10.0.0.4         IP 10.0.0.5

Server PC           Client PC          Client PC           Client PC  

This IP should
always be
static

下面的步骤

  1. 始终使用以太网连接进行服务器 PC 到路由器的连接

  2. 获取服务器PC的MAC地址

在路由器中

  1. 登录服务器

  2. 转到 LAN 设置菜单添加带有服务器 MAC 地址的静态 IP 10.0.0.2

  3. 转到端口转发菜单并将端口 80 和 8080 转发到 IP 10.0.0.2

在服务器 PC

  1. 为 PHP 主机安装 apache 服务器

  2. 转到 httpd.conf 文件并找到代码

    AllowOverride All
    
    #
    # Controls who can get stuff from this server.
    #
    # Require all granted
    # onlineoffline tag - don't remove
     Order Deny,Allow
     Deny from all
     Allow from 127.0.0.1
     Allow from ::1
     Allow from localhost
    

Allow from localhost在下面的“ ”之后添加此代码

Allow from 10.0.0.2
Allow from 10.0.0.3
Allow from 10.0.0.4
Allow from 10.0.0.5

您可以增加客户端PC并将IP添加到服务器httpd.conf文件中

现在是庆祝的时候了

  1. 打开客户端 PC 浏览器
  2. 在浏览器的地址栏中输入url http://10.0.0.2/然后回车
  3. 等一段时间
  4. 答对了
于 2015-04-17T07:17:42.370 回答
0

在本地网络或外部服务器上托管您的服务器没有太大区别,这一切都归结为以下一般步骤:

  1. 安装您的网络服务器,例如 Apache 并确保它的php扩展名处于活动状态(默认)

  2. 确保您的网络服务器绑定到正确的 IP(例如 192.168.1.xx 或 0.0.0.0 可从网络外部访问)

  3. 确保防火墙(服务器和客户端)允许通信(IP 和端口)

于 2014-05-17T05:59:05.597 回答