Configurando host virtual

Configurando host virtual

Atualmente tenho todos os meus sites como diretórios em /var/www. Gostaria de configurar um host virtual http://foo/que aponte para o /var/www/foo/foodiretório (e ainda manter o comportamento padrão do host local).

Adicionei o seguinte arquivo, foo, a /etc/apache2/sites-available/:

<VirtualHost *:80>
    ServerName foo
    DocumentRoot /var/www/foo/foo

    # Other directives here
    <Directory />
        Options FollowSymLinks
        AllowOverride None
    </Directory>
    <Directory /var/www/foo/foo>
        Options Indexes FollowSymLinks MultiViews
        AllowOverride None
        Order allow,deny
        allow from all
    </Directory>
</VirtualHost>

Em seguida, executei os seguintes comandos:

sudo a2ensite foo
sudo /etc/init.d/apache2 reload

Mas quando vou até http://foo/ele ainda retorna uma página de pesquisa do ISP.

Responder1

Você precisa editar seu /etc/hostsarquivo para que http://fooseja 127.0.0.1.

Edite o arquivo /etc/hosts(com sudo/root) e adicione a seguinte linha:

127.0.0.1 foo

Responder2

Confirahttps://github.com/Aslamkv/vh:)

Esta ferramenta permite adicionar e remover virtualhost no Ubuntu fazendo todas as configurações para você. É simples e fácil de usar.

Isenção de responsabilidade:Eu sou o autor :P

Responder3

Para quem usa apache. Você vai precisar

Ensure you have .htaccess in root path of the site you are hosting. Example /var/www
Update the /etc/apache2/sites-available/default

De

<Directory /var/www/>
 Options Indexes FollowSymLinks MultiViews
 AllowOverride None
 Order allow,deny
 allow from all
</Directory>

Para

<Directory /var/www/>
 Options Indexes FollowSymLinks MultiViews
 AllowOverride All
 Order allow,deny
 allow from all
</Directory>

Espero que isso ajude alguém

Responder4

informação relacionada