Professional Documents
Culture Documents
TASK
INSTALLATION TASK
Network File Sharing (NFS) is a protocol that allows you to share directories and files with
other Linux clients over a network. Shared directories are typically created on a file server,
running the NFS server component. Users add files to them, which are then shared with other
users who have access to the folder. An NFS file share is mounted on a client machine,
making it available just like folders the user-created locally. NFS is particularly useful when
disk space is limited and you need to exchange public data between client computers.
Set permissions so that any user on the client machine can access the folder.
To grant access to NFS clients, we’ll need to define an export file. The file is typically located
at /etc/exports
Edit the /etc/exports file in a text editor, and add one of the following three directives.
All the directives below use the options rw, which enables both read and write, sync, which writes
changes to disk before allowing users to access the modified file, and no_subtree_check, which means
NFS doesn’t check if each subdirectory is accessible to the user.
To enable access to a single client /mnt/myshareddir {clientIP}(rw,sync,no_subtree_check)
{clientIP-2}(...)
{clientIP-3}(...)
You can now make the shared directory available to clients using the exportfs command. After running
this command, the NFS Kernel should be restarted.
Samba Overview
“Samba is the standard Windows interoperability suite of programs for Linux and Unix.”
Samba basically allows Unix systems to share files and printers with Windows so that in spite of their
differences, these two systems can peacefully exist.
Samba is also very instrumental in integrating Linux/Unix servers and applications into an Enterprise’s
Active Directory. In this module, we will learn how we can install and set up a samba server with our
Ubuntu distro.
To install samba, we can use the default package manager of our system. In this case, I am using an
Ubuntu machine so my package manager is apt:
To verify that samba was successfully installed, we’ll use the whereis command:
$ whereis samba
First, we need to create a directory that we want to share. Create a directory with the mkdri
command as shown below:
$ mkdir /tmp/sambashare
We created a directory in /tmp folder but you can create it anywhere you choose. Next up we need to
edit the samba config file located under /etc/samba/smb.conf
[sambashare]
comment = Samba And Linux
path = /tmp/sambashare
read only = no
browsable = yes
Analyze:
comment: A brief description of our share
path: The complete path of the directory we are going to share
read-only: This allows the files of the share to be modified by others
browsable: This would allow File Managers to list the share under “Network”
You can start the samba server with the service command:
$ sudo service smbd restart
Note that if you have a firewall like ufw enabled, we need to configure it to allow our samba traffic as
such :
Samba doesn’t use our system account password. Hence, we need to set up a Samba password manually
for our account :
It is a modular, process-based web server application that creates a new thread with each simultaneous
connection. It supports a number of features; many of them are compiled as separate modules and
extend its core functionality and can provide everything from server-side programming language
support to the authentication mechanism. Virtual hosting is one such feature that allows a single Apache
Web Server to serve a number of different websites.
Installing Apache
One of the features of the open-source web application is that anyone can make an installer as
per their own environment. This has allowed various vendors like Debian, Red Hat, FreeBSD,
Suse, etc. to customize the file location and configuration of Apache taking into account other
installed applications and base OS.
Apart from installing it from a vendor-based installer, there is always the option of building and
installing it from the source code. Installing Apache from the source file is platform-independent
& works for all OS.
The Apache web server is a modular application where the administrator can choose the required
functionality and install different modules as per his/her requirement.
All modules can be compiled as Dynamic Shared Objects (DSO is an object file that could be shared by
multiple apps while they are executing) that exist separately from the main Apache file. The DSO
approach is highly recommended, it makes the task of adding/removing/updating modules from the
server’s configuration very simple.
You can install Apache via the default Package Manager available on all Red Hat-based distributions like
CentOs, Red Hat, and Fedora.
[root@amsterdam ~]# yum install httpd
The apache source tarball could be converted into an rpm file using the following command.
[root@amsterdam ~]# rpmbuild -tb httpd-2.4.x.tar.bz2
It is mandatory to have -devel package installed on your server for creating .rpm file from source.
Once you convert the source file into an rpm installer, you could use the following command to install
Apache.
[root@amsterdam ~]# rpm –ivh httpd-2.4.4-3.1.x86_64.rpm
After the installation the server does not start automatically, in order to start the service, you have to
use any of the following command on Fedora, CentOs or Red Hat.
[root@amsterdam ~]# /usr/sbin/apachectl start
Installing apache from the source require the –devel package to be installed on your server. Once you
download the source file move it to the /usr/local/src folder.
[root@amserversterdam ~] cd /usr/local/src
[root@amserversterdam ~] httpd-2.2.26
In order to see all configuration options available for Apache, you can use ./configure –help option. The
most common configuration option is –prefix={install directory name}.
[root@amserversterdam ~] make
The above example shows the compilation of Apache within the /usr/local/apache directory with the
DSO capability. The –enable-so option, can load required modules to apache at run time via the DSO
mechanism rather than requiring a recompilation.
Once the installation completes, you can browse the web server’s default page with your favorite
browser. If a firewall is enabled on your server, you must have to make an exception for port 80 on your
OS firewall. You can use the following command to open port 80.
Virtual Host
An Apache web server can host multiple websites on the SAME server. You do not need a separate
server machine and Apache software for each website. This can achieve using the concept of Virtual
Host or VHost.
Any domain that you want to host on your web server will have a separate entry in apace configuration
file.
Name-based virtual hosting is used to host multiple virtual sites on a single IP address.
In order to configure name-based virtual hosting, you have to set the IP address on which you are going
to receive the Apache requests for all the desired websites. You can do this by NameVirutalHost
directive within the apache configuration i.e. httpd.conf/apache2.conf file.
NameVirtualHost *:80
<VirtualHost 192.168.0.108:80>
ServerAdmin webmaster@example1.com
DocumentRoot /var/www/html/example1.com
ServerName www.example1.com
</VirtualHost>
<VirtualHost 192.168.0.108:80>
ServerAdmin admin@example2.com
DocumentRoot /var/www/html/example2.com
ServerName www.example2.com
</VirtualHost>
You can add as many virtual hosts, as per your requirement. You can check your web configuration files
with:
[root@amsterdam ~]#httpd –t
Syntax OK
If the configuration file has some wrong syntax, it will throw an error
[root@115 conf.d]# httpd -t
Invalid command '*', perhaps misspelled or defined by a module not included in the server
configuration
In order to setup IP based virtual hosting, you need more than one IP address configured on your server.
So, the number of vhost apache will depend on number of IP address configured on your server. If your
server has 10 IP addresses, you can create 10 IP-based virtual hosts.
Listen 192.168.0.100:80
<VirtualHost 192.168.10.108:80>
ServerAdmin webmaster@example1.com
DocumentRoot /var/www/html/example1.com
ServerName www.example1.com
</VirtualHost>
<VirtualHost 192.168.10.109:80>
ServerAdmin admin@example2.com
DocumentRoot /var/www/html/example2.com
ServerName www.example2.com
</VirtualHost>