Necesitaremos instalar un servidor web el cual nos sirva para acezar a Phamm vía web, hemos elegido a httpd (apache2) lo instalaremos con soporte para PHP y SSL para conexiones seguras.
# emerge -pv apache These are the packages that I would merge, in order: Calculating dependencies ...done! [ebuild R ] net-www/apache-2.0.54-r31 +apache2 -debug -doc +ldap -mpm-leader -mpm-peruser -mpm-prefork -mpm-threadpool -mpm-worker -no-suexec (-selinux) +ssl -static-modules -threads 0 kB
Como vemos ya están configuradas las USE flags con soporte para LDAP (+ldap), y SSL (+ssl). Entonces lo instalaremos de manera normal:
# emerge apache
Por default apache no tiene activados los módulos para SSL aunque fue inicialmente instalado con soporte SSL. Antes que nada instalaremos el modulo de PHP para apache.
# emerge -pv mod_php These are the packages that I would merge, in order: Calculating dependencies ...done! [ebuild R ] dev-php/mod_php-4.4.0-r9 -X +apache2 -berkdb +crypt -curl -debug -doc -fdftk -firebird -flash -freetds +gd -gd-external +gdbm -gmp +hardenedphp +imap -informix +ipv6 -java +jpeg -kerberos +ldap -mcal -memlimit -mssql -mysql +nls -oci8 -odbc +pam +png -postgres -snmp -spell +ssl -tiff +truetype +xml2 -yaz 0 kB
Esas dependencias son suficientes, ahora lo instalaremos:
# USE="mysql" emerge mod_php
Ahora configuraremos los archivos para que sean cargados los módulos de PHP y SSL. El archivo donde se configura esto en Gentoo GNU/Linux es: /etc/conf.d/apache2
# vim /etc/conf.d/apache2 APACHE2_OPTS="-D DEFAULT_VHOST -D SSL -D SSL_DEFAULT_VHOST -D PHP4"
Con esta linea agregamos soporte para el default virtual host, soporte SSL, soporte SSL para el default virtual host y soporte PHP4. Ahora iniciar el servicio apache2 así:
# /etc/init.d/apache2 start
Para que el servicio de apache2 sea iniciado al arranque del sistema ejecutar el siguiente comando:
# rc-update add apache2 default
Este articulo ayudara a configurar apache2 para uso de certificados x509 (SSL) para comunicacion segura (cifrada) usando certificados expedidos por CAcert. Requerimientos: Tener instalado apache con soporte SSL Debes de tener una cuenta creada en cacert.org Primero generar nuestra llave privada con la que firmaremos nuestra solicitud de certificado. La nombraremos con nuestro nombre de host a el que le asignaremos el certificado, por ejemplo: www.calcom.com.mx
# cd /etc/apache2/ssl
# openssl genrsa -out www.calcom.com.mx.key 1024 Generating RSA private key, 1024 bit long modulus ...................++++++ .............................++++++ e is 65537 (0x10001)
Ahora generaremos la solicitud de certificado con nuestra llave privada:
# openssl req -new -key www.calcom.com.mx.key -out www.calcom.com.mx.csr You are about to be asked to enter information that will be incorporated into your certificate request. What you are about to enter is what is called a Distinguished Name or a DN. There are quite a few fields but you can leave some blank For some fields there will be a default value, If you enter '.', the field will be left blank. ----- Country Name (2 letter code) [AU]:MX State or Province Name (full name) [Some-State]:Baja California Locality Name (eg, city) []:Tijuana Organization Name (eg, company) [Internet Widgits Pty Ltd]:Calcom de Mexico S.A. de C.V. Organizational Unit Name (eg, section) []:Hosting Common Name (eg, YOUR name) []:www.calcom.com.mx Email Address []:jmedina@calcom.com.mx Please enter the following 'extra' attributes to be sent with your certificate request A challenge password []: An optional company name []:
Acabamos de generar la solicitud de certificado y se guardo en el archivo: /etc/apache2/ssl/www.calcom.com.mx.csr Veamos el contenido:
# cat www.calcom.com.mx.csr -----BEGIN CERTIFICATE REQUEST----- MIIB9jCCAV8CAQAwgbUxCzAJBgasj3dmdk1YMRgwFgYDVQQIEw9CYWphIENhbGlm b3JuaWExEDAOBgNVBAcTB1RpanVhbmExJasdfasdfAoTHUNhbGNvbSBkZSBNZXhp Y28gUy5BLiBkZSBDLlYuMRAwDgYDVQQLEwdIb3N0aW5nMRowGAYDVQQDExF3d3cu Y2FsY29aasd3bS5teDEkMCIGCSqGSIb3DQEJARYVam1lZGluYUBjYWxjb20uY29t Lm14MIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQDGJBAR4lRhch4l92exwzHH X+HQuX1NIJU4nkF46SCWvgQIP36Qs2XgOkTJKSf9Rasdasdfae33P6QHCozdjqq+ LTcF1H6f5z+L7K2TZx5eVje03jkdindcnMAUnR5EYl9QfdXGdGLFR3IWXIcPA9mB s1asd3djHhgUVF1PGk0FawIDAQABoAAwDQYJKoZIhvcNAQEEBQADgYEAB3PX3qOI GadYTXuRxx34Vbol2w5jWXuyHtlbwqPlnY6M00PyWpfcGNPppeQV23232qocgHcl UwADN20b3//89yMeoqEzNy1RPjyNrzSufPml6Mx+RrTBypnmTlDUb2WTThrnzUNl Ok+azrk1BRYu2gYLEFNif56OaHnXjV3vR0Q= -----END CERTIFICATE REQUEST-----
Ahora copiaremos desde el inicio de la linea:
-----BEGIN CERTIFICATE REQUEST----- Hasta la linea final: -----END CERTIFICATE REQUEST-----
Entonces iniciaremos sesion en cacert.org y crearemos un nuevo certificado para servidor (Server Certificates) y el contenido de el CSR lo pegaremos en la pagina de creacion de certificados para que nos devuelba un certificado, el resultado que nos muestre lo pegaremos en un archivo llamado con el nombre de el host y con terminacion .crt (La terminacion no es obligatoria pero si es util para reconocer los tipos de archivos).
# vim www.calcom.com.mx.crt -----BEGIN CERTIFICATE----- MIIEFzdopemeAwIBAgIDAdBFMA0GCSqGSIb3DQEBBQUAMHkxEDAOBgNVBAoTB1Jv b3QgQ0ExHjAcBgNVBAsTFWh0dHA6Ly93d3cuY2FjZXJ0Lm9yZzEiMCAGA1UEAxMZ Q0EgQ2VydCBTaWduaW5nIEF1dGhvcml0eTEhMB8GCSqGSIb3DQEJARYSc3VwcG9y dEBjYWNlcnQub3JnMB4XDTA2MDExMjIxNTAxNloXDTA2MDcxMTIxNTAxNlowHDEa MBgGA1UEAxMRd3d3LmNhbGNvbS5jb20ubXgwgZ8wDQYJKoZIhvcNAQEBBQADgY0A MIGJAoGBAMYkEBHiVGFyHiX3Z7HDMcdf4dC5fU0glTieQXjpIJa+BAg/fpCzZeA6 RMkpJ/1HQOzpsdfasdfasdfKjN2Oqr4tNwXUfp/nP4vsrZNnHl5WPTNSEIZoWbyc wBSdHkRiX1B91cZ0YsVHchZchw8D2YGzWmHo0aMeGBRUXU8aTQVrAgMBAAGjgYgw gYUwDAYDVR0TAQH/BAIwADA0BgNVHSUELTArBggrBgEFBQcDAgYIKwYBBQUHAwEG CWCGSAGG+EIEAQYKKwYBBAGCNwoDAzALBgNVHQ8EBAMCBaAwMgYIKwYBBQUHAQEE JjAkMCIGCCsGAQUFBzABhhZasdafOi8vb2NzcC5jYWNlcnQub3JnMA0GCSqGSIb3 DQEBBQUAA4ICAQAIeqiyZECg7z7/hiynO0ZsY96WQ+oUAZS2XCjL67maOrawTIWJ RN+9Na3sqw23DE5GnqY6IhG6NLLRiKqJt34Fxvjq1pUdTyEJdsBRQZZQxPa6gKph /AwYiUR39Rd+rRIwx7cvEjabH6amympo4cAalFmhITv+8wc9UT5JGZnJbnNK1Y9O 5BW6d8YTI2vQenHMT6y5sowLm65vPEdF2KD1bCHQ/3QTW0wMuV9bGQyTsNeBRB+9 ZGaXaP3IiC8ZmSbBj1Uh5+l5OcZhW6ucCQ5QKOGTVMrqyRD7kVXFAARf7jTU3Mq4 2VZcORTCerAjzpnyYAosQRztxYHGFjmL3f+4fBOqyxbm7tsPkv/bOrBOKS85wvyY aB8EVasdf4kELIvOQ8U0uxolxwewI6rbZk2/QddAbjy/Hv4diM4f8VMhnEgkOUof x2bKrl59gpjZZCwwNscom2CM5dOh+yps+Y4SRPcoy8psk0ItaY1ASi42Wr0iEyDb C3OHJasdftSlIBrM2Uk1b/dNmxVUJfHS1qDLnEYsXhAiVIgHEVZGv7cfZuh7PnQn qOMPfasd3stvinU4mIfwYUMECfp0NdnNVY9rTA0HPCv9zD3V3Ez6plbrG2Z0sf8G kZAls42oev3hRtpxnWVqP+FAi7nrGDCpNg3q1tuJ82YOOVU39dmeUSDNMW== -----END CERTIFICATE-----
Ahora agregaremos esta informacion a la configuracion de el virtual host predeterminado de apache, editar el archivo:
# vim ../modules.d/41_mod_ssl.default-vhost.conf # Server Certificate: # Point SSLCertificateFile at a PEM encoded certificate. If # the certificate is encrypted, then you will be prompted for a # pass phrase. Note that a kill -HUP will prompt again. A test # certificate can be generated with `make certificate' under # built time. Keep in mind that if you've both a RSA and a DSA # certificate you can configure both in parallel (to also allow # the use of DSA ciphers, etc.) ###SSLCertificateFile conf/ssl/server.crt SSLCertificateFile conf/ssl/www.calcom.com.mx.crt # Server Private Key: # If the key is not combined with the certificate, use this # directive to point at the key file. Keep in mind that if # you've both a RSA and a DSA private key you can configure # both in parallel (to also allow the use of DSA ciphers, etc.) ###SSLCertificateKeyFile conf/ssl/server.key SSLCertificateKeyFile conf/ssl/www.calcom.com.mx.key
Ahora reiniciar apache2:
# /etc/init.d/apache2 restart * Stopping apache2 ... [ ok ] * Starting apache2 ... [ ok ]
Ahora prueba entrar con un navegador a tu servidor web pero usando https://hostname Se vera algo asi: IMAGEN Comprueba que el certificado que use es el tuyo, haciendo esto: IMAGEN