客户端没有权限打开/下载apache服务器上的文件

Forbidden
You don’t have permission to access /my.pdf on this server.

参考网站:

https://unix.stackexchange.com/questions/225942/one-of-my-pdf-files-in-my-apache-server-can-be-accessed-the-other-cant-with-th?answertab=votes#tab-top
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
1. 配置Apache服务器 在CentOS 7上安装Apache服务器并启动后,可以通过以下步骤配置Apache服务器,使客户端可以通过 http://abc259.com/ 访问: 1)在终端中使用以下命令打开Apache的全局配置文件: ``` sudo vi /etc/httpd/conf/httpd.conf ``` 2)找到以下行并将其取消注释(去掉前面的#): ``` #ServerName www.example.com:80 ``` 将其修改为: ``` ServerName abc259.com:80 ``` 3)在文件末尾添加以下内容: ``` <VirtualHost *:80> ServerAdmin webmaster@abc259.com DocumentRoot /var/www/html ServerName abc259.com ErrorLog /var/log/httpd/abc259.com-error_log CustomLog /var/log/httpd/abc259.com-access_log common </VirtualHost> ``` 4)保存并关闭文件。 5)重启Apache服务器: ``` sudo systemctl restart httpd ``` 现在,客户端就可以通过输入 http://abc259.com/ 来访问您的网站了。 2. 配置个人主页 如果您想要实现客户端通过输入 http://abc259.com/~abc259 来访问个人主页,可以按照以下步骤进行配置: 1)在终端中使用以下命令创建一个名为“public_html”的目录: ``` mkdir ~/public_html ``` 2)在“public_html”目录中创建一个名为“index.html”的文件: ``` vi ~/public_html/index.html ``` 3)在文件中输入以下内容: ``` <html> <head> <title>My Personal Homepage</title> </head> <body> <h1>Welcome to My Personal Homepage!</h1> </body> </html> ``` 4)保存并关闭文件。 5)在终端中使用以下命令修改文件和目录的权限: ``` chmod 755 ~ chmod 755 ~/public_html chmod 644 ~/public_html/index.html ``` 6)在Apache的全局配置文件中添加以下内容: ``` <Directory /home/abc259/public_html> Options Indexes FollowSymLinks AllowOverride All Require all granted </Directory> ``` 7)保存并关闭文件。 8)重启Apache服务器: ``` sudo systemctl restart httpd ``` 现在,客户端就可以通过输入 http://abc259.com/~abc259 来访问您的个人主页了。

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值