Loading...
Real Time Concepts

Apache Web Server in Centos/Redhat

In this article we will see how to install Apache (HTTPD) and website configuration in centos / Redhat server

yum install httpd

sudo systemctl status httpd

sudo systemctl start httpd

sudo systemctl enable httpd

When you have your server’s IP address, enter that IP Address  in your browser’s address bar:

http://your_server_ip

virtual host configuration in centos 7

<VirtualHost *:80>
ServerName example.com
#ServerAlias www.example.com
DocumentRoot /var/www/html/example
<Directory “/var/www/html/example”>
DirectoryIndex index.html index.php
Options Indexes FollowSymLinks
AllowOverride All
Require all granted
</Directory>

RewriteEngine On
RewriteCond %{HTTP_HOST} ^example\.com$ [NC]
RewriteRule ^ https://www.example.com%{REQUEST_URI} [R=301,L]

RewriteCond %{HTTP_HOST} ^www.example\.com$ [NC]
RewriteRule ^ https://www.example.com%{REQUEST_URI} [R=301,L]

RewriteEngine on
RewriteCond %{REQUEST_METHOD} ^(TRACE|TRACK)
RewriteRule .* – [F]

CustomLog /var/log/httpd/example-access.log combined
ErrorLog /var/log/httpd/example-error.log
</VirtualHost>

<VirtualHost *:443>
ServerName example.com
#ServerAlias example.com
DocumentRoot /var/www/html/example
<Directory “/var/www/html/example”>
DirectoryIndex index.html index.php
Options FollowSymLinks
AllowOverride All
Require all granted
</Directory>
SSLEngine on
SSLProtocol all -SSLv2 -SSLv3

SSLCertificateFile /etc/httpd/SSL/example.crt
SSLCertificateKeyFile /etc/httpd/SSL/example_private-key
SSLCertificateChainFile /etc/httpd/SSL/example.bundle

RewriteEngine on
RewriteCond %{REQUEST_METHOD} ^(TRACE|TRACK)
RewriteRule .* – [F]

CustomLog /var/log/httpd/ssl-example.com-access.log common
ErrorLog /var/log/httpd/ssl-example-error.log
</VirtualHost>

Leave a Reply

Your email address will not be published. Required fields are marked *