Ask Your Question
1

httpd virtualhost source in /home

asked 2017-11-12 02:18:50 -0500

oltarus gravatar image

Hi there,

I'm trying to keep the source of my website in my home directory instead of /var/www/html. Something must be missing, though, because it doesn't work.

What I've done so far:

sudo ln -s /home/oltarus/projects/blog /var/www/html/blog

Not working, I checked that httpd.conf hadn't been changed and that Options FollowSymLink was still there for /var/www/html. Everything looked OK! This is not the way I want to do that anyway, please keep reading.

I then tried something better :

Content of "/etc/httpd/conf.d/blog.conf":

<VirtualHost blog.local:80>
        DocumentRoot /home/oltarus/projects/blog
        ServerName blog.local
        <Directory /home/oltarus/projects/blog>
                Options MultiViews Indexes SymLinksIfOwnerMatch IncludesNoExec
                AllowOverride all
        </Directory>
</VirtualHost>

I then added the following line to /etc/hosts:

127.0.0.1   blog.local

I also checked that all the directories (home, oltarus, projects and of course blog) had a o+x right.

After doing all that, and after a service restart, the "Test Page for the Apache HTTP Server on Fedora" is displayed when I type http://blog.local in my browser, instead of my index.php located in /home/oltarus/projects/blog.

Any idea where it went wrong along the line?

NOTE: I don't know if it changes a thing, but other websites are set up the same way on my computer (but still located in /var/www/html for now). They are loaded after, though, because their name comes after "blog" in the alphabetical order.

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted
3

answered 2017-11-12 20:36:07 -0500

aeperezt gravatar image

You need set userdir to work. In order to do that you need to edit /etc/http/conf.d/userdir.conf and comment line with the content UserDir disabled, and uncomment UserDir publichtml you could change that to projects if you like.

You also need to change selinux settings so the public_html folder allow web content access to do so

setsebool -P httpd_enable_homedirs true
chcon -R -t httpd_sys_content_t /home/oltarus/projects

You also need to change your home folder permits to 711 and make sure projects is 755

chmod 711 /home/oltarus
chmod 755 /home/oltarus/projects

Normally people use publichtml if for some reason do not work change projects to publichtml

Good luck

edit flag offensive delete link more

Comments

Excellent, it worked (only if I move it to the public_html, though, but fine for me). Thank you very much.

oltarus gravatar imageoltarus ( 2017-11-14 23:03:12 -0500 )edit

Question Tools

1 follower

Stats

Asked: 2017-11-12 02:18:50 -0500

Seen: 326 times

Last updated: Nov 12 '17