let’s say, we want to configure two domains example1.com and example2.com in our server with Centos7 + httpd installation. So we have a dedicated IP say 10.10.10.10
First thing to do is to create an A record on your registrar, and point to the IP of our server which 10.10.10.10
Next, navigate to
1 |
sudo vi /etc/httpd/conf/httpd.conf |
navigate to end on that file and you will see this line:
1 |
IncludeOptional conf.d/*.conf |
That line will include the all the configurations files that has ending file name .conf from /etc/httpd/conf.d
Now navigate to conf.d directory:
1 |
cd /etc/httpd/conf.d |
create files example1.com.conf and example2.com.conf
Open example1.com.conf and put this:
1 2 3 4 5 6 7 8 9 10 |
<VirtualHost *:80> ServerAdmin yourname@example1.com ServerName example1.com DocumentRoot /var/www/example1.com <Directory "/var/www/example1.com"> Options Indexes FollowSymLinks AllowOverride All Require all granted </Directory> </VirtualHost> |
Next open example2.com.conf and put this:
1 2 3 4 5 6 7 8 9 10 |
<VirtualHost *:80> ServerAdmin yourname@example2.com ServerName example2.com DocumentRoot /var/www/example2.com <Directory "/var/www/example2.com"> Options Indexes FollowSymLinks AllowOverride All Require all granted </Directory> </VirtualHost> |
Next, we have to support SSL;
create the files again for our SSL configuration:
1 2 |
sudo touch example1.com.ssl.conf sudo touch example2.com.ssl.conf |
Open respective files and put this lines:
for example1.com:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 |
<VirtualHost *:443> DocumentRoot "/var/www/example1.com" ServerName example1.com:443 SSLEngine on SSLProtocol all -SSLv2 SSLCipherSuite HIGH:MEDIUM:!aNULL:!MD5:!SEED:!IDEA SSLCertificateFile /etc/pki/tls/certs/example1.crt SSLCertificateKeyFile /etc/pki/tls/private/example1.key SSLCACertificateFile /etc/pki/tls/certs/example1.ca-bundle.crt <Files ~ "\.(cgi|shtml|phtml|php3?)$"> SSLOptions +StdEnvVars </Files> <Directory "/var/www/cgi-bin"> SSLOptions +StdEnvVars </Directory> </VirtualHost> |
for example2.com:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 |
<VirtualHost *:443> DocumentRoot "/var/www/example2.com" ServerName example2.com:443 SSLEngine on SSLProtocol all -SSLv2 SSLCipherSuite HIGH:MEDIUM:!aNULL:!MD5:!SEED:!IDEA SSLCertificateFile /etc/pki/tls/certs/example2.crt SSLCertificateKeyFile /etc/pki/tls/private/example2.key SSLCACertificateFile /etc/pki/tls/certs/example2.ca-bundle.crt <Files ~ "\.(cgi|shtml|phtml|php3?)$"> SSLOptions +StdEnvVars </Files> <Directory "/var/www/cgi-bin"> SSLOptions +StdEnvVars </Directory> </VirtualHost> |
Now everything is full setup, we will restart our httpd service.
1 |
systemctl restart httpd |
Be First to Comment