Apache Network Based Authentication

Step 1. Open the httpd.conf file and go to the bottom of the file & put the below mentioned entries

[root@localhost ~]# vim /etc/httpd/conf/httpd.conf 

 
ServerAdmin root@localhost.localdomain 
DocumentRoot /var/www/html
< Directory /var/www/html >
Order Allow, Deny
Allow from 10.0.0.0/8
Deny from All

ServerName www.linuxonlinesolutions.com 
ErrorLog /etc/httpd/logs/error_log 
CustomLog /etc/httpd/logs/access_log common 
 

Here above, i defined the order to access the website. There are only two options that can be used, allow and deny. Put the ip range which you want to allow and deny all other networks.
Read more »

Apache User Based Authentication

Step 1. Open the httpd.conf file and go to the bottom of the file & put the below mentioned entries

[root@localhost ~]# vim /etc/httpd/conf/httpd.conf 

 
ServerAdmin root@localhost.localdomain 
DocumentRoot /var/www/html
< Directory /var/www/html >
AllowOverride Authconfig

ServerName www.linuxonlinesolutions.com
ErrorLog /etc/httpd/logs/error_log 
CustomLog /etc/httpd/logs/access_log common 
 

Here above ‘AllowOverride Authconfig’ means that the www.linuxonlinesolutions.com will require password authorization to access the web page in the mentioned directory.

Step 2. Restart the httpd service

[root@localhost ~]# service httpd restart

Step 3. Create a file .htaccess in your website where your web page is stored and put the following entries.

[root@localhost~]# vim /var/www/html/.htaccess
 Read more »

Basic Apache Configuration

In our last article, we have learned about the working of a web server. But do u know which are the most popular web servers of world. If not, then i am going to tell you about them. The web server software that we use, depends on the operating system that we are using. Microsoft Windows systems uses IIS [Internet Information Server], whereas most of the Unix based operating systems uses Apache web Server. Apache is the most popular web server of the world. Most of the Internet users believe that a web sites success depends upon its content and promotion. But this is not enough. A correct choice of web server is as important as content of website. Before choosing a web server we should consider its capabilities and support.

We are going to learn Apache. Apache was released in 1995 by Apache Software Foundation. Apache is an open source web software application that can run on most of the Operating system platform including Windows, Linux, Unix, Solaris, Novell Net Ware and Mac OS. Apache is released under Apache License. It is the biggest competitor of Microsoft’s IIS, which is a paid web software application. Apache supports virtual hosting which means we can configure more than one website on a single pc. Currently Apache is a giant in the field of Web Servers and you can verify it by searching in Internet. Apache holds about 60% of market share in the market of Web Servers. Apache is the best web server till now, so we are going to configure it on our Linux machine.

Now lets configure Basic Apache Web Server on our Linux machine:

Step 1. Install http package and Start its service.

[root@localhost ~]# yum install http* -y 
 Read more »

Database Backup Script

Scenario: Create a backup script to take Backup of mysql databases on remote server to your local backup server and remove existing backups older than 7 days.

Solution:


#!/bin/bash

DB_BACKUP="/Databases/`date +%A`"
DB_USER="root"
DB_PASSWD="Pass@7rt5_890#"
DB_HOST='172.24.25.154'

# Remove backups older than 7 days
find /Databases -maxdepth 1 -type d -mtime +7 -exec rm -rf {} \;

# Create the backup directory
mkdir -p $DB_BACKUP

for db in $(mysql -h $DB_HOST  -u $DB_USER -p$DB_PASSWD -e 'show databases' -s --skip-column-names|grep -vi information_schema);
do mysqldump -h $DB_HOST -u $DB_USER -p$DB_PASSWD --opt  --skip-add-locks --routines $db | gzip > "$DB_BACKUP/$db-$(date +%Y-%m-%d).gz";

done