Apache Configuration
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
- Package : httpd
- Service : httpd
- Port : 80 (http) ,443(https)
- Configuration file : /etc/httpd/conf/httpd.conf
- Document Root : /var/www/html/
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
1.) Install httpd service.
#yum install httpd -y
==================================================
2) Configuration file path.
vim /etc/httpd/conf/httpd.conf
Here you can change port as per your requirement.
Listen 80
Listen 8080
==================================================
3.) You have to create a file like index.html
#vim /var/www/html/index.html
==================================================
4.) After creating file under html folder, need to start httpd service.
Your URL will be http;//ipaddress or domain name from browser.
Also, you can same check with your terminal like curl http://localhost
==================================================
5.) We can change or add default page extenstion or file name in hosting configuration.
==================================================
6.) Whenever you change the configuration in config file then you have to reload the httpd service.
#systemctl reload httpd
##################################################
Port Based Hosting
##################################################
1.) Configuration file path.
vim /etc/httpd/conf/httpd.conf
You have to add custom port number as per your requirement in httpd configuration file.
==================================================
2) Add below syntex in your httpd configuration file.
<Directory /var/www/html/site1>
Require all granted
AllowOverride None
</Directory>
<VirtualHost 172.31.36.170:8080>
DocumentRoot /var/www/html/site1
ServerAdmin ashara@ritesh.local
ErrorLog "logs/site1_error_log"
CustomLog "logs/site1_access_log" combined
</VirtualHost>
<Directory /var/www/html/site2>
Require all granted
AllowOverride None
</Directory>
<VirtualHost 172.31.36.170:8181>
DocumentRoot /var/www/html/site2
ServerAdmin ashara@ritesh.local
ErrorLog "logs/site2_error_log"
CustomLog "logs/site2_access_log" combined
</VirtualHost>
==================================================
3.) Now restart httpd service.
#systemctl restart httpd
or
#systemctl reload httpd
==================================================
4.) We are now checking output with different port numbers which we have mentioned in httpd configuration file.
<Directory /var/www/html/site1>
Require all granted
AllowOverride None
</Directory>
<VirtualHost 192.168.1.201:80>
DocumentRoot /var/www/html/site1
ServerAdmin janak@devops.local
ErrorLog "logs/site1_error_log"
CustomLog "logs/site1_access_log" combined
</VirtualHost>
<Directory /var/www/html/site2>
Require all granted
AllowOverride None
</Directory>
<VirtualHost 192.168.1.201:8080>
DocumentRoot /var/www/html/site2
ServerAdmin janak@devops.local
ErrorLog "logs/site2_error_log"
CustomLog "logs/site2_access_log" combined
</VirtualHost>
https://www.webhi.com/how-to/how-to-install-ssl-certificate-on-apache-for-centos-7/
apachectl configtest
IP Based
===========================================
<Directory /var/www/html/site1>
Require all granted
AllowOverride None
</Directory>
<VirtualHost 192.168.1.102:80>
DocumentRoot /var/www/html/site1
ServerAdmin janak@devops.local
ErrorLog "logs/site1_error_log"
CustomLog "logs/site1_access_log" combined
</VirtualHost>
<Directory /var/www/html/site2>
Require all granted
AllowOverride None
</Directory>
<VirtualHost 192.168.1.112:80>
DocumentRoot /var/www/html/site2
ServerAdmin janak@devops.local
ErrorLog "logs/site2_error_log"
CustomLog "logs/site2_access_log" combined
</VirtualHost>
DNS Based
=======================
<Directory /var/www/html/site1>
Require all granted
AllowOverride None
</Directory>
<VirtualHost 192.168.0.104:80>
DocumentRoot /var/www/html/site1
ServerName www.devopsservice.local:80
ServerAdmin janak@devops.local
ErrorLog "logs/site1_error_log"
CustomLog "logs/site1_access_log" combined
</VirtualHost>
<Directory /var/www/html/site2>
Require all granted
AllowOverride None
</Directory>
<VirtualHost 192.168.0.104:80>
DocumentRoot /var/www/html/site2
ServerName web.devopsservice.local:80
ServerAdmin janak@devops.local
ErrorLog "logs/site2_error_log"
CustomLog "logs/site2_access_log" combined
</VirtualHost>
No comments:
Post a Comment