尝试使用VAR符号链接/ www / html等 [英] Attempting to use symbolic link for var/www/html
问题描述
这就是我要完成的:创建符号链接,从无功/ www / html等
来一个目录在家里(〜
)的文件夹。我想符号链接到在家里(〜
)的目录是一个Git仓库,如果有什么差别。我有这个目录中的index.html文件。
this is what I'm trying to accomplish: creating symbolic link from var/www/html
to a directory in the home (~
) folder. the directory I'm trying to symlink to in home (~
) is a git repository, if that makes any difference. I have an index.html file in this directory.
我已经创建了使用此命令无功/ www / html等的符号链接在Amazon EC2实例: LN -s〜/ dirIWant / HTML
,然而这导致以下错误,当我尝试访问我的网页: 403禁止您没有权限访问/在此服务器上
我使用的Apache
I've created a symbolic link to var/www/html on an Amazon EC2 instance using this command: ln -s ~/dirIWant/ html
, however this is resulting in the following error when I try to access my webpage: 403 Forbidden "You don't have permission to access / on this server."
I'm using apache.
有其他人试图做类似的事情,并得到它的工作?
Has anybody else tried to do something similar and gotten it to work?
目前,当我去我的网站www.blah.com,它显示了这个403错误。我试图改变使用须藤CHOWN -h的Apache许可:阿帕奇
,但它似乎并没有帮助。你有什么其他的想法?
Currently, when I go to my website www.blah.com, it shows this 403 error. I've tried to change the permission using sudo chown -h apache:apache
but it doesn't seem to help. Do you have any other ideas?
推荐答案
这是因为Apache作为运行的的Apache 的用户和的/ var / www / html等
是由根在亚马逊的Linux AMI拥有。所建议的弗兰克·您可以更改所有权/权限,或使用 userdirs
This is because apache runs as apache user and the /var/www/html
is owned by root in Amazon Linux AMI. You can change ownership/permissions as suggested by Frank, or use userdirs.
在我看来,你想要的web服务器的文件夹,从你的主目录方便到达(〜 <$ C C $>)。我想这样的事情在我的EC2和决定使用的每个用户的网页目录的(的 mod_userdir )。
It seems to me that you want the webserver's folder to be conveniently accessible from your home directory (~
). I wanted something like this on my EC2 and decided to use Per-user web directories (mod_userdir).
这个功能可以让你保持HTTP服务器的空间部分由一个用户所拥有的目录。每个用户得到他自己的目录,默认情况下位于 /家庭/用户名/的public_html
。该网页,脚本和其他文件,在该目录中都可以访问互联网通过追加 /〜用户名
到您的域。此外,还可以从的public_html
更改该文件夹中的httpd.conf的名称别的东西,像 gitRepo
。在这种情况下,如果你有一个 index.html的
文件 /home/ec2-user/gitRepo/index.html
,它会通过 http://ec2-hostname.aws.amazon.com/~ec2-user/index.html
和EC2所拥有-user,这便于从用户级编辑的文件。
This feature of lets you keep parts of the HTTP server's space in a directory owned by a user. Each user gets his own directory, located by default in /home/username/public_html
. The pages, scripts and other files in that directory are accessible to the internet by appending /~username
to your domain. Additionally, you can change the name of that folder in httpd.conf from public_html
to something else, like gitRepo
. In that case, if you have an index.html
file in /home/ec2-user/gitRepo/index.html
, it will be accessible to the public via http://ec2-hostname.aws.amazon.com/~ec2-user/index.html
and be owned by ec2-user, which is convenient for editing files from user level.
要在EC2上(假设gitRepo为您想使用的文件夹名称)进行设置,应使用纳米/etc/httpd/conf/httpd.conf中
来打开Apache的配置文件,然后向下滚动,直到看到&LT; IfModule mod_userdir.c&GT;
。然后改变这部分如下所示:
To set this up on EC2 (assuming "gitRepo" for the folder name you want to use), use nano /etc/httpd/conf/httpd.conf
to open Apache config file and scroll down until you see <IfModule mod_userdir.c>
. Then change this section to look like the following:
<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>
之后,你应该是好去,但确保权限设置是正确的:
Afterwards you should be good to go but ensure the permissions are set up correctly:
chmod 711 /home/ec2-user
chmod 755 /home/ec2-user/gitRepo
chown -R ec2-user /home/ec2-user/gitRepo
最后重新加载web服务器这样的:
And finally reload the web server like this:
sudo service httpd reload
这篇关于尝试使用VAR符号链接/ www / html等的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!