SlideShare a Scribd company logo
1 of 9
Download to read offline
How To Configure Apache VirtualHost on RHEL 7 on AWS
i | P a g e
Table of Contents
Overview.......................................................................................................................................................1
Applies To......................................................................................................................................................1
Pre-Requisites ...............................................................................................................................................1
Configure Apache – VirtualHost....................................................................................................................1
Default – Listen .........................................................................................................................................1
Default – DocumentRoot..........................................................................................................................1
Default – List DocumentRoot....................................................................................................................2
New Website Directory.............................................................................................................................2
Add Listen .................................................................................................................................................2
Add VirtualHost Directive .........................................................................................................................3
Default Port – 80...................................................................................................................................3
Alternate Port – 81................................................................................................................................3
Alternate Port – 82................................................................................................................................3
Parse Config File........................................................................................................................................5
Create – Log Directories............................................................................................................................5
Validate Syntax..........................................................................................................................................5
Parse Config File........................................................................................................................................6
Restart Service – httpd..............................................................................................................................6
SELinux Status ...........................................................................................................................................7
Add Network port type.........................................................................................................................7
Modify Security Group..................................................................................................................................7
Launch websites............................................................................................................................................8
Website #1 ............................................................................................................................................8
Website #2 ............................................................................................................................................8
Website #3 ............................................................................................................................................8
How To Configure Apache VirtualHost on RHEL 7 on AWS
1 | P a g e
Overview
Virtual hosts means hosting more than one website’s on apache webserver.
The purpose of this guide is to configure virtual hosts on a different ports and different document content
folder. It is always a best practice to configure SELinux in enforcing mode to have extra layer of security
on the server that is exposed to the internet domain.
Applies To
Tested on RHEL 7, CentOS 7.
Pre-Requisites
 apache httpd
 policycoreutils-python (semanage command)
Configure Apache – VirtualHost
One of the features with apache is configuring virtualhost for hosting multiple websites on a webserver
and configuring these website on a different ports also.
All the configurations has to be done with “apache” user. Daemon start/restart/status command should
be executed with “root” user.
Default – Listen
Next we will list the “Listen” directive (port to listen) that has been configured. By default this directive is
configured to listen on port “80”; run the command;
cat /etc/httpd/conf/httpd.conf | grep ^Listen
Default – DocumentRoot
First and foremost thing that has to be done is to know the “DocumentRoot” directive that has been
configured in apache main configuration file “httpd.conf”. By default this directive is configured as
“/var/www/html”.
cat /etc/httpd/conf/httpd.conf | grep ^DocumentRoot
How To Configure Apache VirtualHost on RHEL 7 on AWS
2 | P a g e
Default – List DocumentRoot
Next we will list the folder DocumentRoot “/var/www/”, run the command;
cd /var/www/ ; ll
New Website Directory
Create the new website directory, where we intend create new website and change the owner of the
folder to apache user and group.
mkdir -v /var/www/example{2..3}; cd /var/www/
chown -R apache:apache example{2..3} ; ll
Add Listen
Next step is to configure listen port directive, edit “httpd.conf” and add the directive entries as below.
Listen :80
Listen :81
Listen :82
How To Configure Apache VirtualHost on RHEL 7 on AWS
3 | P a g e
Add VirtualHost Directive
Next step is to create a new VirtualHost directive entries for different ports, as below.
Default Port – 80
Configuration directives for port 80 and virtual host.
<VirtualHost *:80>
ServerAdmin admin@domain.com
DocumentRoot "/var/www/html"
ServerName example1.domain.com
ServerAlias example1.domain.com
ErrorLog "/var/log/httpd/example1/error_log"
CustomLog "/var/log/httpd/example1/access_log" common
<Directory /var/www/html>
Options FollowSymLinks
AllowOverride None
Require all granted
</Directory>
</VirtualHost>
Alternate Port – 81
Configuration directives for port 81 and virtual host.
<VirtualHost *:81>
ServerAdmin admin@domain.com
DocumentRoot "/var/www/example2"
ServerName example2.domain.com
ServerAlias example2.domain.com
ErrorLog "/var/log/httpd/example2/error_log"
CustomLog "/var/log/httpd/example2/access_log" common
<Directory /var/www/example2>
Options FollowSymLinks
AllowOverride None
Require all granted
</Directory>
</VirtualHost>
Alternate Port – 82
Configuration directives for port 82 and virtual host.
<VirtualHost *:82>
ServerAdmin admin@domain.com
DocumentRoot "/var/www/example3"
ServerName example3.domain.com
ServerAlias example3.domain.com
ErrorLog "/var/log/httpd/example3/error_log"
CustomLog "/var/log/httpd/example3/access_log" common
<Directory /var/www/example3>
Options FollowSymLinks
AllowOverride None
Require all granted
</Directory>
</VirtualHost>
How To Configure Apache VirtualHost on RHEL 7 on AWS
4 | P a g e
How To Configure Apache VirtualHost on RHEL 7 on AWS
5 | P a g e
Parse Config File
To show the settings as parsed from the config file and show errors in the configuration, run the command;
httpd -S
Note: In this case log file directories are not created, hence the check has failed.
Create – Log Directories
Next step is to create log directories for “example1”, “example2” and “example3” in “/var/log/httpd/”.
In this directory all the access and error logs will be generated and stored, to create these directories run
the command;
mkdir -v /var/log/httpd/example{1..3}
Validate Syntax
After parsing the configuration file, next we will check for syntax errors to validate the syntax, run the
command; if no issues are found “Syntax OK” will be displayed.
httpd -t
How To Configure Apache VirtualHost on RHEL 7 on AWS
6 | P a g e
Parse Config File
After creating the directory, rerun the parse config file and show errors if any, if no errors are reported, it
will list all the main parameters configured.
httpd -S
Restart Service – httpd
After validating the configuration and verifying the syntax, next you can go ahead and restart the httpd
service and check the service status.
systemctl restart httpd
systemctl status httpd -l
How To Configure Apache VirtualHost on RHEL 7 on AWS
7 | P a g e
SELinux Status
To know the SELinux Status and current enforcement mode configured run the command; if the “SeLinux
status” is enabled and current mode is set to “enforcing”; SELinux configuration is required else ignore
these steps.
sestatus | grep 'SELinux status|Current mode'
Add Network port type
Since SELinux is enabled, next step is to add network type port type definitions for SELinux to authorize
ports 80 – 82 for http traffic, run the command.
semanage port -d -t http_port_t -p tcp 80
semanage port -d -t http_port_t -p tcp 81
semanage port -d -t http_port_t -p tcp 82
semanage port -l | grep -w "http_port_t" or semanage port -l | grep http_port_t
Modify Security Group
Add new rules to the “Inbound rules” in the AWS Security group for all the ports that needs to access
from outside.
How To Configure Apache VirtualHost on RHEL 7 on AWS
8 | P a g e
Launch Websites
To demonstrate these settings and configuration is working, we will create a “index.html” file with a
sample html content page as per the website numbers and different font colors.
Website #1
<HTML>
<BODY>
<TITLE> 1st website </TITLE>
<H1>
<FONT COLOR="brown"> This is First website's default page </H1>
</H1>
</BODY>
</HTML>
Website #2
<HTML>
<BODY>
<TITLE> 2nd website </TITLE>
<H1>
<FONT COLOR="green"> This is second website's default page </FONT>
</H1>
</FONT>
</BODY>
</HTML>
Website #3
<HTML>
<BODY>
<TITLE> 3rd website </TITLE>
<H1>
<FONT COLOR="blue"> This is third website's default page </FONT>
</H1>
</FONT>
</BODY>
</HTML>

More Related Content

What's hot

How To Install and Configure AWS CLI on RHEL 7
How To Install and Configure AWS CLI on RHEL 7How To Install and Configure AWS CLI on RHEL 7
How To Install and Configure AWS CLI on RHEL 7VCP Muthukrishna
 
How To Install and Configure SUDO on RHEL 7
How To Install and Configure SUDO on RHEL 7How To Install and Configure SUDO on RHEL 7
How To Install and Configure SUDO on RHEL 7VCP Muthukrishna
 
How to Upgrade Openfire on CentOS 7
How to Upgrade Openfire on CentOS 7How to Upgrade Openfire on CentOS 7
How to Upgrade Openfire on CentOS 7VCP Muthukrishna
 
How to Install MariaDB Server or MySQL Server on CentOS 7
How to Install MariaDB Server or MySQL Server on CentOS 7How to Install MariaDB Server or MySQL Server on CentOS 7
How to Install MariaDB Server or MySQL Server on CentOS 7VCP Muthukrishna
 
How To Install and Configure Splunk on RHEL 7 in AWS
How To Install and Configure Splunk on RHEL 7 in AWSHow To Install and Configure Splunk on RHEL 7 in AWS
How To Install and Configure Splunk on RHEL 7 in AWSVCP Muthukrishna
 
Install and Configure RSyslog – CentOS 7 / RHEL 7
Install and Configure RSyslog – CentOS 7 / RHEL 7Install and Configure RSyslog – CentOS 7 / RHEL 7
Install and Configure RSyslog – CentOS 7 / RHEL 7VCP Muthukrishna
 
How to installation and configure apache2
How to installation and configure apache2How to installation and configure apache2
How to installation and configure apache2VCP Muthukrishna
 
How To Configure SNMP Logging on RHEL 7
How To Configure SNMP Logging on RHEL 7How To Configure SNMP Logging on RHEL 7
How To Configure SNMP Logging on RHEL 7VCP Muthukrishna
 
Install and Configure WordPress in AWS on RHEL 7 or CentOS 7
Install and Configure WordPress in AWS on RHEL 7 or CentOS 7Install and Configure WordPress in AWS on RHEL 7 or CentOS 7
Install and Configure WordPress in AWS on RHEL 7 or CentOS 7VCP Muthukrishna
 
How to install and configure firewall on ubuntu os
How to install and configure firewall on ubuntu osHow to install and configure firewall on ubuntu os
How to install and configure firewall on ubuntu osVCP Muthukrishna
 
How to Install and Configure Cacti on Linux
How to Install and Configure Cacti on LinuxHow to Install and Configure Cacti on Linux
How to Install and Configure Cacti on LinuxVCP Muthukrishna
 
Configure Run Levels RHEL 7 or CentOS 7
Configure Run Levels RHEL 7 or CentOS 7Configure Run Levels RHEL 7 or CentOS 7
Configure Run Levels RHEL 7 or CentOS 7VCP Muthukrishna
 
How To Install and Configure SNMP on RHEL 7 or CentOS 7
How To Install and Configure SNMP on RHEL 7 or CentOS 7How To Install and Configure SNMP on RHEL 7 or CentOS 7
How To Install and Configure SNMP on RHEL 7 or CentOS 7VCP Muthukrishna
 
How To Install and Use ABRT CLI on RHEL 7
How To Install and Use ABRT CLI on RHEL 7How To Install and Use ABRT CLI on RHEL 7
How To Install and Use ABRT CLI on RHEL 7VCP Muthukrishna
 
How To Manage Services on RHEL 7 or CentOS 7
How To Manage Services on RHEL 7 or CentOS 7How To Manage Services on RHEL 7 or CentOS 7
How To Manage Services on RHEL 7 or CentOS 7VCP Muthukrishna
 
Nginx bind() to 0.0.0.0:9080 failed
Nginx bind() to 0.0.0.0:9080 failedNginx bind() to 0.0.0.0:9080 failed
Nginx bind() to 0.0.0.0:9080 failedVCP Muthukrishna
 
LSOF Command Usage on RHEL 7
LSOF Command Usage on RHEL 7LSOF Command Usage on RHEL 7
LSOF Command Usage on RHEL 7VCP Muthukrishna
 
TFTP Installation Configuration Guide
TFTP Installation Configuration GuideTFTP Installation Configuration Guide
TFTP Installation Configuration GuideVCP Muthukrishna
 

What's hot (20)

How To Install and Configure AWS CLI on RHEL 7
How To Install and Configure AWS CLI on RHEL 7How To Install and Configure AWS CLI on RHEL 7
How To Install and Configure AWS CLI on RHEL 7
 
How To Install and Configure SUDO on RHEL 7
How To Install and Configure SUDO on RHEL 7How To Install and Configure SUDO on RHEL 7
How To Install and Configure SUDO on RHEL 7
 
How to Upgrade Openfire on CentOS 7
How to Upgrade Openfire on CentOS 7How to Upgrade Openfire on CentOS 7
How to Upgrade Openfire on CentOS 7
 
How to Install MariaDB Server or MySQL Server on CentOS 7
How to Install MariaDB Server or MySQL Server on CentOS 7How to Install MariaDB Server or MySQL Server on CentOS 7
How to Install MariaDB Server or MySQL Server on CentOS 7
 
How To Install and Configure Splunk on RHEL 7 in AWS
How To Install and Configure Splunk on RHEL 7 in AWSHow To Install and Configure Splunk on RHEL 7 in AWS
How To Install and Configure Splunk on RHEL 7 in AWS
 
Install and Configure RSyslog – CentOS 7 / RHEL 7
Install and Configure RSyslog – CentOS 7 / RHEL 7Install and Configure RSyslog – CentOS 7 / RHEL 7
Install and Configure RSyslog – CentOS 7 / RHEL 7
 
How to installation and configure apache2
How to installation and configure apache2How to installation and configure apache2
How to installation and configure apache2
 
How To Configure SNMP Logging on RHEL 7
How To Configure SNMP Logging on RHEL 7How To Configure SNMP Logging on RHEL 7
How To Configure SNMP Logging on RHEL 7
 
Install and Configure WordPress in AWS on RHEL 7 or CentOS 7
Install and Configure WordPress in AWS on RHEL 7 or CentOS 7Install and Configure WordPress in AWS on RHEL 7 or CentOS 7
Install and Configure WordPress in AWS on RHEL 7 or CentOS 7
 
How to install and configure firewall on ubuntu os
How to install and configure firewall on ubuntu osHow to install and configure firewall on ubuntu os
How to install and configure firewall on ubuntu os
 
How to Install and Configure Cacti on Linux
How to Install and Configure Cacti on LinuxHow to Install and Configure Cacti on Linux
How to Install and Configure Cacti on Linux
 
Configure Run Levels RHEL 7 or CentOS 7
Configure Run Levels RHEL 7 or CentOS 7Configure Run Levels RHEL 7 or CentOS 7
Configure Run Levels RHEL 7 or CentOS 7
 
How To Install and Configure SNMP on RHEL 7 or CentOS 7
How To Install and Configure SNMP on RHEL 7 or CentOS 7How To Install and Configure SNMP on RHEL 7 or CentOS 7
How To Install and Configure SNMP on RHEL 7 or CentOS 7
 
SystemD Usage Guide
SystemD Usage GuideSystemD Usage Guide
SystemD Usage Guide
 
How To Install and Use ABRT CLI on RHEL 7
How To Install and Use ABRT CLI on RHEL 7How To Install and Use ABRT CLI on RHEL 7
How To Install and Use ABRT CLI on RHEL 7
 
How To Manage Services on RHEL 7 or CentOS 7
How To Manage Services on RHEL 7 or CentOS 7How To Manage Services on RHEL 7 or CentOS 7
How To Manage Services on RHEL 7 or CentOS 7
 
How To Install CentOS 7
How To Install CentOS 7How To Install CentOS 7
How To Install CentOS 7
 
Nginx bind() to 0.0.0.0:9080 failed
Nginx bind() to 0.0.0.0:9080 failedNginx bind() to 0.0.0.0:9080 failed
Nginx bind() to 0.0.0.0:9080 failed
 
LSOF Command Usage on RHEL 7
LSOF Command Usage on RHEL 7LSOF Command Usage on RHEL 7
LSOF Command Usage on RHEL 7
 
TFTP Installation Configuration Guide
TFTP Installation Configuration GuideTFTP Installation Configuration Guide
TFTP Installation Configuration Guide
 

Similar to How To Configure Apache VirtualHost on RHEL 7 on AWS

Configuration of Apache Web Server On CentOS 8
Configuration of Apache Web Server On CentOS 8Configuration of Apache Web Server On CentOS 8
Configuration of Apache Web Server On CentOS 8Kaan Aslandağ
 
Deploy Rails Application by Capistrano
Deploy Rails Application by CapistranoDeploy Rails Application by Capistrano
Deploy Rails Application by CapistranoTasawr Interactive
 
L.A.M.P Installation Note --- CentOS 6.5
L.A.M.P Installation Note --- CentOS 6.5L.A.M.P Installation Note --- CentOS 6.5
L.A.M.P Installation Note --- CentOS 6.5William Lee
 
Philly security shell meetup
Philly security shell meetupPhilly security shell meetup
Philly security shell meetupNicole Johnson
 
Apache Presentation
Apache PresentationApache Presentation
Apache PresentationAnkush Jain
 
Using aphace-as-proxy-server
Using aphace-as-proxy-serverUsing aphace-as-proxy-server
Using aphace-as-proxy-serverHARRY CHAN PUTRA
 
ITB2019 NGINX Overview and Technical Aspects - Kevin Jones
ITB2019 NGINX Overview and Technical Aspects - Kevin JonesITB2019 NGINX Overview and Technical Aspects - Kevin Jones
ITB2019 NGINX Overview and Technical Aspects - Kevin JonesOrtus Solutions, Corp
 
How To Configure Nginx Load Balancer on CentOS 7
How To Configure Nginx Load Balancer on CentOS 7How To Configure Nginx Load Balancer on CentOS 7
How To Configure Nginx Load Balancer on CentOS 7VCP Muthukrishna
 
Document Management: Opendocman and LAMP installation on Cent OS
Document Management: Opendocman and LAMP installation on Cent OSDocument Management: Opendocman and LAMP installation on Cent OS
Document Management: Opendocman and LAMP installation on Cent OSSiddharth Ram Dinesh
 

Similar to How To Configure Apache VirtualHost on RHEL 7 on AWS (20)

Configuration of Apache Web Server On CentOS 8
Configuration of Apache Web Server On CentOS 8Configuration of Apache Web Server On CentOS 8
Configuration of Apache Web Server On CentOS 8
 
Deploy Rails Application by Capistrano
Deploy Rails Application by CapistranoDeploy Rails Application by Capistrano
Deploy Rails Application by Capistrano
 
Apache - Quick reference guide
Apache - Quick reference guideApache - Quick reference guide
Apache - Quick reference guide
 
Apache
ApacheApache
Apache
 
Proxy
ProxyProxy
Proxy
 
L.A.M.P Installation Note --- CentOS 6.5
L.A.M.P Installation Note --- CentOS 6.5L.A.M.P Installation Note --- CentOS 6.5
L.A.M.P Installation Note --- CentOS 6.5
 
Installing lemp with ssl and varnish on Debian 9
Installing lemp with ssl and varnish on Debian 9Installing lemp with ssl and varnish on Debian 9
Installing lemp with ssl and varnish on Debian 9
 
Apache HTTP Server
Apache HTTP ServerApache HTTP Server
Apache HTTP Server
 
Http
HttpHttp
Http
 
Philly security shell meetup
Philly security shell meetupPhilly security shell meetup
Philly security shell meetup
 
Apache Presentation
Apache PresentationApache Presentation
Apache Presentation
 
Apache
ApacheApache
Apache
 
Using aphace-as-proxy-server
Using aphace-as-proxy-serverUsing aphace-as-proxy-server
Using aphace-as-proxy-server
 
ITB2019 NGINX Overview and Technical Aspects - Kevin Jones
ITB2019 NGINX Overview and Technical Aspects - Kevin JonesITB2019 NGINX Overview and Technical Aspects - Kevin Jones
ITB2019 NGINX Overview and Technical Aspects - Kevin Jones
 
are available here
are available hereare available here
are available here
 
How To Configure Nginx Load Balancer on CentOS 7
How To Configure Nginx Load Balancer on CentOS 7How To Configure Nginx Load Balancer on CentOS 7
How To Configure Nginx Load Balancer on CentOS 7
 
Raj apache
Raj apacheRaj apache
Raj apache
 
Apache Ppt
Apache PptApache Ppt
Apache Ppt
 
Apache Web Server Setup 3
Apache Web Server Setup 3Apache Web Server Setup 3
Apache Web Server Setup 3
 
Document Management: Opendocman and LAMP installation on Cent OS
Document Management: Opendocman and LAMP installation on Cent OSDocument Management: Opendocman and LAMP installation on Cent OS
Document Management: Opendocman and LAMP installation on Cent OS
 

More from VCP Muthukrishna

How to Fix Duplicate Packages in YUM on CentOS 7
How to Fix Duplicate Packages in YUM on CentOS 7How to Fix Duplicate Packages in YUM on CentOS 7
How to Fix Duplicate Packages in YUM on CentOS 7VCP Muthukrishna
 
How To Install and Configure GNome on CentOS 7
How To Install and Configure GNome on CentOS 7How To Install and Configure GNome on CentOS 7
How To Install and Configure GNome on CentOS 7VCP Muthukrishna
 
How To Connect to Active Directory User Validation
How To Connect to Active Directory User ValidationHow To Connect to Active Directory User Validation
How To Connect to Active Directory User ValidationVCP Muthukrishna
 
How To Connect To Active Directory PowerShell
How To Connect To Active Directory PowerShellHow To Connect To Active Directory PowerShell
How To Connect To Active Directory PowerShellVCP Muthukrishna
 
How To List Files on Remote Server - PowerShell
How To List Files on Remote Server - PowerShellHow To List Files on Remote Server - PowerShell
How To List Files on Remote Server - PowerShellVCP Muthukrishna
 
How To List Files and Display In HTML Format
How To List Files and Display In HTML FormatHow To List Files and Display In HTML Format
How To List Files and Display In HTML FormatVCP Muthukrishna
 
How To Check and Delete a File via PowerShell
How To Check and Delete a File via PowerShellHow To Check and Delete a File via PowerShell
How To Check and Delete a File via PowerShellVCP Muthukrishna
 
Zimbra Troubleshooting - Mails not being Delivered or Deferred or Connection ...
Zimbra Troubleshooting - Mails not being Delivered or Deferred or Connection ...Zimbra Troubleshooting - Mails not being Delivered or Deferred or Connection ...
Zimbra Troubleshooting - Mails not being Delivered or Deferred or Connection ...VCP Muthukrishna
 
How To Setup SSH Keys on CentOS 7
How To Setup SSH Keys on CentOS 7How To Setup SSH Keys on CentOS 7
How To Setup SSH Keys on CentOS 7VCP Muthukrishna
 
How To Install and Configure Open SSH Server on Ubuntu
How To Install and Configure Open SSH Server on UbuntuHow To Install and Configure Open SSH Server on Ubuntu
How To Install and Configure Open SSH Server on UbuntuVCP Muthukrishna
 
Windows PowerShell Basics - How To List PSDrive Info
Windows PowerShell Basics - How To List PSDrive InfoWindows PowerShell Basics - How To List PSDrive Info
Windows PowerShell Basics - How To List PSDrive InfoVCP Muthukrishna
 
How To List Nginx Modules Installed / Complied on CentOS 7
How To List Nginx Modules Installed / Complied on CentOS 7How To List Nginx Modules Installed / Complied on CentOS 7
How To List Nginx Modules Installed / Complied on CentOS 7VCP Muthukrishna
 
Windows PowerShell Basics – How To Create powershell for loop
Windows PowerShell Basics – How To Create powershell for loopWindows PowerShell Basics – How To Create powershell for loop
Windows PowerShell Basics – How To Create powershell for loopVCP Muthukrishna
 
How To Construct IF and Else Conditional Statements
How To Construct IF and Else Conditional StatementsHow To Construct IF and Else Conditional Statements
How To Construct IF and Else Conditional StatementsVCP Muthukrishna
 
How To Create PowerShell Function Mandatory Parameter and Optional Parameter
How To Create PowerShell Function Mandatory Parameter and Optional ParameterHow To Create PowerShell Function Mandatory Parameter and Optional Parameter
How To Create PowerShell Function Mandatory Parameter and Optional ParameterVCP Muthukrishna
 
How To Create Power Shell Function Mandatory Parameter Value
How To Create Power Shell Function Mandatory Parameter ValueHow To Create Power Shell Function Mandatory Parameter Value
How To Create Power Shell Function Mandatory Parameter ValueVCP Muthukrishna
 
How To Create PowerShell Function
How To Create PowerShell FunctionHow To Create PowerShell Function
How To Create PowerShell FunctionVCP Muthukrishna
 
How To Disable IE Enhanced Security Windows PowerShell
How To Disable IE Enhanced Security Windows PowerShellHow To Disable IE Enhanced Security Windows PowerShell
How To Disable IE Enhanced Security Windows PowerShellVCP Muthukrishna
 
How To Check IE Enhanced Security Is Enabled Windows PowerShell
How To Check IE Enhanced Security Is Enabled Windows PowerShellHow To Check IE Enhanced Security Is Enabled Windows PowerShell
How To Check IE Enhanced Security Is Enabled Windows PowerShellVCP Muthukrishna
 
How To Install and Configure Screen on CentOS 7
How To Install and Configure Screen on CentOS 7How To Install and Configure Screen on CentOS 7
How To Install and Configure Screen on CentOS 7VCP Muthukrishna
 

More from VCP Muthukrishna (20)

How to Fix Duplicate Packages in YUM on CentOS 7
How to Fix Duplicate Packages in YUM on CentOS 7How to Fix Duplicate Packages in YUM on CentOS 7
How to Fix Duplicate Packages in YUM on CentOS 7
 
How To Install and Configure GNome on CentOS 7
How To Install and Configure GNome on CentOS 7How To Install and Configure GNome on CentOS 7
How To Install and Configure GNome on CentOS 7
 
How To Connect to Active Directory User Validation
How To Connect to Active Directory User ValidationHow To Connect to Active Directory User Validation
How To Connect to Active Directory User Validation
 
How To Connect To Active Directory PowerShell
How To Connect To Active Directory PowerShellHow To Connect To Active Directory PowerShell
How To Connect To Active Directory PowerShell
 
How To List Files on Remote Server - PowerShell
How To List Files on Remote Server - PowerShellHow To List Files on Remote Server - PowerShell
How To List Files on Remote Server - PowerShell
 
How To List Files and Display In HTML Format
How To List Files and Display In HTML FormatHow To List Files and Display In HTML Format
How To List Files and Display In HTML Format
 
How To Check and Delete a File via PowerShell
How To Check and Delete a File via PowerShellHow To Check and Delete a File via PowerShell
How To Check and Delete a File via PowerShell
 
Zimbra Troubleshooting - Mails not being Delivered or Deferred or Connection ...
Zimbra Troubleshooting - Mails not being Delivered or Deferred or Connection ...Zimbra Troubleshooting - Mails not being Delivered or Deferred or Connection ...
Zimbra Troubleshooting - Mails not being Delivered or Deferred or Connection ...
 
How To Setup SSH Keys on CentOS 7
How To Setup SSH Keys on CentOS 7How To Setup SSH Keys on CentOS 7
How To Setup SSH Keys on CentOS 7
 
How To Install and Configure Open SSH Server on Ubuntu
How To Install and Configure Open SSH Server on UbuntuHow To Install and Configure Open SSH Server on Ubuntu
How To Install and Configure Open SSH Server on Ubuntu
 
Windows PowerShell Basics - How To List PSDrive Info
Windows PowerShell Basics - How To List PSDrive InfoWindows PowerShell Basics - How To List PSDrive Info
Windows PowerShell Basics - How To List PSDrive Info
 
How To List Nginx Modules Installed / Complied on CentOS 7
How To List Nginx Modules Installed / Complied on CentOS 7How To List Nginx Modules Installed / Complied on CentOS 7
How To List Nginx Modules Installed / Complied on CentOS 7
 
Windows PowerShell Basics – How To Create powershell for loop
Windows PowerShell Basics – How To Create powershell for loopWindows PowerShell Basics – How To Create powershell for loop
Windows PowerShell Basics – How To Create powershell for loop
 
How To Construct IF and Else Conditional Statements
How To Construct IF and Else Conditional StatementsHow To Construct IF and Else Conditional Statements
How To Construct IF and Else Conditional Statements
 
How To Create PowerShell Function Mandatory Parameter and Optional Parameter
How To Create PowerShell Function Mandatory Parameter and Optional ParameterHow To Create PowerShell Function Mandatory Parameter and Optional Parameter
How To Create PowerShell Function Mandatory Parameter and Optional Parameter
 
How To Create Power Shell Function Mandatory Parameter Value
How To Create Power Shell Function Mandatory Parameter ValueHow To Create Power Shell Function Mandatory Parameter Value
How To Create Power Shell Function Mandatory Parameter Value
 
How To Create PowerShell Function
How To Create PowerShell FunctionHow To Create PowerShell Function
How To Create PowerShell Function
 
How To Disable IE Enhanced Security Windows PowerShell
How To Disable IE Enhanced Security Windows PowerShellHow To Disable IE Enhanced Security Windows PowerShell
How To Disable IE Enhanced Security Windows PowerShell
 
How To Check IE Enhanced Security Is Enabled Windows PowerShell
How To Check IE Enhanced Security Is Enabled Windows PowerShellHow To Check IE Enhanced Security Is Enabled Windows PowerShell
How To Check IE Enhanced Security Is Enabled Windows PowerShell
 
How To Install and Configure Screen on CentOS 7
How To Install and Configure Screen on CentOS 7How To Install and Configure Screen on CentOS 7
How To Install and Configure Screen on CentOS 7
 

Recently uploaded

Developer Data Modeling Mistakes: From Postgres to NoSQL
Developer Data Modeling Mistakes: From Postgres to NoSQLDeveloper Data Modeling Mistakes: From Postgres to NoSQL
Developer Data Modeling Mistakes: From Postgres to NoSQLScyllaDB
 
Connect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck PresentationConnect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck PresentationSlibray Presentation
 
Gen AI in Business - Global Trends Report 2024.pdf
Gen AI in Business - Global Trends Report 2024.pdfGen AI in Business - Global Trends Report 2024.pdf
Gen AI in Business - Global Trends Report 2024.pdfAddepto
 
DevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platformsDevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platformsSergiu Bodiu
 
Artificial intelligence in cctv survelliance.pptx
Artificial intelligence in cctv survelliance.pptxArtificial intelligence in cctv survelliance.pptx
Artificial intelligence in cctv survelliance.pptxhariprasad279825
 
WordPress Websites for Engineers: Elevate Your Brand
WordPress Websites for Engineers: Elevate Your BrandWordPress Websites for Engineers: Elevate Your Brand
WordPress Websites for Engineers: Elevate Your Brandgvaughan
 
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptx
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptxMerck Moving Beyond Passwords: FIDO Paris Seminar.pptx
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptxLoriGlavin3
 
Designing IA for AI - Information Architecture Conference 2024
Designing IA for AI - Information Architecture Conference 2024Designing IA for AI - Information Architecture Conference 2024
Designing IA for AI - Information Architecture Conference 2024Enterprise Knowledge
 
Vertex AI Gemini Prompt Engineering Tips
Vertex AI Gemini Prompt Engineering TipsVertex AI Gemini Prompt Engineering Tips
Vertex AI Gemini Prompt Engineering TipsMiki Katsuragi
 
Nell’iperspazio con Rocket: il Framework Web di Rust!
Nell’iperspazio con Rocket: il Framework Web di Rust!Nell’iperspazio con Rocket: il Framework Web di Rust!
Nell’iperspazio con Rocket: il Framework Web di Rust!Commit University
 
TrustArc Webinar - How to Build Consumer Trust Through Data Privacy
TrustArc Webinar - How to Build Consumer Trust Through Data PrivacyTrustArc Webinar - How to Build Consumer Trust Through Data Privacy
TrustArc Webinar - How to Build Consumer Trust Through Data PrivacyTrustArc
 
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks..."LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...Fwdays
 
Streamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project SetupStreamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project SetupFlorian Wilhelm
 
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)Mark Simos
 
Unleash Your Potential - Namagunga Girls Coding Club
Unleash Your Potential - Namagunga Girls Coding ClubUnleash Your Potential - Namagunga Girls Coding Club
Unleash Your Potential - Namagunga Girls Coding ClubKalema Edgar
 
Advanced Computer Architecture – An Introduction
Advanced Computer Architecture – An IntroductionAdvanced Computer Architecture – An Introduction
Advanced Computer Architecture – An IntroductionDilum Bandara
 
Commit 2024 - Secret Management made easy
Commit 2024 - Secret Management made easyCommit 2024 - Secret Management made easy
Commit 2024 - Secret Management made easyAlfredo García Lavilla
 
Dev Dives: Streamline document processing with UiPath Studio Web
Dev Dives: Streamline document processing with UiPath Studio WebDev Dives: Streamline document processing with UiPath Studio Web
Dev Dives: Streamline document processing with UiPath Studio WebUiPathCommunity
 
Are Multi-Cloud and Serverless Good or Bad?
Are Multi-Cloud and Serverless Good or Bad?Are Multi-Cloud and Serverless Good or Bad?
Are Multi-Cloud and Serverless Good or Bad?Mattias Andersson
 
From Family Reminiscence to Scholarly Archive .
From Family Reminiscence to Scholarly Archive .From Family Reminiscence to Scholarly Archive .
From Family Reminiscence to Scholarly Archive .Alan Dix
 

Recently uploaded (20)

Developer Data Modeling Mistakes: From Postgres to NoSQL
Developer Data Modeling Mistakes: From Postgres to NoSQLDeveloper Data Modeling Mistakes: From Postgres to NoSQL
Developer Data Modeling Mistakes: From Postgres to NoSQL
 
Connect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck PresentationConnect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck Presentation
 
Gen AI in Business - Global Trends Report 2024.pdf
Gen AI in Business - Global Trends Report 2024.pdfGen AI in Business - Global Trends Report 2024.pdf
Gen AI in Business - Global Trends Report 2024.pdf
 
DevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platformsDevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platforms
 
Artificial intelligence in cctv survelliance.pptx
Artificial intelligence in cctv survelliance.pptxArtificial intelligence in cctv survelliance.pptx
Artificial intelligence in cctv survelliance.pptx
 
WordPress Websites for Engineers: Elevate Your Brand
WordPress Websites for Engineers: Elevate Your BrandWordPress Websites for Engineers: Elevate Your Brand
WordPress Websites for Engineers: Elevate Your Brand
 
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptx
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptxMerck Moving Beyond Passwords: FIDO Paris Seminar.pptx
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptx
 
Designing IA for AI - Information Architecture Conference 2024
Designing IA for AI - Information Architecture Conference 2024Designing IA for AI - Information Architecture Conference 2024
Designing IA for AI - Information Architecture Conference 2024
 
Vertex AI Gemini Prompt Engineering Tips
Vertex AI Gemini Prompt Engineering TipsVertex AI Gemini Prompt Engineering Tips
Vertex AI Gemini Prompt Engineering Tips
 
Nell’iperspazio con Rocket: il Framework Web di Rust!
Nell’iperspazio con Rocket: il Framework Web di Rust!Nell’iperspazio con Rocket: il Framework Web di Rust!
Nell’iperspazio con Rocket: il Framework Web di Rust!
 
TrustArc Webinar - How to Build Consumer Trust Through Data Privacy
TrustArc Webinar - How to Build Consumer Trust Through Data PrivacyTrustArc Webinar - How to Build Consumer Trust Through Data Privacy
TrustArc Webinar - How to Build Consumer Trust Through Data Privacy
 
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks..."LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...
 
Streamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project SetupStreamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project Setup
 
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
 
Unleash Your Potential - Namagunga Girls Coding Club
Unleash Your Potential - Namagunga Girls Coding ClubUnleash Your Potential - Namagunga Girls Coding Club
Unleash Your Potential - Namagunga Girls Coding Club
 
Advanced Computer Architecture – An Introduction
Advanced Computer Architecture – An IntroductionAdvanced Computer Architecture – An Introduction
Advanced Computer Architecture – An Introduction
 
Commit 2024 - Secret Management made easy
Commit 2024 - Secret Management made easyCommit 2024 - Secret Management made easy
Commit 2024 - Secret Management made easy
 
Dev Dives: Streamline document processing with UiPath Studio Web
Dev Dives: Streamline document processing with UiPath Studio WebDev Dives: Streamline document processing with UiPath Studio Web
Dev Dives: Streamline document processing with UiPath Studio Web
 
Are Multi-Cloud and Serverless Good or Bad?
Are Multi-Cloud and Serverless Good or Bad?Are Multi-Cloud and Serverless Good or Bad?
Are Multi-Cloud and Serverless Good or Bad?
 
From Family Reminiscence to Scholarly Archive .
From Family Reminiscence to Scholarly Archive .From Family Reminiscence to Scholarly Archive .
From Family Reminiscence to Scholarly Archive .
 

How To Configure Apache VirtualHost on RHEL 7 on AWS

  • 1. How To Configure Apache VirtualHost on RHEL 7 on AWS i | P a g e Table of Contents Overview.......................................................................................................................................................1 Applies To......................................................................................................................................................1 Pre-Requisites ...............................................................................................................................................1 Configure Apache – VirtualHost....................................................................................................................1 Default – Listen .........................................................................................................................................1 Default – DocumentRoot..........................................................................................................................1 Default – List DocumentRoot....................................................................................................................2 New Website Directory.............................................................................................................................2 Add Listen .................................................................................................................................................2 Add VirtualHost Directive .........................................................................................................................3 Default Port – 80...................................................................................................................................3 Alternate Port – 81................................................................................................................................3 Alternate Port – 82................................................................................................................................3 Parse Config File........................................................................................................................................5 Create – Log Directories............................................................................................................................5 Validate Syntax..........................................................................................................................................5 Parse Config File........................................................................................................................................6 Restart Service – httpd..............................................................................................................................6 SELinux Status ...........................................................................................................................................7 Add Network port type.........................................................................................................................7 Modify Security Group..................................................................................................................................7 Launch websites............................................................................................................................................8 Website #1 ............................................................................................................................................8 Website #2 ............................................................................................................................................8 Website #3 ............................................................................................................................................8
  • 2. How To Configure Apache VirtualHost on RHEL 7 on AWS 1 | P a g e Overview Virtual hosts means hosting more than one website’s on apache webserver. The purpose of this guide is to configure virtual hosts on a different ports and different document content folder. It is always a best practice to configure SELinux in enforcing mode to have extra layer of security on the server that is exposed to the internet domain. Applies To Tested on RHEL 7, CentOS 7. Pre-Requisites  apache httpd  policycoreutils-python (semanage command) Configure Apache – VirtualHost One of the features with apache is configuring virtualhost for hosting multiple websites on a webserver and configuring these website on a different ports also. All the configurations has to be done with “apache” user. Daemon start/restart/status command should be executed with “root” user. Default – Listen Next we will list the “Listen” directive (port to listen) that has been configured. By default this directive is configured to listen on port “80”; run the command; cat /etc/httpd/conf/httpd.conf | grep ^Listen Default – DocumentRoot First and foremost thing that has to be done is to know the “DocumentRoot” directive that has been configured in apache main configuration file “httpd.conf”. By default this directive is configured as “/var/www/html”. cat /etc/httpd/conf/httpd.conf | grep ^DocumentRoot
  • 3. How To Configure Apache VirtualHost on RHEL 7 on AWS 2 | P a g e Default – List DocumentRoot Next we will list the folder DocumentRoot “/var/www/”, run the command; cd /var/www/ ; ll New Website Directory Create the new website directory, where we intend create new website and change the owner of the folder to apache user and group. mkdir -v /var/www/example{2..3}; cd /var/www/ chown -R apache:apache example{2..3} ; ll Add Listen Next step is to configure listen port directive, edit “httpd.conf” and add the directive entries as below. Listen :80 Listen :81 Listen :82
  • 4. How To Configure Apache VirtualHost on RHEL 7 on AWS 3 | P a g e Add VirtualHost Directive Next step is to create a new VirtualHost directive entries for different ports, as below. Default Port – 80 Configuration directives for port 80 and virtual host. <VirtualHost *:80> ServerAdmin admin@domain.com DocumentRoot "/var/www/html" ServerName example1.domain.com ServerAlias example1.domain.com ErrorLog "/var/log/httpd/example1/error_log" CustomLog "/var/log/httpd/example1/access_log" common <Directory /var/www/html> Options FollowSymLinks AllowOverride None Require all granted </Directory> </VirtualHost> Alternate Port – 81 Configuration directives for port 81 and virtual host. <VirtualHost *:81> ServerAdmin admin@domain.com DocumentRoot "/var/www/example2" ServerName example2.domain.com ServerAlias example2.domain.com ErrorLog "/var/log/httpd/example2/error_log" CustomLog "/var/log/httpd/example2/access_log" common <Directory /var/www/example2> Options FollowSymLinks AllowOverride None Require all granted </Directory> </VirtualHost> Alternate Port – 82 Configuration directives for port 82 and virtual host. <VirtualHost *:82> ServerAdmin admin@domain.com DocumentRoot "/var/www/example3" ServerName example3.domain.com ServerAlias example3.domain.com ErrorLog "/var/log/httpd/example3/error_log" CustomLog "/var/log/httpd/example3/access_log" common <Directory /var/www/example3> Options FollowSymLinks AllowOverride None Require all granted </Directory> </VirtualHost>
  • 5. How To Configure Apache VirtualHost on RHEL 7 on AWS 4 | P a g e
  • 6. How To Configure Apache VirtualHost on RHEL 7 on AWS 5 | P a g e Parse Config File To show the settings as parsed from the config file and show errors in the configuration, run the command; httpd -S Note: In this case log file directories are not created, hence the check has failed. Create – Log Directories Next step is to create log directories for “example1”, “example2” and “example3” in “/var/log/httpd/”. In this directory all the access and error logs will be generated and stored, to create these directories run the command; mkdir -v /var/log/httpd/example{1..3} Validate Syntax After parsing the configuration file, next we will check for syntax errors to validate the syntax, run the command; if no issues are found “Syntax OK” will be displayed. httpd -t
  • 7. How To Configure Apache VirtualHost on RHEL 7 on AWS 6 | P a g e Parse Config File After creating the directory, rerun the parse config file and show errors if any, if no errors are reported, it will list all the main parameters configured. httpd -S Restart Service – httpd After validating the configuration and verifying the syntax, next you can go ahead and restart the httpd service and check the service status. systemctl restart httpd systemctl status httpd -l
  • 8. How To Configure Apache VirtualHost on RHEL 7 on AWS 7 | P a g e SELinux Status To know the SELinux Status and current enforcement mode configured run the command; if the “SeLinux status” is enabled and current mode is set to “enforcing”; SELinux configuration is required else ignore these steps. sestatus | grep 'SELinux status|Current mode' Add Network port type Since SELinux is enabled, next step is to add network type port type definitions for SELinux to authorize ports 80 – 82 for http traffic, run the command. semanage port -d -t http_port_t -p tcp 80 semanage port -d -t http_port_t -p tcp 81 semanage port -d -t http_port_t -p tcp 82 semanage port -l | grep -w "http_port_t" or semanage port -l | grep http_port_t Modify Security Group Add new rules to the “Inbound rules” in the AWS Security group for all the ports that needs to access from outside.
  • 9. How To Configure Apache VirtualHost on RHEL 7 on AWS 8 | P a g e Launch Websites To demonstrate these settings and configuration is working, we will create a “index.html” file with a sample html content page as per the website numbers and different font colors. Website #1 <HTML> <BODY> <TITLE> 1st website </TITLE> <H1> <FONT COLOR="brown"> This is First website's default page </H1> </H1> </BODY> </HTML> Website #2 <HTML> <BODY> <TITLE> 2nd website </TITLE> <H1> <FONT COLOR="green"> This is second website's default page </FONT> </H1> </FONT> </BODY> </HTML> Website #3 <HTML> <BODY> <TITLE> 3rd website </TITLE> <H1> <FONT COLOR="blue"> This is third website's default page </FONT> </H1> </FONT> </BODY> </HTML>