Thursday, August 10, 2023

INSTALL AND CONFIGURE HTTPD

INSTALL AND CONFIGURE HTTPD, ENABLE PUT METHOD:

 

Here we will see how to install HTTPD(apache server) and enable PUT Method for curl to upload file.

IN this doc we are installing  linux server my server is Linux OEL 7

[root@server ~]# cat /etc/os-release

NOW, we are connecting to root user to install HTTPD

Su - root

yum install httpd ( it will download and install httpd)

systemctl enable httpd (it will enable httpd)

systemctl start httpd (it will start httpd)

check the status of server

 

 

Now check with your  URL http://IP or Hostname

e.g. http://192.168.50.90

 

NOTE : to access the http server from different server we need to enable a port 80

List out the port which are open in my server

firewall-cmd --list-all

First iam adding a port in my server then need to restart firewall for reflect of my port

 

firewall-cmd --add-port=80/tcp –permanent

firewall-cmd –reload

firewall-cmd --list-all  

 

Creating a initial file basic index.html page

When we install httpd it will create html output directory in /var/www/html , iam creating my index.html file under /var/www/html because when apache trying to open page it look under html directory

Just copy paste below index.html file body  and save it.

·       Create index.html file

Cd /var/www/html

Vi index.html

Add entries

<html>

<head>

<title>Welcome to my test site!</title>

</head>

<body>

This site is for testing purposes only

</body>

</html>

 

Now check with your URL it should give a index page which we created

Here we completed the installation of HTTPD ( apache) server,

Now, I am starting to enable put method for curl to upload files in my server

 

Here First iam creating a password file for user apache

·       Create password file

htpasswd -c /home/html/.htpasswd apache

when we run a htpasswd it will ask promt two times for password, please make sure to keep this password save as it require when we upload a file with curl

I am creating my password file I location  /home/html you can create any location but make sure this password file location will b update in httpd configuration file

Which will see in below steps

Here we are  doing changes in httpd configuration file please make according to your environment in below lines

·       Make changes in httpd configuration file –

/etc/httpd/conf

Vi httpd.conf

 

1)       

#

# Deny access to the entirety of your server's filesystem. You must

# explicitly permit access to web content directories in other

# <Directory> blocks below.

#

<Directory />

    AllowOverride none

    Require all denied

</Directory>

 

2)

 

#

# Relax access to content within /var/www.

#

<Directory "/var/www">

    AllowOverride None

    # Allow open access:

    Require all granted

</Directory>

 

3)

Enable DAV

 

    #

    # Controls who can get stuff from this server.

    #

   #Require all granted

        Dav On

        AuthType Basic

        AuthUserFile "/home/html /.htpasswd"

        AuthName "Staging Area"

        Require valid-user

 

</Directory>

 

4)

# The following lines prevent .htaccess and .htpasswd files from being

# viewed by Web clients.

#

<Files ".ht*">

    Require all denied

</Files>

 

5)

 

Add –

    #

    MIMEMagicFile conf/magic

</IfModule>

 

<IfModule mod_dav_fs.c>

    # Location of the WebDAV lock database.

    DAVLockDB /var/lib/dav/lockdb

</IfModule>

 

 

Give apache user permission

 

·       Give permission :

Apache permission to /var/www/html and /var/lib/dav

Chown apache:apache /var/www/html

Chown apache:apache /var/lib/dav

 

Here I am setting  SELINUX to permissive after setting this it will required boot server for reflect this is important if not your see a permission error

·       Make  SELINUX = permissive in /etc/selinux config file

SELINUX=permissive

 

Now restart the httpd and run the curl command

·       Bounce httpd

Systemctl restart httpd

·       Now run curl command

curl --user apache:XXXX  --upload-file filename   http://HOSTIP

note : make sure credential must b correct which create is htpasswd file

 

 

 

 

 

Sunday, July 16, 2023

Docker : Install Docker on Oracle Linux 7

 


Docker : Install Docker on Oracle Linux 7 (OL7)


Install Docker

Enable all the required repositories. To do this you are going to need the yum-utils package.


yum install -y yum-utils zip unzip

yum-config-manager --enable ol7_optional_latest

yum-config-manager --enable ol7_addons


yum install -y oraclelinux-developer-release-el7

yum-config-manager --enable ol7_developer

Install Docker and BTRFS.


yum install -y docker-engine btrfs-progs btrfs-progs-devel

Configure BTRFS

By default the containers are created under the "/var/lib/docker", so you really need to house this on a separate disk or in a separate partition, preferably using BTRFS as the file system.

NOTE : you can keep docker in default location or can create new mount .

I have a second LUN with a device named "/dev/sdb". I could build the file system on this disk directly, but I prefer to partition the disks with a single partition using fdisk. These responses will create a new partition using the whole of the disk ("n", "p", "return", "return", "return", "w").


# fdisk /dev/sdb

Welcome to fdisk (util-linux 2.23.2).


Changes will remain in memory only, until you decide to write them.

Be careful before using the write command.


Device does not contain a recognized partition table

Building a new DOS disklabel with disk identifier 0x2ccc116e.


Command (m for help): n

Partition type:

   p   primary (0 primary, 0 extended, 4 free)

   e   extended

Select (default p): p

Partition number (1-4, default 1): 

First sector (2048-25165823, default 2048): 

Using default value 2048

Last sector, +sectors or +size{K,M,G} (2048-25165823, default 25165823): 

Using default value 25165823

Partition 1 of type Linux and of size 12 GiB is set


Command (m for help): w

The partition table has been altered!


Calling ioctl() to re-read partition table.

Syncing disks.

#

Make the BTRFS file system on the "sdb1" partition. The Oracle Linux 7 Configuring Docker Storage manual describes how to use the docker-storage-config utility to do this with a single command.


# docker-storage-config -s btrfs -d /dev/sdb1

Creating 'btrfs' file system on: /dev/sdb1

#

We can see the file system is added to the "/etc/fstab" file and has been mounted under "/var/lib/docker" by the utility.


# cat /etc/fstab


#

# /etc/fstab

# Created by anaconda on Tue Nov 14 11:49:55 2017

#

# Accessible filesystems, by reference, are maintained under '/dev/disk'

# See man pages fstab(5), findfs(8), mount(8) and/or blkid(8) for more info

#

/dev/mapper/ol-root     /                       xfs     defaults        0 0

UUID=196ae589-c060-46b9-87dc-49d3ed2b01e7 /boot                   xfs     defaults        0 0

/dev/mapper/ol-swap     swap                    swap    defaults        0 0

UUID=10dbd6c1-8ae4-420e-91d8-b021f334e82b /var/lib/docker btrfs defaults 0 0 # added by docker-storage-config

#



# df -h

Filesystem           Size  Used Avail Use% Mounted on

devtmpfs             7.7G     0  7.7G   0% /dev

tmpfs                7.8G     0  7.8G   0% /dev/shm

tmpfs                7.8G   25M  7.7G   1% /run

tmpfs                7.8G     0  7.8G   0% /sys/fs/cgroup

/dev/mapper/ol-root   45G   25G   21G  55% /

/dev/sda1            497M  291M  206M  59% /boot

tmpfs                1.6G   12K  1.6G   1% /run/user/42

tmpfs                1.6G     0  1.6G   0% /run/user/0

/dev/sdb1            100G   17M   98G   1% /var/lib/docker

#

If we didn't have access to the docker-storage-config utility we could have used the following commands.


# mkfs.btrfs -f -L docker1 /dev/sdb1

# systemctl stop docker.service

# rm -Rf /var/lib/docker

# mkdir /var/lib/docker

# echo "LABEL=docker1  /var/lib/docker btrfs defaults 0 0" >> /etc/fstab

# mount /var/lib/docker

Finish Docker Setup

Enable and start the Docker service.


# systemctl enable docker.service

# systemctl start docker.service

You can get information about docker using the following commands.


# systemctl status docker.service

# docker info

# docker version

You are now ready to start using Docker!