Configurar un servidor virtual

Configurar un servidor virtual

Actualmente tengo todos mis sitios web como directorios en /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 predeterminado del host local).

Agregué el siguiente archivo, fooa /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 lo accedo http://foo/todavía me devuelve una página de búsqueda de ISP.

Respuesta1

Debe editar su /etc/hostsarchivo para que http://foose resuelva en 127.0.0.1.

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

127.0.0.1 foo

Respuesta2

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

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

Descargo de responsabilidad:Yo soy el autor :P

Respuesta3

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

Respuesta4

información relacionada