Cài đặt web server apache

 

#Cấu hình https

 

[root@webserver~]dnf install httpd mod_ssl -y

 

#Tạo SSL self‑signed certificate

 

[root@webserver~]mkdir -p /opt/certs/

 

#Tạo private key + certificate

 

[root@webserver~]openssl req -x509 -nodes -days 365 \

 

-newkey rsa:2048 \

 

-keyout server.key \

 

-out server.crt

 

Nhập thông tin output ra

 

Country Name          : VN

 

State or Province     : Hanoi

 

Locality              : Hanoi

 

Organization Name     : Lab

 

Common Name (CN)      : giangit.com   #quan trọng

 

Cấu hình

 

[root@webserver~]nano /etc/httpd/conf.d/vhost.conf

 ########################################################

<VirtualHost *:443>

 

                 ServerAdmin admin@giangit.com

 

   DocumentRoot /var/www/html

 

   ServerName giangit.com

 

   ServerAlias www.giangit.com

 

   ErrorLog /var/log/httpd/giangit.com-error.log

 

   CustomLog /var/log/httpd/giangit.com-access.log combined

 

   # SSL config

 

   SSLEngine on

 

   SSLCertificateFile /opt/certs/server.crt

 

   SSLCertificateKeyFile /opt/certs/server.key

 

   SSLProtocol all -SSLv3 -TLSv1 -TLSv1.1

 

   SSLCipherSuite HIGH:!aNULL:!MD5

 

   SSLHonorCipherOrder on

 

   <Directory /var/www/html/ >

 

       AllowOverride All

 

       Require all granted

 

   </Directory>

 

</VirtualHost>

 

#Cấu hình redirect http thành https

 

<VirtualHost *:80>

 

   ServerName .giangit.com

 

   Redirect permanent  /  https://giangit.com/

 

</VirtualHost>

#save file và restart dịch vụ

########################################################

[root@webserver~]systemctl restart httpd