Configurar host virtual


10

Actualmente tengo todos mis sitios web como directorios bajo /var/www. Me gustaría configurar un host virtual http://foo/que apunte al /var/www/foo/foodirectorio (y aún así mantener el comportamiento localhost predeterminado).

Agregué el siguiente archivo 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>

Luego ejecuté los siguientes comandos:

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

Pero cuando voy http://foo/, aún me devuelve una página de búsqueda de ISP.

Respuestas:


15

Necesita editar su /etc/hostsarchivo para que se http://fooresuelva en 127.0.0.1.

Edite el archivo /etc/hosts(con sudo / root) y agregue la siguiente línea:

127.0.0.1 foo

1

Pago https://github.com/Aslamkv/vh :)

Esta herramienta le permite agregar y eliminar virtualhost en Ubuntu haciendo todas las configuraciones por usted. Es simple y fácil de usar.

Descargo de responsabilidad: soy el autor: P


0

Para aquellos que usan apache. Necesitaras

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>

A

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

Espero que esto ayude a alguien


¿No deberían directoryser diferentes los 2 bloques?
gion_13

Al usar nuestro sitio, usted reconoce que ha leído y comprende nuestra Política de Cookies y Política de Privacidad.
Licensed under cc by-sa 3.0 with attribution required.