Why do my Virtualhosts point to the root folder.?

Asked

Viewed 129 times

0

I’m using the Apache 2 in the Ubuntu 14.04. I moved the folder www/html to my other partition /media/Dados/www. But that’s not the problem.

The problem starts when setting a vhost to a subdirectory:

Subdirectory: /media/Dados/www/ak-vitrine

Archive on websites-available:

<VirtualHost *:80>
    ServerAdmin webmaster@localhost
    ServerName ak-vitrine.dev
    ServerAlias www.ak-vitrine.dev

    DocumentRoot "/media/Dados/www/AK-Vitrine"

    <Directory "/media/Dados/www/AK-Vitrine">
        Options Indexes FollowSymLinks MultiViews
        AllowOverride All
        Order allow,deny
        Allow from all
    </Directory>
</VirtualHost>

When accessing http://ak-vitrine.dev it shows me the folder list of the root folder /media/Dados/www/. How to solve?

  • 2

    Since I’m no expert on the subject (and I’m still crawling with Linux), try: 1) Give a name to Virtualhost: <VirtualHost akvitrine.localhost:80> 2) Remove the Options. Additionally, if you come to face some Forbiddens (like me) add Require all granted within the <Directtory>. Ah! And remember that *Nix environments are case-sensitive, soon ak-showcase is different from AK-Vitrine

  • Neither the Virtualhost nickname nor removing Options worked =/

  • Solution found, posted the answer :) Thanks for the help Bruno, it was with her that came the idea.

2 answers

1

I came up with the solution myself, after much, much research. First I used the command:

sudo a2dissite 000-default.conf

This disables the default apache virtualhost (usually the one written "Its Works")

With this it was enough to create the virtualhost correctly, paying attention to include the extension . conf in the files of websites-available and sites-enabled. To make it easier I created a bash for creating the virtualhost without error (at least in the same environment).

For this use in the terminal:

sudo gedit /usr/local/bin/addvhost

and paste the contents of http://pastebin.com/pRWCLPc8

Then just run on the terminal sudo addvhosts to add a vhost. It will ask what the project name and directory are, creating the necessary files and re-starting apache.

I hope this information will be useful to someone. :)

0

Possibly the directory is without permission, or as Bruno said, must be problem case sensitive in the name of your directory.

  • Yes, I have case-sensitive in mind. I checked the locations and names, and it’s all right =/

Browser other questions tagged

You are not signed in. Login or sign up in order to post.