1 - Gerando o certificado SSL para o Apache
Código: Selecionar todos
mkdir /etc/apache2/certs
cd /etc/apache2/certs
touch ssl.key
touch ssl.crt
chmod 755 ssl.key
chmod 755 ssl.crt
openssl genrsa -des3 -out server.key 2048 openssl req -new -x509 -days 3650 -key server.key -out server.crt
Este certificado será válido por 10 anos, portanto nem esquente a cabeça com expiração do mesmo

2 - Habilitar o modulo SSL no Apache
Código: Selecionar todos
a2enmod ssl
Código: Selecionar todos
NameVirtualHost *:443
<virtualhost *:443>
ServerAdmin [email protected]
SSLEngine On
ServerSignature Off
SSLCertificateFile /etc/apache2/certs/server.crt
SSLCertificateKeyFile /etc/apache2/certs/server.key
DocumentRoot /var/www/
<directory />
Options FollowSymLinks
AllowOverride None
</directory>
<directory /var/www/>
Options -Indexes FollowSymLinks MultiViews
AllowOverride None
Order allow,deny
allow from all
</directory>
ScriptAlias /cgi-bin/ /usr/lib/cgi-bin/
<directory "/usr/lib/cgi-bin">
AllowOverride None
Options ExecCGI -MultiViews +SymLinksIfOwnerMatch
Order allow,deny
Allow from all
</directory>
ErrorLog /var/log/apache2/error.log
LogLevel warn
CustomLog /var/log/apache2/access.log combined
</virtualhost>
Código: Selecionar todos
a2ensite ssl-default
Código: Selecionar todos
a2enmod rewrite
Código: Selecionar todos
/etc/init.d/apache2 reload && /etc/init.d/apache2 restart
8 - Criar regra NAT na porta 443 TCP para o ip local do servidor ApacheRestarting web server: apache2Apache/2.2.9 mod_ssl/2.2.9 (Pass Phrase Dialog) Some of your private key files are encrypted for security reasons.
In order to read them you have to provide the pass phrases.
Server webserver.exemplo.com.br:443 (RSA) Enter pass phrase:
OK: Pass Phrase Dialog successful.
9 - Editando os vhosts existentes e criando regra de rewrite para o PhpMyadmin
Entre as tags: <virtualhost></virtualhost> inserir:
Código: Selecionar todos
RewriteEngine on
RewriteCond %{SERVER_PORT} ^80$
RewriteRule ^/phpmyadmin(.*)$ https://%{SERVER_NAME}/phpmyadmin$1 [L,R]
RewriteLog "/var/log/apache2/rewrite.log"
RewriteLogLevel 2
Bom proveito
