Friday, August 18, 2023

Linux cut command

Cut command check your command query with option the show output on screen.

Command Syntax:- cut option filename





Thursday, August 17, 2023

Linux Web Server Configuration

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>

Linux Master DNS Server Configuration

Package Name: bind

Service Name: named

IP Address : 192.168.1.4

Port: 53

Configuration File: /etc/named.conf

Directory: /var/named




DNS Name: ritesh.local

Computer Name: computer-1.ritesh.local

Example:  computer-1.ritesh.local  - FQDN


- Install Package


[root@computer-1 ~]#  yum install bind


[root@computer-1 ~]# hostnamectl set-hostname computer-1.ritesh.local


[root@computer-1 ~]# cat /etc/hosts


192.168.1.4 computer-1.devopsservice.local computer-1


[root@computer-1 ~]# cat /etc/resolv.conf

# Generated by NetworkManager

search ritesh.local

nameserver 192.168.1.4


[root@computer-1 ~]#


[root@computer-1 ~]# vi /etc/named.conf


listen-on port 53 { 192.168.1.4; };

allow-query     { any; };


[root@computer-1 ~]# vi /etc/named.rfc1912.zones


zone "devopsservice.local" IN {

        type master;

        file "ritesh.local.forward";

        allow-update { none; };

};




[root@computer-1 ~]# cd /var/named/

[root@computer-1 ~]# vi ritesh.local.forward


$TTL 1D

@       IN SOA  computer-1.ritesh.local. root.ritesh.local. (

                                        0       ; serial

                                        1D      ; refresh

                                        1H      ; retry

                                        1W      ; expire

                                        3H )    ; minimum

          IN NS computer-1.ritesh.local.

computer-1 IN A 192.168.1.4

windows   IN A 192.168.1.3



[root@computer-1 ~]# chown root:named ritesh.local.forward


[root@computer-1 ~]# systemctl start named