zoukankan      html  css  js  c++  java
  • 问题:手机访问不了同一个局域网内的电脑上的网站 (已解决)

    1. 问题具体描述

      我在centos7下搭建好了appache服务器,然后写好了后台程序以及前端网页,现在想用我的笔记本建立一个热点,然后用我的手机连接并访问我的网站。 我尝试了下,发现要么是找不到网页,要么是访问人数过多或无法访问(但在我的电脑上可以访问我的网站)。       心很凉~

    2. 期间使用的工具

      系统是centos7, 服务器是appache, 用的是C写了CGI后台程序,用HTML5写了前端网页。

    3. 如何能访问的?

      我考虑到防火墙是不是禁止了外界对我的网站的访问, 后来百度下,找到了解决办法。

      切换root模式,输入shell指令:  firewall-cmd --permanent --add-service=http (意思是 防火墙永久开放http服务)

      然后,重启firewall-cmd:   firewall-cmd --reload

      另外,下面是我httpd.conf的配置,主要是三部分,一个是设置我的wifi热点的监听(毕竟要把我的电脑作为服务器),一个是把/var/www/html开放出来,还有一个是/var/www/cgi-bin,

    因为我要访问我的网页和后台程序。

     部分1

    #
    # Listen: Allows you to bind Apache to specific IP addresses and/or
    # ports, instead of the default. See also the <VirtualHost>
    # directive.
    #
    # Change this to Listen on specific IP addresses as shown below to
    # prevent Apache from glomming onto all bound IP addresses.
    #
    #Listen 12.34.56.78:80
    Listen 10.42.0.1:80   #让服务器监听IP是10.42.0.1,网站的端口80,这个IP是我的wifi模块的IP

       部分2

    # Further relax access to the default document root:
    <Directory "/var/www/html">
        #
        # Possible values for the Options directive are "None", "All",
        # or any combination of:
        #   Indexes Includes FollowSymLinks SymLinksifOwnerMatch ExecCGI MultiViews
        #
        # Note that "MultiViews" must be named *explicitly* --- "Options All"
        # doesn't give it to you.
        #
        # The Options directive is both complicated and important.  Please see
        # http://httpd.apache.org/docs/2.4/mod/core.html#options
        # for more information.
        #
        Options Indexes FollowSymLinks
    
        #
        # AllowOverride controls what directives may be placed in .htaccess files.
        # It can be "All", "None", or any combination of the keywords:
        #   Options FileInfo AuthConfig Limit
        #
        AllowOverride None
        Order allow,deny
     
        #
        # Controls who can get stuff from this server.
        #
        # Require all granted
        Allow from all
    </Directory>

    部分3

    #
    # "/var/www/cgi-bin" should be changed to whatever your ScriptAliased
    # CGI directory exists, if you have that configured.
    #
    <Directory "/var/www/cgi-bin">
        AllowOverride None
        Options ExecCGI   #执行CGI
        Order allow,deny
        Allow from all
        AddHandler default-handler .css
    </Directory>

    更改配置后,重启appache服务器: systemctl restart httpd

    4. 备注

      如果有什么问题,多多指教,谢谢。

  • 相关阅读:
    创建smartfroms页格式
    常用TCODE
    CALL transaction 的用法-传内表
    POPUP_TO_CONFIRM的使用方法
    PARAMETERS 指令
    常用弹出对话框函数
    alv界面透视功能
    解决org.apache.ibatis.binding.BindingException: Invalid bound statement (not found)问题
    Error:java: Annotation processing is not supported for module cycles.
    pom配置进行版本号统一管理
  • 原文地址:https://www.cnblogs.com/the-one/p/6664604.html
Copyright © 2011-2022 走看看