Apache is the mostly used Web Server on the Internet today. This blog covers its installation, configuration, enable SSL, Generate Self-Signed SSL certificate and enable Basic Authentication
Step 1:
Install Apache webserver,
OS : Centos 7
First update the operating system with the latest updates.
# yum update
Install Apache,
# yum install httpd mod_ssl -y
mod_ssl is required to enable SSL in httpd.
Step 2:
Generate Self-Signed SSL certificate and enable SSL,
Below command to generate self signed ssl certificate.
# mkdir /etc/httpd/ssl && openssl req -x509 -nodes -days 365 -newkey rsa:2048 -keyout /etc/httpd/ssl/helmprivaterepo.key -out /etc/httpd/ssl/helmprivatrepo.crt && ls -lrth /etc/httpd/ssl
Next configure the certificates in ssl.conf file.
# vi /etc/httpd/conf.d/ssl.conf
Update below two lines with the newly created ssl certificate location.
SSLCertificateFile /etc/httpd/ssl/helmprivaterepo.crt
SSLCertificateKeyFile /etc/httpd/ssl/helmprivaterepo.key
Step 3:
Enable Basic authentication in Apache,
First generate a username and password by,
# htpasswd -c /etc/httpd/.htpasswd admin
Configure httpd for basic authentication,
# vi /etc/httpd/conf/httpd.conf
add the below lines at the end,
<Directory "/var/www/html">
AuthType Basic
AuthName "Restricted Content"
AuthUserFile /etc/httpd/.htpasswd
Require valid-user
</Directory>
Now start the httpd service and verify webserver status and Basic Authentication.
# systemctl start httpd
# systemctl status httpd
# systemctl enable httpdGo to browser and check the authentication is working or not.
URL : https://hostname_or_domainname
Thats all, we have successfully installed Apache webserver in Centos and generated Self-Signed SSL certificate and enabled SSL, Basic Authentication.
Post a Comment