Instalar Apache

sudo apt-get install apache2

Se puede ingresar directamente al sitio a través de la direccion ip desde un navegador.

La ubicación del archivo del sitio se encuentra en por default en:

/var/www/html

Configuración

Antes de comenzar, se debe realizar un respaldo delos sig. archivos:

sudo cp /etc/apache2/sites-available/default-ssl.conf{,.backup}

sudo cp /etc/apache2/sites-available/000-default.conf{,.backup}

CONFIGURACIÓN del HOST Virtual para el dominio.

Editar los archivos 000-default.conf

cd /etc/apache2/sites-available/

nano 000-default.conf

El sitio que se configurara sera yosetcompany.com.

<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
ServerName yosetcompany.com
        DocumentRoot /var/www/html

        #Configuración HTTPS

RewriteEngine On
RewriteCond %{HTTPS} off
RewriteRule (.*) https://%{HTTP_HOST}%{REQUEST_URI}
        # 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>

Creando el enlace para activar el Host Virtual para yosetcompany.com

$ sudo a2ensite 000-default.conf

para desactivar un sitio seria el siguiente comandosudo a2dissite 000-defaul.conf

Configurar el archivo SSL para HTTPS para el dominio.

nano /etc/apache/sites-available/default-ssl.conf
<IfModule mod_ssl.c>
        <VirtualHost _default_:443>
        ServerAdmin webmaster@localhost
               ServerName www.yosetcompany.com:443
                DocumentRoot /var/www/html




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




                #   Enable/Disable SSL for this virtual host.
                SSLEngine on


                SSLCertificateFile      /etc/ssl/certs/ssl-cert-snakeoil.pem
                SSLCertificateKeyFile /etc/ssl/private/ssl-cert-snakeoil.key


                <FilesMatch "\.(cgi|shtml|phtml|php)$">
                                SSLOptions +StdEnvVars
                </FilesMatch>
                <Directory /usr/lib/cgi-bin>
                                SSLOptions +StdEnvVars
                </Directory>



        </VirtualHost>
</IfModule>

Crear el enlace para ssl

a2ensite default-ssl

Activación de modulo ssl para apache, recargándo y reiniciando el servicio de apache.

a2enmod ssl

/etc/init.d/apache2 reload

/etc/init.d/apache2 restart

Crear Certificados

Puede crear su propio certificado solo dando la dirección del propio certificado editando las siguientes lineas del archivo default-ssl.conf y blog-ssl.conf

SSLCertificateFile /home/usuario/micertificado.crt
SSLCertificateKeyFile /home/usuario/micertificado.key

Creando certificado personal:

sudo openssl req -x509 -nodes -days 365 -newkey rsa:2048 -keyout /home/usuario/micertificado.key -out /home/usuario/micertificado.crt

results matching ""

    No results matching ""