redhat7.2版本/var/www/html上传静态页面,在自带火狐浏览器里访问不到解决方案

对linux和前端感兴趣的人,都会把自己的项目放到服务器上去玩,希望所有的人都可以访问到,但是,也会有存在访问路径报403或404的错误,那怎么解决呢?其实是对路径访问出错。本期对这个问题来进行说明:

测试环境:虚拟机 VM ware

系统版本:RedHat 7.2 企业版

测试文件目录1:qm,index.html在【注意index.html的位置】

 

测试文件目录2:wsq_homepage【注意index.html的位置】

 

测试文件1:test.html

将这三个测试的文件,都存放在如下所示的目录:(由于博客是后期写的,所以qm文件已被,不影响操作,假设存在于/var/www/html

 在浏览器中访问需要通过命令安装一些服务(yum - y httpd,yum是需要先配置好的)

并关闭selinux:(为permissive表示关闭)

[root@localhost ~]# cd /etc/selinux/
[root@localhost selinux]# ls
[root@localhost selinux]# getenforce
Enforcing
[root@localhost selinux]# setenforce 0
[root@localhost selinux]# getenforce  
Permissive

将80端口添加到防火墙规则:

[root@localhost selinux]# sudo firewall-cmd --query-port=80/tcp
no
[root@localhost selinux]# sudo firewall-cmd --permanent --zone=public --add-port=80/tcp\
> ^C
[root@localhost selinux]# sudo firewall-cmd --permanent --zone=public --add-port=80/tcp
success
[root@localhost selinux]# sudo firewall-cmd --permanent --zone=public --add-port=80/udp
success
[root@localhost selinux]# sudo firewall-cmd --reload
success
[root@localhost selinux]# systemctl status httpd
● httpd.service - The Apache HTTP Server
   Loaded: loaded (/usr/lib/systemd/system/httpd.service; disabled; vendor preset: disabled)
   Active: active (running) since 五 2022-10-21 20:38:25 CST; 10min ago
     Docs: man:httpd(8)
           man:apachectl(8)
 Main PID: 13862 (httpd)
   Status: "Total requests: 6; Current requests/sec: 0; Current traffic:   0 B/sec"
   CGroup: /system.slice/httpd.service
           ├─13862 /usr/sbin/httpd -DFOREGROUND
           ├─13863 /usr/sbin/httpd -DFOREGROUND
           ├─13864 /usr/sbin/httpd -DFOREGROUND
           ├─13865 /usr/sbin/httpd -DFOREGROUND
           ├─13866 /usr/sbin/httpd -DFOREGROUND
           ├─13867 /usr/sbin/httpd -DFOREGROUND
           └─14074 /usr/sbin/httpd -DFOREGROUND

10月 21 20:38:25 localhost.localdomain systemd[1]: Starting The Apache HTTP Server...
10月 21 20:38:25 localhost.localdomain httpd[13862]: AH00558: httpd: Could not reliably determine the server's fully qualified domain name, using localhost.localdomain. Set ...his message
10月 21 20:38:25 localhost.localdomain systemd[1]: Started The Apache HTTP Server.
Hint: Some lines were ellipsized, use -l to show in full.

写index.html:

[root@localhost html]# vi index.html
this is test paga

这时,在redhat自带的火狐浏览器里,访问的地址为:127.0.0.1/index

 如何将自己写的静态网页上传到虚拟机呢?可以用Xshell、SecureCRT等软件,将上面所说的两个网页目录,上传到html下,访问路径:

http://127.0.0.1/test/html/index.html

 

 访问地址:http://127.0.0.1/wsq_homepage/index.html

 

也就是说,在浏览器中访问的是 主机地址+网页文件夹下的index.html ---->127.0.0.1+test(网页的主目录+直到index.html)。那为什么是这样,为什么不加前面的端口的?为什么又不加var/www/,因为httpd启动工作路径在var/www/目录下!

腾讯云服务器免费上传静态页面教程:

免费把自己写的网页上传到网上(腾讯云)_猫猫没有猫耳朵的博客-CSDN博客_腾讯云服务器上传网页

  • 0
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

小白不会debug

需要源码打个赏呗~

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值