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.
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?
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?
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.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).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 frompublic_html
to something else, likegitRepo
. In that case, if you have anindex.html
file in/home/ec2-user/gitRepo/index.html
, it will be accessible to the public viahttp://ec2-hostname.aws.amazon.com/~ec2-user/index.html
and be owned by ec2-user, which is convenient for editing files from user level.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:Afterwards you should be good to go but ensure the permissions are set up correctly:
And finally reload the web server like this: