Linux Unit 4
Linux Unit 4
com
0
Acuity Educare
LINUX SYSTEM
ADMINISTRATION
SEM : V
SEM V: UNIT 4
• Computer only understand numbers (IP address) but it is very difficult for humans to rememberIP
address.
• Domain Name System (DNS) provides solution by associating hostnames with IP addresses. It
converts the people friendly names into computer friendly numbers called IP address.
• Each time we type a Web site’s address into browser, the Domain Name System (DNS)
converts it into IP address.
The DNS Hierarchy
• In above figure part of the DNS hierarchy is shown. There are a few subzones under
example.com in this hierarchy.
• For example: When we type www.example.edu in browser, first it goes to root name server for
.edu for information. The root name server then directs the search to a lower-level domainname
server.
• After we find the domain, information about that domain is provided by its local domain name
servers.
• The three types of local domain name servers are Primary/master, Secondary/slave, and
caching servers.
• Primary/Master name server:
• Every zone has at least a primary name server, also referred to as the master name server.
• This server is responsible for a zone and modifications can be made to this server.
• To increase redundancy in case the master name server goes down, zones are also often configured with
Page 1 of 32
YouTube - Abhay More | Telegram - abhay_more
607A, 6th floor, Ecstasy business park, city of joy, JSD road, mulund (W) | 8591065589/022-25600622
TRAINING -> CERTIFICATION -> PLACEMENT BSC IT : SEM - V : LINUX – U4
• To get information from a DNS server, a client computer is configured with a DNS resolver.
• This is the configuration that tells the client which DNS server to use. If the client computer is aLinux
machine, the DNS resolver is in the configuration file /etc/resolv.conf
• In the DNS resolver, more than one name server is often configured to handle cases where thefirst
DNS server in the list is not available.
• Let’s assume that a client is in the example.com domain and wants to get the resource record for
www.google.com. The following will occur:
•
1. When the request arrives at the name server of example.com, this name server will check its cache. If
it has recently found the requested resource record, the name server will issue a recursive answer from
cache, and nothing else needs to be done.
2. If the name server cannot answer the request from cache, it will first check whether a forwarder has
been configured. A forwarder is a DNS name server to which requests are forwarded that cannot be
answered by the local DNS server. For example, this can be thename server of a provider that serves
many zones and that has a large DNS cache.
Page 2 of 32
YouTube - Abhay More | Telegram - abhay_more
607A, 6th floor, Ecstasy business park, city of joy, JSD road, mulund (W) | 8591065589/022-25600622
TRAINING -> CERTIFICATION -> PLACEMENT BSC IT : SEM - V : LINUX – U4
3. If no forwarder has been configured, the DNS server will resolve the name step-bystep. In the first step,
it will contact the name servers of the DNS root domain to find out how to reach the name servers of
the .com domain.
4. After finding out which name servers are responsible for the .com domain, the local DNSserver, which
still acts on behalf of the client that issued the original request, contacts a name server of the .com
domain to find out which name server to contact to obtain information about the google domain.
5. After finding the name server that is authoritative for the google.com domain, the name server can
then request the resource record it needs. It will cache this resource record and send the answer back
to the client.
• Cache-Only name server is useful when optimizing DNS requests in your network.
• To configure a cache-only name server install the BIND service and make sure that it allows incoming
traffic.
• Once the resource record is found, BIND stores it in cache.This means that the next time a client needs
the same information, it can be provided much faster. It will do the recursion on behalf of all clients.
• Normally, A Forwarder is also configured with cache-only name servers.
Steps:
1. Open a terminal, log in as root, and run #yum install bind* on the host computer to install the bind
package.
2. With an editor, open the confi guration file /etc/named.conf.
# vi /etc/named.conf
This opens your DNS server to accept queries on any network inter face from any client.
4. In /etc/named.conf, change the parameter
dnssec-validation; to dnsserver-validation no;
Page 3 of 32
YouTube - Abhay More | Telegram - abhay_more
607A, 6th floor, Ecstasy business park, city of joy, JSD road, mulund (W) | 8591065589/022-25600622
TRAINING -> CERTIFICATION -> PLACEMENT BSC IT : SEM - V : LINUX – U4
forwarders x.x.x.x
in the same configuration file and give it the value of the IP address of the DNS server we normally use
for our Internet connection. This ensures that the DNS server of our Internet provider is used for DNS
recursion and that requests are not sent directly to the name serversof the root domain.
6. Use the service named restart command to restart the DNS server.
7. From the RHEL host, use
dig redhat.com
You should get an answer, which is sent by your DNS server. We can see this in the SERVER line in the dig
response.
Step 1:
• Modify the /etc/named.conf file. With an editor, open the confi guration file /etc/named.conf.
# vi /etc/named.conf
• The first line is important. It is the directory line that tells named.conf in which directory on the Linux
file system it can find its configuration. By default, it is set to /var/named.
options {
directory “/var/named”;
listen-on port 53 { any; };
allow-query { any; };
forwarders { 8.8.8.8; };
};
• To tell the DNS server which zones it has to service, you need to include a few lines in
/etc/named.conf. In these lines, you’ll tell the server which zones to service and where the
configuration files for that zone are stored. Add two zones, one for the forward lookup of server, and
one for the reverse lookup.
Page 4 of 32
YouTube - Abhay More | Telegram - abhay_more
607A, 6th floor, Ecstasy business park, city of joy, JSD road, mulund (W) | 8591065589/022-25600622
TRAINING -> CERTIFICATION -> PLACEMENT BSC IT : SEM - V : LINUX – U4
• Now named knows where to find the zone configuration file, you’ll also need to create a configuration
for that zone file.
The second parameter in the header file is where the SOA is defined. This line specifies which
name server is authoritative for this DNS domain:
$TTL 1D
$ORIGIN example.com.
@ IN SOA main.example.com.
hostmaster.exampl
e.com. (20120822
;
Page 5 of 32
YouTube - Abhay More | Telegram - abhay_more
607A, 6th floor, Ecstasy business park, city of joy, JSD road, mulund (W) | 8591065589/022-25600622
TRAINING -> CERTIFICATION -> PLACEMENT BSC IT : SEM - V : LINUX – U4
se
rial
3H ; refresh
15 ; retry
1W ; expire
3h ; minimum TTL
IN NS
main.example.com.main
IN A 192.168.1.1
branch IN A 192.168.1.2
mailex IN A 192.168.1.3
IN MX 10
mailex.example.com.IN
MX 20
mailex.provider.com.
Where,
• Next set up the reverse lookup zone file which is called /var/named/example.rev
$TTL 1D
@ IN SOA main.example.com.(
200005203; Serial
8h ;
Refre
sh
2h ; Retry
1w ; Expire
• Next add the information about name servers and the IP addresses.NS
main.example.com
Page 6 of 32
YouTube - Abhay More | Telegram - abhay_more
607A, 6th floor, Ecstasy business park, city of joy, JSD road, mulund (W) | 8591065589/022-25600622
TRAINING -> CERTIFICATION -> PLACEMENT BSC IT : SEM - V : LINUX – U4
The start of authority (SOA) is the first line in the zone file.
The SOA identifies the name server as the authoritative source for informationabout that
domain.
@ IN SOA main.example.com (
IN means Internet.
A Address
Matches a name to an IP address
Secondary servers compare this number with their stored information. If the numbers are
the same, the information has not changed, and it is not necessary
to download this file.
Refresh The amount of time the server should wait before refreshing its data
Retry The amount of time the server should wait before attempting to contact theprimary
server if the previous attempt failed
Expire If the secondary master is not able to contact a primary master during the
specified period, the data expires and should be removed.
TTL Specifies the time to live for the data. This parameter is intended for cachingname
servers and tells them how long to hold the data in their cache.
NS Name servers in domain
MX The mail exchange record. The MX record specifies the mail servers for thedomain.
Page 7 of 32
YouTube - Abhay More | Telegram - abhay_more
607A, 6th floor, Ecstasy business park, city of joy, JSD road, mulund (W) | 8591065589/022-25600622
TRAINING -> CERTIFICATION -> PLACEMENT BSC IT : SEM - V : LINUX – U4
1 PTR router.example.com
Where,
PTR Pointer for address name mapping (Pointer type resource record)Used to
point to the name servers.
Q. What are DNS Zones? List and Explain different DNS Zone Types.
What is the use of zone file? Explain with suitable example.
What is zone files and reverse zone files
• Most DNS servers are configured to service at least two zone types.
Zone:
• First there is the regular zone type that is used to find an IP address for a hostname. This is themost
common use of DNS.
• The Zone file contains the names and addresses of servers and workstations in the localdomain
and maps names to IP addresses.
In forward address resolution, we provide name to find an IP number. Forward addressresolution is
most common name resolution.
Reverse Zone:
• In some cases, it is needed to find the name for a specific IP address. This type of request is handled by
the in-addr.arpa zones.
• In in-addr.arpa zones, PTR resource records are configured. The name of the in-addr.arpazone is
the reversed network part of the IP address followed by in-addr.arpa.
• For example, if the IP address is 192.168.1.1, the in-addr.arpa zone would be 1.168.192.in- addr.arpa.
Page 8 of 32
YouTube - Abhay More | Telegram - abhay_more
607A, 6th floor, Ecstasy business park, city of joy, JSD road, mulund (W) | 8591065589/022-25600622
TRAINING -> CERTIFICATION -> PLACEMENT BSC IT : SEM - V : LINUX – U4
The name server for this zone would be configured to know the names of all IP addresses within that
zone.
• Although in-addr.arpa zones are useful, they are not always configured. The main reason isthat
DNS name resolving also works without in-addr.arpa zones; reverse name resolution is required in
specifi c cases only.
Note: Refer Step 2 of Master DNS Server for Zone files.
• To enable Slave DNS Server, you must first allow the primary Server to transfer data. You dothis by
setting the allow-transfer parameter for the zone.
• It’s also a good idea to set the notify yes parameter in the definition of the master zone. Thismeans
that the master server automatically sends an update to the slaves if something has changed.
• Modify the /etc/named.conf file in Master DNS Server.
options {
directory
“/var/named”; listen-on
port 53 { any; };allow-
query { any; };
forwarders { 8.8.8.8; };
allow-transfer { 192.168.1.2;};
};
file “example.com”;
allow-transfer { 192.168.1.2;};
};
allow-transfer { 192.168.1.2;};
};
• Open a terminal, log in as root, and run #yum install bind* on the host computer to install thebind
package.
• Modify the /etc/named.conf file. With an editor, open the confi guration file /etc/named.conf.
# vi /etc/named.conf
options {
directory
“/var/named”; listen-on
port 53 { any; };allow-
query { any; };
forwarders { 8.8.8.8; };
};
file "example.com";
masters { 192.168.1.1; };
};
};
• Now named knows where to find the zone configuration file, you’ll also need to create a
configuration for that zone file.
Step 3: Same as Step 2 of Master DNS Server
Page 10 of 32
YouTube - Abhay More | Telegram - abhay_more
607A, 6th floor, Ecstasy business park, city of joy, JSD road, mulund (W) | 8591065589/022-25600622
TRAINING -> CERTIFICATION -> PLACEMENT BSC IT : SEM - V : LINUX – U4
Q. Explain the option statement of named.conf file with atleast five parameters.
Wrie a note on statement of /etc/named.conf file
Explain server statement of named.conf file
• Option statement
• Zone statement
• Server Statements etc.
General Syntax:
<option-1>;
<option-2>;
<option-N>;
};
• Option Statement
• The options statement contains global configuration options
• Syntax: option statement
options
{
<option>;
[<option>; …]
Blackhole Specifies which hosts are not allowed to query the nameserver. The defaultoption is
none.
This option is used when particular host floods the server with queries.
pid-file Specifies the location of the process ID file created by the named server.
Page 11 of 32
YouTube - Abhay More | Telegram - abhay_more
607A, 6th floor, Ecstasy business park, city of joy, JSD road, mulund (W) | 8591065589/022-25600622
TRAINING -> CERTIFICATION -> PLACEMENT BSC IT : SEM - V : LINUX – U4
listen-on Specifies the IPv4 netwrok interface on which the name server listens for queries.
listen-on-v6 Specifies the IPv6 network interface on which to listen for queries.
directory Specifies the working directory for the named server. The default option is
/var/named.
notify Specifies whether to notify the secondary name servers when a zone is updates.
It accepts following options
yes – the server will notify all secondary name servers.
no- the server will not notify any secondary nameserver
master-only - the server will notify primary server for the zone only.
explicit - the server will notify only the secondary servers.
Example:
Options
Listen-on {10.0.0.1;};
};
• Zone statement
• Zone statement defines the characteristics of a zone.
• Syntax:
zone<zone-name><zone-class>
{
<zone-options>;
[<zone-options>
…];
• In /etc/named.conf file we add two zones with the help of zone statements, one for the forward
lookup of server, and one for the reverse lookup.
allow- Specifies the slave servers that are allowed to request a transfer of the zone's
allow- Specifies the hosts that are allowed to dynamically update information in their zone.
notify Specifies whether named notifies the master servers when a zone is updated. This
directive accepts the following options
type Define the type of zone. This directive accepts the following options
Forward – forwards all request to other name servers
Master – shows that this is the authorative server for this zone.Slave –
shows that this is the slave server for this zone.
file Specifies the name of the file in the named working directory that contains the zone
configuration data.
masters Specify the IP addresses of master server. This option is only used whe the type isslave.
Example:
masters { 192.168.1.1; };
};
masters { 192.168.1.1; };
};
Page 13 of 32
YouTube - Abhay More | Telegram - abhay_more
607A, 6th floor, Ecstasy business park, city of joy, JSD road, mulund (W) | 8591065589/022-25600622
TRAINING -> CERTIFICATION -> PLACEMENT BSC IT : SEM - V : LINUX – U4
• Server Statement
• In the server statement we can set the properties of a remote server.
• We can specify whether to send queries to the remote server from the local server.
• We can set the method used for transferring information.
no is the default and indicates that queries are sent to the remote server.Yes
means that the remote server is not required.
transfer Specify the number of transfers you want to allow.
transfer-format Specify whether you want one-answer or many answers.
• The Dynamic Host Confi guration Protocol (DHCP) is used to assign IP-related configuration to hosts in
your network.
• Administrator manage IP-related configuration on a single, central location on the network, instead of
on multiple different hosts.
• When a client comes up, it will send a DHCP request on the network. This DHCP request issent as
a broadcast, and the DHCP server that receives the DHCP request will answer and assign an available
IP address. Because the DHCP request is sent as a broadcast, you can have just one DHCP server per
subnet. If multiple DHCP servers are available, there is no way to determine which DHCP server assigns
the IP addresses. In such cases, it is common to set up failover DHCP, which means that two DHCP
services together are servicing the same subnet, and one DHCP server completely takes over if
something goes wrong.
• Each client remembers by default the last IP address it has used. When sending out a DHCP request, it
will always request to use the last IP address again. If that IP address is no longer available, the DHCP
server will give another IP address from the pool of available IP addresses.
Step 1:
• Start the virtual machine, and open a root shell. From the root shell, use the following command
to install the DHCP server.
# yum install dhcp
Page 14 of 32
YouTube - Abhay More | Telegram - abhay_more
607A, 6th floor, Ecstasy business park, city of joy, JSD road, mulund (W) | 8591065589/022-25600622
TRAINING -> CERTIFICATION -> PLACEMENT BSC IT : SEM - V : LINUX – U4
Step 2:
• Open the file /etc/dhcp/dhcpd.conf with an editor, and give it the following contents.
# vi /etc/dhcp/dhcpd.conf
# The amount of time in seconds that the host can keep the IP address.
default-lease-time 600;
max-lease-time 1800;
# IP address of routers/Gateways
Step 3:
Start the DHCP server by using the command #service dhcpd start, and enable it using
• Check if the dhcp client is installed on system. we can check for it by issuing the following
command:
o which dhclient
• If the client is on system, we will see the location of the file. If the file is not installed, we canfind
Page 15 of 32
YouTube - Abhay More | Telegram - abhay_more
607A, 6th floor, Ecstasy business park, city of joy, JSD road, mulund (W) | 8591065589/022-25600622
TRAINING -> CERTIFICATION -> PLACEMENT BSC IT : SEM - V : LINUX – U4
• If a user sends a mail message to a user on another domain on the Internet, it’s the responsibility of
the MTA to contact the MTA of the other domain and deliver the messagethere.
• To find out which MTA serves the other domain, the DNS MX record is used.
• The MTA uses the Simple Mail Transfer Protocol (SMTP) to exchange mail messages with other MTAs
on the Internet.
• When MTA receive a message, the MTA checks whether it is the final destination. If it is, it will deliver
the message to the local message delivery agent (MDA), which takes care of delivering the message
to the mailbox of the user. If the MTA itself is not the final destination, the MTA relays the message to
the MTA of the final destination.
• An MTA relay messages only for authenticated users or users who are known in some other way.
• If, for some reason, the MTA cannot deliver the message to the other MTA, it will queue it. Queuing
means that the MTA stores the message in a local directory and will try to deliver it again later. As an
administrator, you can flush the queues, which means that you can tell the MTA to send all queued
Page 16 of 32
YouTube - Abhay More | Telegram - abhay_more
607A, 6th floor, Ecstasy business park, city of joy, JSD road, mulund (W) | 8591065589/022-25600622
TRAINING -> CERTIFICATION -> PLACEMENT BSC IT : SEM - V : LINUX – U4
messages now.
• Upon delivery, it sometimes happens that the MTA, which contacted an exterior MTA and delivered the
message there, receives it back. This process is referred to as bouncing.
• In general, a message is bounced if it doesn’t comply with the rules of the receiving MTA or if the
destination user doesn’t exist.
• For example: sendmail, postfix, Qmail.
• When MTA receives the mail, it delivers it to the mail delivery agent.
• MDA is the software component that takes care of delivering the mail message to thedestination
user’s mailbox.
• The MDA delivers mail to the recipient’s local message store, which by default on Red Hat
Enterprise Linux is the directory /var/spool/mail/<username>.
• We can use the POP or IMAP server, which is an addition to a mail solution that makes it easierfor
users to get their messages, if they’re not on the same machine where the MDA is running.
POP server allows users to download messages on one machine whereas an IMAP
server allows users to connect to the mail server and read the messages while they are online.
• For example:
procmailMail User Agent
• Finally, the mail message arrives in the mail user agent (MUA). This is the mail client that endusers
use to read their messages or to compose new messages.
• Users install MUA which allows them to work with email on their computer, tablet, orsmartphone.
• Popular MUAa are Outlook, Evolution, and the Linux command-line Mutt tool, Pine.
• Messages are sent between MTAs using SMTP.Other than SMTP there are two other protocolsused to
send mail, Post Office Protocol (POP3) and Internet Message Access Protocol (IMAP4).
• SMTP is the TCP/IP protocol for transferring e-mail messages between computers on a network.
Sometimes SMTP is known as store-and-forward protocol because messages transmitted via SMTP may
go directly from the sending to the receiving MTA or through other MTAs on other network computers.
The other MTA’s briefly store the message before they forward it to another MTA.
• The SMTP protocol can transfer only ASCII text. It can’t handle fonts, colors, graphics, or attachments.
If you want to be able to send these items, you need to add another protocol Multipurpose Internet Mail
Extensions, or MIME. MIME enables you to add colors, sounds, and graphics to your messages while
still enabling them to be delivered by SMTP. In order for MIME to work, you must have a MIME-
compliant MUA.
Page 17 of 32
YouTube - Abhay More | Telegram - abhay_more
607A, 6th floor, Ecstasy business park, city of joy, JSD road, mulund (W) | 8591065589/022-25600622
TRAINING -> CERTIFICATION -> PLACEMENT BSC IT : SEM - V : LINUX – U4
• The problem with SMTP is that it assumes the sending and receiving MTAs are alwaysconnected to the
internet.
POP3
POP3 is the Post Office Protocol version 3. This protocol runs on a server that is connected toa network
and continuously sends and receives mail.
The POP3 server stores any messages it receives. POP3 was developed to solve the problem of what
happens to messages when the recipient is not connected to the network.
Without POP3, the message could not be sent to the recipient if the recipient is offline. But with POP3,
when you want to check your e-mail, you connect to the POP3 server to retrieve your messages that
were stored by the server. After you retrieve your messages, you can use the MUA on your PC to read
them.
MUA has to understand the POP3 to be able to communicate with the POP3 server.
With POP3 the messages you retrieve to your PC are then typically removed from the server. This means
that they are no longer available to you if you want to retrieve them to another PC.
IMAP4
• The Internet Message Access Protocol version 4 (IMAP4) provides sophisticated client/server
functionality for handling e-mail.
IMAP4 has more features than POP3. IMAP4 enables you to store your e-mail on a networked mail server,
just as POP3 does. The difference is that POP3 requires you to download your e- mail before your MUA
reads it, whereas IMAP4 enables your e-mail to reside permanently on a remote server, from which you can
access your mail. And you can do so from your office, your home, or anywhere else. MUA must understand
IMAP4 to retrieve messages from an IMAP4 server.
Give steps to send mail messages with Mutt to the recipient on the local machine.
Page 18 of 32
YouTube - Abhay More | Telegram - abhay_more
607A, 6th floor, Ecstasy business park, city of joy, JSD road, mulund (W) | 8591065589/022-25600622
TRAINING -> CERTIFICATION -> PLACEMENT BSC IT : SEM - V : LINUX – U4
If we get a message that the mail directory for rahul doesn’t exist, type y to create it. You’ll now see the
Mutt interface.
4. Press Enter to open the mail message. Because it doesn’t contain any content, you’ll see the message
header.
5. Type q once you’ve finished reading the message.
6. To reply to the message, type r. Mutt will prompt us to choose which user want to send the message
and which subject line we want to use. Press Enter twice to accept the default suggestions.
7. The message composition window will open next. This is a vi window, so use o to open a new line and
start writing the message. Once we are finished writing, use the vi command :wq! to close the message-
editing interface.
8. Now you’ll see the message summary. From there, type y to send it to root. Next type q to quit Mutt.
Exit rahul’s su shell, and as root type mutt. You’ll see that rahul’s message has been delivered to inbox.
Page 19 of 32
YouTube - Abhay More | Telegram - abhay_more
607A, 6th floor, Ecstasy business park, city of joy, JSD road, mulund (W) | 8591065589/022-25600622
TRAINING -> CERTIFICATION -> PLACEMENT BSC IT : SEM - V : LINUX – U4
2. Find the parameter inet_interfaces = localhost, and put a hash sign in front of it.
3. Enable the parameter inet_interfaces = all by removing the pound sign in front of the line.
4. use #service postfix restart to restart the Postfix process. If a firewall is active, make sure thatpor t
25 is open on it.
5. use #su - lisa to become user lisa and start Mutt. You’ll notice that lisa still hasn’t received her
message yet.
6. As root on the host computer, type #mailq to type the current content of the mail queue.
7. Type #postfix flush to flush the mail queue. Postfix will now try to send the message again.
• For troubleshooting the message delivery process, use /var/log/maillog file. In this file, you’llfind
status information about the message delivery process.
• The mail queue is the list of messages that haven’t been sent yet because there wassome kindof
problem. As an administrator, we can use the mailq command to check the current contents of the
mail queue or use the postfix flush command to flush the entire mail queue. This means that you’ll tell
Postfix to process all messages that are currently in the mail queue and try to deliver them now.
Page 20 of 32
YouTube - Abhay More | Telegram - abhay_more
607A, 6th floor, Ecstasy business park, city of joy, JSD road, mulund (W) | 8591065589/022-25600622
TRAINING -> CERTIFICATION -> PLACEMENT BSC IT : SEM - V : LINUX – U4
• mynetworks
• This parameter is optional. We can use it to specify the network address from which our MTA
accepts messages for relaying without further authentication.
• relayhost
• This parameter contains the name of a host that is used to relay all messages to. Use this if, for
example, we want the mail server of your ISP to take care of all message delivery.
To change any of these parameters make changes in /etc/postfix/main.cf, we can change the
configuration file by hand and restart Postfix.
• By default messages are sent unencrypted in Dovecot. This means that passwords and other sensitive
information can be captured while in transit. For that reason, we should always use POP3S and IMAPS.
2. Run following command to create some self-signed certificates for Dovecot, and install them in
the right locations.
/usr/libexec/dovecot/mkcert.sh
This sends an empty message to user rahul that has only a subject line.
5. Use # su - rahul to become Rahul and start Mutt using # mutt command.
6. From Mutt, hit c to change the mailbox you’re accessing, and enter the
URL
pop://rahul@localhost. This should give us access to our mailbox on the local computer.
Page 21 of 32
YouTube - Abhay More | Telegram - abhay_more
607A, 6th floor, Ecstasy business park, city of joy, JSD road, mulund (W) | 8591065589/022-25600622
TRAINING -> CERTIFICATION -> PLACEMENT BSC IT : SEM - V : LINUX – U4
7. Use c once more, and enter the URL pop3://rahul@localhost. You’ll now have access to themailbox
using the TLS version of POP3.
• Apache is “A PAtCHy server.” It was based on some existing code and a series of “patch files.”
Apache features:
1. Speed: Apache is faster than many other Web servers, including commercial servers.
2. Configurability: Apache is also both easy to configure and easy to reconfigure.
Its configuration information is in plain text files and uses simple English-language directives.
Reconfiguring a running server is also simple, just change configuration directive and restart server.
3. Fewer Bugs: Apache has fewer bugs, Apache’s source code is freely available, so hundreds ofdevelopers
check it, find bugs, fix and submit fixes for inclusion in the code base.
4. Apache is easily extensible using Dynamic Shared Objects (DSOs), more commonly known as
modules. Modules extend Apache’s capabilities and add new features without requiring
recompilation because they can be loaded and unloaded at runtime, just as shared libraries are
dynamically loaded and unloaded.
5. Support very large number of users: Apache uses a binary database format for authenticating
users’ requests for password-protected Web pages. This format enables Apache to support very large
numbers of users.
6. Apache supports virtual hosts, also known as multi-homed servers, which enables a single machine to
provide Web services for multiple domains or IP addresses (or hostnames).
7. Apache enables administrators to define multiple directory index files, the default page to display
when a Web client requests a directory URL. So, for example, the server can return index.html,
index.htm, index.php, or execute a script named index.cgi when a client requests a directory URL,
depending on what Apache finds in the requested directory.
8. Apache has rich support for server logging. We can define custom log file formats and control the
level of detail contained in each log entry. Apache can be configured to generate a unique identifier that
distinguishes one hit from every other hit.
9. Content Negotiation: Apache automatically adjusts to the capabilities of connected Web clients, a
process called content negotiation.
It refers to the technique web clients and servers use to select how to present a resource, such as a
document, that is unavailable in different format.
Page 22 of 32
YouTube - Abhay More | Telegram - abhay_more
607A, 6th floor, Ecstasy business park, city of joy, JSD road, mulund (W) | 8591065589/022-25600622
TRAINING -> CERTIFICATION -> PLACEMENT BSC IT : SEM - V : LINUX – U4
For example: suppose that a web page is available in different languages. One way to select proper
language is to give the user an index page from which he can choose desired language or sever can
choose preferred language automatically using content negotiation based on information a web browser
sends indicating its preference like browser can indicate that it likes to see web page in French, if
possible. If not French then English.
The web browser indicate preference by transmitting specific data in each HTTP request header.
If a Web client is broken in a way that Apache can determine, incompletely or improperly implements
HTTP standards, or does not support a given HTML specification (or, at least, the specification Apache
supports), it sends Web pages modified to give the best representation of the requested information
based on what the client can process.
• The Web client (a browser in this case) first performs a DNS lookup on the server name specified in the
URL, obtains the IP address of the server, and then connects to port 80 at that IP address (or another
port if the server is not using the default HTTP port).
• When the connection is established, the client sends an HTTP GET request for the documentin the
URL, which could be, specific HTML document, an image, a script, or a directory listing etc.
• After the server receives the request, it translates the document URL into a filename on thelocal
system. For example, the document URL http://localhost/college/news.html can become
/home/college/news.html.
• If the document requested has access control Apache Server ask for user name and passwordfrom the
client else reject the request depending on type of access control.
Page 23 of 32
YouTube - Abhay More | Telegram - abhay_more
607A, 6th floor, Ecstasy business park, city of joy, JSD road, mulund (W) | 8591065589/022-25600622
TRAINING -> CERTIFICATION -> PLACEMENT BSC IT : SEM - V : LINUX – U4
If the requested URL specifies a directory than a document, Apache looks for the directoryindex
page, index.html by default, and returns that document to the client. If the directory index page does
not exist, Apache send a directory listing in HTML format back to the client or send an error message,
depending on how the server is configured.
The document can also be a specially written script, a CGI (Common Gateway Interface) script.In this
case, Apache executes the script and sends the results back to the client.
Finally, after Apache has transmitted the requested document and the client receives it, the
client closes the connection and Apache writes an entry in one or more log files.
Welcome to my website
Esc:wq!
4 Use elinks http://localhost to access the website we just created. We’ll notice that our webserver is up
and running.
Welcome to my website
Esc:wq!
Page 24 of 32
YouTube - Abhay More | Telegram - abhay_more
607A, 6th floor, Ecstasy business park, city of joy, JSD road, mulund (W) | 8591065589/022-25600622
TRAINING -> CERTIFICATION -> PLACEMENT BSC IT : SEM - V : LINUX – U4
Use elinks http://localhost to access the website we just created. We’ll notice that our webserver is up
and running.
1. Install Apache
2. Configuration Directives
Apache is highly configurable as it has large number of directives. The primary Apacheconfiguration
file, /etc/httpd/conf/httpd.conf is organized into three sections.
A. Global/Generic Parameters:
• Apache Mode
• Apache can be started in two different modes: the prefork mode and the worker mode.
• The prefork mode is the default mode. In this mode, a master httpd process is started, and this
master process will start different httpd servers.
• As an alternative, the worker mode can be used. In this mode, one httpd process is active, andit uses
different threads to serve client requests.
• There are various performance parameters for both modes.
ServerTokens OS
Page 25 of 32
YouTube - Abhay More | Telegram - abhay_more
607A, 6th floor, Ecstasy business park, city of joy, JSD road, mulund (W) | 8591065589/022-25600622
TRAINING -> CERTIFICATION -> PLACEMENT BSC IT : SEM - V : LINUX – U4
ServerRoot “/etc/httpd”
PidFile /var/run/httpd.pid
<IfModule prefork.c>
StartServers 8
MinSpareServers 5
MaxSpareServers 20
ServerLimit 256
MaxClients 256
MaxRequestsPerChild 4000
</IfModule>
<IfModule worker.c>
StartServers 4
MaxClients 300
MinSpareThreads 25
MaxSpareThreads 75
ThreadsPerChild 25
MaxRequestsPerChild 0
</IfModule>
Listen 80
Include conf.d/*.conf
Directive Description
ServerTokens OS Defines the contents of the server’s HTTP response header.
ServerRoot /etc/httpd defines the root of the configuration directory
PidFile /var/run/httpd.pid Defines the file containing the PID of the master server process
Timeout 60 Defines the maximum time in seconds Apache waits for packet
send and receive operations to complete.
KeepAlive Off If set to On, maintains an open connection to a remote client in the
absence of direct contact for the time specified by KeepAliveTimeout.
MaxKeepAliveRequests 100 Sets the number of requests permitted per connection
KeepAliveTimeout 15 Sets the number of seconds permitted to elapse between requests from the
same client on the same connection when KeepAlive is On
Page 26 of 32
YouTube - Abhay More | Telegram - abhay_more
607A, 6th floor, Ecstasy business park, city of joy, JSD road, mulund (W) | 8591065589/022-25600622
TRAINING -> CERTIFICATION -> PLACEMENT BSC IT : SEM - V : LINUX – U4
StartServers 8 Defines the number of child servers created when Apache starts
MinSpareServers 5 Defines the minimum number of spare (idle) child servers permitted
MaxSpareServers 20 Defines the maximum number of spare (idle) child servers the master
server spawns
ServerLimit 256 Specifies the upper limit on the number of server processes or threads
running simultaneously.
MaxClients 300 Sets the maximum number of simultaneous connections (child servers)
supported
MaxRequestsPerChild 4000 Sets the maximum number of requests each child server fills before
terminating
Listen [ipaddress:]80 Combination of IP address and port on which Apache listens for
connections; multiple Listen directives may be used. If specific IP Address
not mentioned, it will bind to port 80 on all IP addresses that are available.
• The default or primary server refers to the Web server that responds to all HTTP requests not handled
by virtual hosts, also known as virtual servers.
• A virtual server or virtual host is a Web server that runs on the same machine as the default server but
that is distinguished from the main server by a different host name or IP address.
• Table shows directives used to configure the default server. Again, the default values for each
configuration directive, whether assigned by the Apache Group or by Red Hat, are shown in bold face.
Port 80 Defines the port on which the primary server listens for connectionif no
BindAddress or Listen directive specifies a port number with
:port; has no effect otherwise
User [#]apache Specifies the user name or, if prefixed with #, the UID under whichthe
child servers execute
Group [#]apache Specifies the group name or, if prefixed with #, the GID under whicthe
child servers execute
ServerAdmin root@localhost Defines the e-mail address included in error messages displayed tclient
connections
Page 27 of 32
YouTube - Abhay More | Telegram - abhay_more
607A, 6th floor, Ecstasy business park, city of joy, JSD road, mulund (W) | 8591065589/022-25600622
TRAINING -> CERTIFICATION -> PLACEMENT BSC IT : SEM - V : LINUX – U4
DocumentRoot Sets the base directory from which all requested documents will b
“/var/www/html served; document URLs (file names) are interpreted relative to
” DocumentRoot; see also UserDir
ReadmeName README.html Defines README.html as the file whose contents will be appendeto the
end of a directory listing
Port 80
User apache
Group apache
ServerAdmin root@localhost
DocumentRoot “/var/www/html”
<Directory />
Options FollowSymLinks
AllowOverride None
</Directory>
<Directory “/var/www/html”>
Options Indexes Includes FollowSymLinks
AllowOverride None
Order allow,deny
Allow from all
</Directory>
.
.
.
C. Configuring virtual servers
Table shows the Apache configuration directives that control the configuration and behavior ofvirtual
servers.
NameVirtualHost ipaddr[:port] Defines the IP address addr (listening on port, if specified) for a
name-based virtual host.
<Virtual Host ipaddr[:port]> Defines a virtual host whose IP address is addr (listening on port
Directives specified); directives are one or more of the directives listed
previously and override the directives listed for the default server
</VirtualHost>
Page 28 of 32
YouTube - Abhay More | Telegram - abhay_more
607A, 6th floor, Ecstasy business park, city of joy, JSD road, mulund (W) | 8591065589/022-25600622
TRAINING -> CERTIFICATION -> PLACEMENT BSC IT : SEM - V : LINUX – U4
ServerAlias altname Enables the virtual server to respond to one or more alternate ho
names altname when used with name-based virtual hosts.
Port 80
ServerName example.domain.com
NameVirtualHost 192.168.0.1
<VirtualHost 192.168.0.1>
DocumentRoot /var/www/thisdomain
ServerName www.domain.com
</VirtualHost>
<VirtualHost 192.168.0.1>
DocumentRoot /var/www/thatdomain
ServerName www.that.domain.com
</VirtualHost>
3. Starting and Stopping Apache
To start and stop Apache, the preferred method is to use the httpd initialization script and the
service utility.
• There are some additional arguments such as restart, reload and configtest.
• The reload argument signals Apache to reload its configuration files and it is good way to refresh a
running server’s configuration without restarting it and closing all active connections.
• The configtest argument causes Apache to parse its configuration files. If it detects an error, itwill
display an error message indicating what went wrong and where in the configuration file it found
error.
Page 29 of 32
YouTube - Abhay More | Telegram - abhay_more
607A, 6th floor, Ecstasy business park, city of joy, JSD road, mulund (W) | 8591065589/022-25600622
TRAINING -> CERTIFICATION -> PLACEMENT BSC IT : SEM - V : LINUX – U4
Use # chkconfig httpd on to put the Apache web server in our server’s runlevels, and start itat every
boot.
• To extend the functionality of httpd process we can use Dynamic Shared Objects (DSOs),
more commonly known as modules.
• Modules extend Apache’s capabilities and add new features without requiring recompilation
because they can be loaded and unloaded at runtime, just as shared libraries.
• To include Apache modules, they first need to be installed. By default, some of the most
common modules areinstalled to the /etc/httpd/modules directory.
• To tell Apache that it should load a specific module, we need to use the LoadModule
directive.
• If a module is loaded, it can also have a specific configuration. There are three ways toload
additional configurations for modules:
a. Use the IfModule directive in httpd.conf.
b. Put it in an include file.
c. If a module is common, its parameters can be entered in httpd.conf without
furtherspecification.
a. Using IfModule parameter in the httpd.conf file. This approach is more practical formodulesthat
have a limited number of specific directives.
For example:
<IfModule prefork.c>
StartServers 8
MinSpareServers 5
MaxSpareServers 20
ServerLimit 256
MaxClients 256
MaxRequestsPerChild 4000
</IfModule>
Page 30 of 32
YouTube - Abhay More | Telegram - abhay_more
607A, 6th floor, Ecstasy business park, city of joy, JSD road, mulund (W) | 8591065589/022-25600622
TRAINING -> CERTIFICATION -> PLACEMENT BSC IT : SEM - V : LINUX – U4
b. By default, some modules put their configuration in a separate configuration file and store thatfile in
the directory /etc/httpd/conf.d.
The directive include conf.d/*.conf ensures that all configuration files where the name ends in
.conf are included by defaultwhen Apache starts.
c. If a module is very common and almost always used, its parameters can simply be entered inthe
httpd.conf file.
1. Use # yum install -y mysql mysql-server to install the MySQL core components.
2. Use # service mysqld start to start MySQL.
3. Add a MySQL root user
# mysqladmin -u root password ‘password’
It is internal MySQL account and has nothing to do with the Linux root user.
5. Now, we are in MYSQL PromptNow and can use one of the many available SQL commands tocheck
the MySQL internal users. At the MySQL prompt, enter
Page 32 of 32
YouTube - Abhay More | Telegram - abhay_more
607A, 6th floor, Ecstasy business park, city of joy, JSD road, mulund (W) | 8591065589/022-25600622