【问题标题】:Hosting a php website on an internal local network在内部本地网络上托管 php 网站
【发布时间】:2014-05-17 05:50:16
【问题描述】:

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

【问题讨论】:

    标签: apache networking intranet localserver


    【解决方案1】:

    首先使用路由器连接网络中的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. 服务器电脑到路由器的连接始终使用以太网连接

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

    在路由器中

    1. 登录服务器

    2. 进入 LAN 设置菜单添加静态 IP 10.0.0.2 和服务器 MAC 地址

    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. 宾果游戏

    【讨论】:

      【解决方案2】:

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

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

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

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

      【讨论】:

        猜你喜欢
        • 2011-07-31
        • 1970-01-01
        • 1970-01-01
        • 2016-02-07
        • 1970-01-01
        • 1970-01-01
        • 2019-07-20
        • 1970-01-01
        • 1970-01-01
        相关资源
        最近更新 更多