
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/foo
directorio (y aún así mantener el comportamiento predeterminado del host local).
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 lo accedo http://foo/
todavía me devuelve una página de búsqueda de ISP.
Respuesta1
Debe editar su /etc/hosts
archivo para que http://foo
se 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
Si lo deseas, puedes echar un vistazo a la respuesta que he publicado aquí: