ワイルドカード対応(HTTP 2.2/2.4)
conf.d/httpd-vhost.conf
<VirtualHost *:80>
ServerName a.cent.example.jp
ServerAlias a.cent.example.jp *.cent.example.jp
VirtualDocumentRoot /var/www/vhost/%1/html/
ErrorLog logs/vhost.error_log
CustomLog logs/vhost.access_log common
# RewriteLog logs/vhost.rewrite_log
# RewriteLogLevel 9
<Directory /var/www/vhost/*/html/>
Options All
AllowOverride All
Order deny,allow
Allow from all
<IfVersion = /^2.4./ >
# version 2.4
Require all granted
</IfVersion>
</Directory>
DirectoryIndex index.php index.html
</VirtualHost>
# HTTPS 接続が不要の場合はここ以下を削除 ---------------------------------------------
<IfVersion == 0.0>
# ありえないバージョンを指定することにより複数行コメントと為す
# SSL 証明書(自己証明書作成)
$ mkdir -p /var/www/vhost/conf/
$ cd /var/www/vhost/conf/
$ openssl genrsa 2048 -out server.key
$ openssl req -new -key server.key -out server.csr
# バージョン 0.0 の場合のみ実行 を利用したコメント
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) [XX]:JP
State or Province Name (full name) []:
Locality Name (eg, city) [Default City]:Tokyo
Organization Name (eg, company) [Default Company Ltd]:Example.JP
Organizational Unit Name (eg, section) []:Developer
Common Name (eg, your name or your server's hostname) []:*.example.jp
Email Address []:root@example.jp
Please enter the following 'extra' attributes
to be sent with your certificate request
A challenge password []:1234
An optional company name []:1234
$ openssl x509 -days 3650 -req -signkey server.key -in server.csr -out server.crt
$ openssl rsa -in server.key -out server.key
</IfVersion>
<IfModule ssl_module>
<VirtualHost *:443>
ServerName a.cent.example.jp
ServerAlias a.cent.example.jp *.cent.example.jp
VirtualDocumentRoot /var/www/vhost/%1/html/
ErrorLog logs/vhost.error_log
CustomLog logs/vhost.access_log common
# RewriteLog logs/vhost.rewrite_log
# RewriteLogLevel 9
<Directory /var/www/vhost/*/html/>
Options All
AllowOverride All
Order deny,allow
Allow from all
<IfVersion = /^2.4./ >
# version 2.4
Require all granted
</IfVersion>
</Directory>
DirectoryIndex index.php index.html
SSLEngine on
SSLProtocol all -SSLv2
SSLCipherSuite ALL:!ADH:!EXPORT:!SSLv2:RC4+RSA:+HIGH:+MEDIUM:+LOW
SSLCertificateFile /var/www/vhost/conf/server.crt
SSLCertificateKeyFile /var/www/vhost/conf/server.key
</VirtualHost>
</IfModule>