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. 备注
如果有什么问题,多多指教,谢谢。