这就是我想要实现的目标:从中创建符号链接var/www/html
到主目录中的目录(~
) 文件夹。我试图在 home 中符号链接到的目录(~
) 是一个 git 存储库,如果这有什么区别的话。我在这个目录中有一个index.html 文件。
我使用以下命令在 Amazon EC2 实例上创建了指向 var/www/html 的符号链接:ln -s ~/dirIWant/ html
,但是当我尝试访问我的网页时,这会导致以下错误:403 Forbidden "You don't have permission to access / on this server."
我正在使用阿帕奇。
有其他人尝试过做类似的事情并让它发挥作用吗?
目前,当我访问我的网站 www.blah.com 时,它显示此 403 错误。我尝试使用更改权限sudo chown -h apache:apache
但这似乎没有帮助。你还有其他建议吗?
这是因为 apache 运行为apache用户和/var/www/html
由 Amazon Linux AMI 中的 root 拥有。您可以按照弗兰克的建议更改所有权/权限,或使用userdirs.
在我看来,您希望可以从您的主目录方便地访问网络服务器的文件夹(~
)。我想在我的 EC2 上实现类似的功能,并决定使用每用户 Web 目录 (mod_用户目录).
此功能允许您将 HTTP 服务器的部分空间保留在用户拥有的目录中。每个用户都有自己的目录,默认位于/home/username/public_html
。该目录中的页面、脚本和其他文件可以通过附加/~username
到您的域。此外,您可以在 httpd.conf 中更改该文件夹的名称public_html
到别的东西,比如gitRepo
。在这种情况下,如果您有index.html
文件输入/home/ec2-user/gitRepo/index.html
,公众可以通过http://ec2-hostname.aws.amazon.com/~ec2-user/index.html
属于ec2-user所有,方便用户级别的文件编辑。
要在 EC2 上进行设置(假设您要使用的文件夹名称为“gitRepo”),请使用nano /etc/httpd/conf/httpd.conf
打开 Apache 配置文件并向下滚动,直到看到<IfModule mod_userdir.c>
。然后将此部分更改为如下所示:
<IfModule mod_userdir.c>
#
# UserDir is disabled by default since it can confirm the presence
# of a username on the system (depending on home directory
# permissions).
#
UserDir enabled all
#
# To enable requests to /~user/ to serve the user's public_html
# directory, remove the "UserDir disabled" line above, and uncomment
# the following line instead:
#
UserDir gitRepo
</IfModule>
之后你应该可以开始了,但要确保权限设置正确:
chmod 711 /home/ec2-user
chmod 755 /home/ec2-user/gitRepo
chown -R ec2-user /home/ec2-user/gitRepo
最后重新加载网络服务器,如下所示:
sudo service httpd reload
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)