0% found this document useful (0 votes)
46 views4 pages

Configuracion de Virtual Host Apache

The document describes the 5 steps to create a virtual host in Apache: 1. Create directories to host the website files 2. Create a virtual host configuration file and edit it to point to the new directories 3. Open the necessary port in the Apache ports configuration file 4. Enable the new virtual host 5. Test that the virtual host is working

Uploaded by

auxiliarredes2
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
46 views4 pages

Configuracion de Virtual Host Apache

The document describes the 5 steps to create a virtual host in Apache: 1. Create directories to host the website files 2. Create a virtual host configuration file and edit it to point to the new directories 3. Open the necessary port in the Apache ports configuration file 4. Enable the new virtual host 5. Test that the virtual host is working

Uploaded by

auxiliarredes2
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 4

Crear un Virtual Host

Como primer paso creamos el directorio que alojara nuestra web.

Para crear un directorio usaremos el comando mkdir, como se muestra a


continuación en donde creamos el directorio bitácora.es/public donde alojaremos
los archivos de la aplicación web.

cd /var/www
sudo mkdir bitacora.es
cd bitacora.es
sudo mkdir public

como paso dos creamos el archivo de configuración del nuevo virtual host

como este archivo ya existe lo que haremos será copiar el archivo y editarlo.

cd /etc/apache2/sites-available
sudo cp 000-default.conf bitacora.es.conf

Lo editamos:

sudo nano bitacora.es.conf

Inicialmente tenemos algo así:

<VirtualHost *:80>

# The ServerName directive sets the request scheme, hostname and port
that

# the server uses to identify itself. This is used when creating

# redirection URLs. In the context of virtual hosts, the ServerName

# specifies what hostname must appear in the request's Host: header to

# match this virtual host. For the default virtual host (this file) this

# value is not decisive as it is used as a last resort host regardless.

# However, you must set it for any further virtual host explicitly.
#ServerName www.example.com

ServerAdmin webmaster@localhost

DocumentRoot /var/www/html

# Available loglevels: trace8, ..., trace1, debug, info, notice, warn,

# error, crit, alert, emerg.

# It is also possible to configure the loglevel for particular

# modules, e.g.

#LogLevel info ssl:warn

ErrorLog ${APACHE_LOG_DIR}/error.log

CustomLog ${APACHE_LOG_DIR}/access.log combined

# For most configuration files from conf-available/, which are

# enabled or disabled at a global level, it is possible to

# include a line for only one particular virtual host. For example the

# following line enables the CGI configuration for this host only

# after it has been globally disabled with "a2disconf".

#Include conf-available/serve-cgi-bin.conf

</VirtualHost>

Y tras modificarlo debe quedar así:

<VirtualHost *:8081>
# The ServerName directive sets the request scheme, hostname and port
that
# the server uses to identify itself. This is used when creating
# redirection URLs. In the context of virtual hosts, the ServerName
# specifies what hostname must appear in the request's Host: header to
# match this virtual host. For the default virtual host (this file) this
# value is not decisive as it is used as a last resort host regardless.
# However, you must set it for any further virtual host explicitly.
#ServerName www.example.com

ServerAdmin webmaster@localhost
DocumentRoot /var/www/bitacora.es/public

# Available loglevels: trace8, ..., trace1, debug, info, notice, warn,


# error, crit, alert, emerg.
# It is also possible to configure the loglevel for particular
# modules, e.g.
#LogLevel info ssl:warn

ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined

# For most configuration files from conf-available/, which are


# enabled or disabled at a global level, it is possible to
# include a line for only one particular virtual host. For example the
# following line enables the CGI configuration for this host only
# after it has been globally disabled with "a2disconf".
#Include conf-available/serve-cgi-bin.conf

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

</VirtualHost>

Como podemos ver en la línea 1 hemos cambiado :80 por :8081, con lo que estamos
indicando que a este virtual host accederemos mediante este puerto.

En la línea 12 lo único que hemos hecho es actualizar la referencia al directorio raíz


para asegurarnos que apunta al lugar adecuado.

Y por último hemos añadido una nueva sección a partir de la línea 30 con unas
directrices básicas entre las que hemos habilitado el módulo mod_rewrite, necesario
para la re-escritura de urls.

Como paso tres abrimos el puerto adecuado en apache

Para conseguir que apache atienda las solicitudes que llegan por el puerto 8081,
que es el que hemos indicado en nuestro fichero de configuración del virtual host,
debemos editar el archivo /etc/apache2/ports.conf.

sudo nano /etc/apache2/ports.conf

El contenido del fichero es algo así:


# If you just change the port or add more ports here, you will likely
also
# have to change the VirtualHost statement in
# /etc/apache2/sites-enabled/000-default.conf

Listen 80
Listen 8081

<IfModule ssl_module>
Listen 443
</IfModule>

<IfModule mod_gnutls>
Listen 443
</IfModule>

Como podemos ver en la línea 5 hace referencia al puerto 80, para que pueda
escuchar por el puerto 8081 hemos añadido en la línea 6 el puerto 8081 indicándole
que de igual manera escuche por este puerto.

Como paso cuatro habilitamos el nuevo host virtual

Ahora lo que debemos hacer es crear un enlace simbólico, para crear el enlace
simbólico lo haremos con el comando a2ensite

sudo a2ensite bitacora.es.conf

Ya hemos creado el enlacé simbólico en el directorio sites-enabled, ahora solo nos


queda reiniciar apache:

sudo service apache2 restart

Como paso cinco, comprobaremos que todo funcione correctamente.

Para comprobar que todo funciona correctamente lo haremos con solo dos sencillos
pasos.

1. Creamos un archivo index.html y lo guardamos en el directorio público del


host virtual que acabamos de crear, en este caso
/var/www/bitacora.es/public.

2. Accedemos a la ip del servidor seguida de dos puntos y el puerto:


http://192.168.1.10:8081/index.html.

Si vemos el contenido del archivo index.html es que todo ha salido bien, en caso
contrario deberemos buscar el problema en función del mensaje de error obtenido.

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy