Showing posts with label Apache. Show all posts
Showing posts with label Apache. Show all posts

Monday, 19 December 2016

How to install & configure MRTG with RRDTools and Router2 on Ubuntu 14.04


Install & configure MRTG with RRDTools and Router2 on Ubuntu 14.04



What is MRTG?
The Multi Router Traffic Grapher (MRTG) is a tool to monitor the traffic load on network links. MRTG generates HTML pages containing PNG images which provide a LIVE visual representation of this traffic.

What is RRDTool?
RRDtool is the OpenSource industry standard, high performance data logging and graphing system for time series data. RRDtool can be easily integrated in shell scripts, perl, python, ruby, lua or tcl applications.

What is Router2?
routers2.cgi is a frontend to data stored in rrdtool databases. This is written in Perl, and requires the MRTG system to collect the data. Although the name would indicate otherwise, this frontend will work in the same way as 14all.cgi, and can provide a generic frontend for ALL MRTG collected data.

Step 1: Update & Upgrade the Ubuntu Server:

# apt-get -y update
# apt-get -y upgrade

Step 2: Preparation for Installing MRTG With RRDTools and Router2:

# apt-get -y install mrtg mrtg-ping-probe rrdtool librrds-perl snmp snmpd snmp-mibs-downloader libapache2-mod-perl2 libnet-snmp-perl libgd-gd2-perl

*Note: The installation requires round about 60 packages. Attention: The installation process from MRTG asks a single question, whether or not the root user should be the only one who can read the default configuration file from MRTG (/etc/mrtg.cfg). In our scenario, this can be answered with “Yes”, which is also the default option in this question.

Step 3: Install WebServer (Apache2) & Php-fpm and Preconfigured it according to the MRTG and Router2:

# apt-get -y install apache2
# vi /etc/apache2/sites-available/000-default.conf

#### Comment out/Delete all the lines and add the following lines;

<VirtualHost *:80>
        ServerAdmin webmaster@localhost
        DocumentRoot /var/www/

        ScriptAlias /cgi-bin/ /usr/lib/cgi-bin/
         <Directory "/usr/lib/cgi-bin/">
                 AllowOverride None
                 Options +ExecCGI -MultiViews +SymLinksIfOwnerMatch
                 Require all granted
         </Directory>
        ErrorLog ${APACHE_LOG_DIR}/error.log
        CustomLog ${APACHE_LOG_DIR}/access.log combined
</VirtualHost>

--- Save & Quit (:wq) ---

# apt-get -y install php5-fpm php5
# service apache2 restart
# service php5-fpm restart

# vi /var/www/index.html

### Add these lines

<head>
<meta http-equiv="refresh" content="0; URL=http://<IP-Address-Of-Server>/cgi-bin/routers2.cgi">
</head>

--- Save & Quit (:wq) ---

Step 4: Configure the Environment for the MRTG with RRDTool:

*Note: We must create some folders in order to store our configuration and rrd files. I decided to store the configs under the /etc folder while the rrd files under the /var folder.

# mkdir /var/mrtg #for rrd directory
# mkdir /etc/mrtg #for config files

*Note: Note that RRDtool itself needs no further configuration since it is always used from Routers2 directly and thus needs no specific configuration.

# cd /tmp
# wget http://www.steveshipway.org/software/rrd/routers2-v2.23.tar.gz
# tar xfv routers2-v2.23.tar.gz
# cd routers2-v2.23/
# perl install.pl

Continue [yes]? yes
Document root? /var/www
CGI directory? /usr/lib/cgi-bin
MRTG config directory? /etc/mrtg
MRTG files [*.cfg]? Enter
RRD directory [/tmp]? /var/mrtg
Perl executable [/usr/bin/perl]? Enter
Configuration file [/var/mrtg/routers2.conf]? Enter
Activate routingtable extensions [no]? Enter
'usebigk' option [mixed]? no
auth option [none]? Enter
Caching option [no]? Enter
Can I mail [no]? Enter

INSTALLING SOFTWARE

Perl is     : /usr/bin/perl
MRTG files  : /etc/mrtg/*.cfg
RRD files   : /var/mrtg
Doc root    : /var/www
CGI bin     : /usr/lib/cgi-bin
Config file : /var/mrtg/routers2.conf
Routingtable: INACTIVE
Compact page: ENABLED
Caching     : DISABLED
'usebigk'   : no
Auth option : NONE
Mail Steve  : no
Other options can be set later by modifying the Config file
Continue to install [no]? yes

# vi /var/mrtg/routers2.conf

### Add these lines at the end of the file,

charset = utf-8         #Since otherwise the degree symbol ° isn't displayed correctly
actuals = yes           #Show actual values in a popup
defaulttarget = summary #Show the summary page first
graphstyle = x3         #Show the biggest image by default
graphtype = w           #Show the weekly graph by default
percentile = yes        #Percentile calculation
sorder = l2 l2D x3 x3D  #Offer only the huge images
showtotal = yes         #A total line on the incoming and outgoing graphs
compact = no            #I am not using the compact graphs. Maybe you want to...
daystart = 8            #For displaying a highlighted area for the working day
dayend   = 18           #Ditto
windowtitle = Title     #Here you can customize the title of the webpage
bgcolour = #fffffff     #Otherwise some targets have a purple background
twinmenu = yes          #Since we all have widescreen displays nowadays
showfindbox = no        #I am not monitoring that many devices

--- Save & Quit (:wq) ---

# vi /etc/mrtg.cfg

## Comment out/Delete all the Lines and add the following lines at the end

#Directory in which the RRD files will be stored
WorkDir: /var/mrtg
#Tells MRTG to use RRD instead of its own log format
LogFormat: rrdtool
#To have multiple instances of MRTG running to immediately pass through all targets
Forks: 4
#Use the configs in the mrtg subfolder (/etc/mrtg)
Include: mrtg/*.cfg

--- Save & Quit (:wq) ---

# a2enmod cgi
# service apache2 restart

Step 5: Test the Setup on Browser:

http://<ip-address>/cgi-bin/routers2.cgi or http://<ip-address>

Thanks For Visiting on My Blog, For More Tutorials Keep Visiting My Blog.


Monday, 11 July 2016

How to Install & Configure Apache for both GUI & CLI mode on CentOS/RHEL 6.X

Install & Configure Apache for both GUI & CLI mode on CentOS/RHEL 6.X


What is ApacheGUI?


This tools is a free and open source package designed for system administrators to manage the functionality of Apache Web Server from a browser, such as edit configuration and web document files directly from browser, download, search or visualize Apache Logs in real time, install, edit or remove Apache modules, view runtime statistics or detailed graphs transactions of Apache HTTP Server.



Step 1: Stop the Selinux, and Update the Date Time on the Server :



# vi /etc/sysconfig/selinux

SELINUX=disabled ###(Change enabled to disabled)

--- save & quit (:wq) ---

# service iptables stop
# chkconfig iptabes off
# yum -y install ntpd
# service ntpd restart
# ntpdate pool.ntp.org
# chkconfig ntpd on

Step 2: Install Java of your choise. here installed open jdk you can install oracle java also:



# yum -y install httpd httpd-develjava

Step 3: Download ApacheGUI:



# cd /opt
# wget http://jaist.dl.sourceforge.net/project/apachegui/1.11-Linux-Solaris-Mac/ApacheGUI-1.11.0.tar.gz
# tar -zxvf ApacheGUI-1.11.0.tar.gz
# cd ApacheGUI/bin

Step 4.Start the server:



# ./run.sh
# service iptables stop

If you want to Change the server port from 9999.

# vi /opt/ApacheGUI/tomcat/conf/server.xml

find 9999 and change to any port you like.

Step 5. Configure Apache GUI:



Browse : http://Server-IP/Domain:9999/ApacheGUI/



Use following credentials to login into ApacheGUI tool If Asked

Username: admin
Password: admin

Step 6. Configure Apache GUI from Web Panel :


Next, the tool will prompt you on How Apache Web Server was installed?
Choose Package option, if you installed Apache on RHEL/CentOS using yum package management tool and hit OK to move forward.

Server Root: /etc/httpd
Primary Configuration File: /etc/httpd/conf/httpd.conf
Configuration Directory: /etc/httpd
Log Directory: /logs
Modules Directory: /etc/httpd/modules
Binary File: /usr/sbin/apachectl
Username: root
Password: redhat
Password: redhat

** After you finish hit on Submit button to apply configuration and you’re done.
** Now you can control Apache Web Server with all its configuration files and edit web documents directly from your browser

Step 7. Create init script for Apache GUI :



# vi /etc/init.d/apache-gui

#!/bin/sh
#
#
# System startup script for apache-gui
#
### BEGIN INIT INFO
# Provides: apache-gui
# Default-Start:     2 3 4 5
# Default-Stop:      0 1 6
# Short-Description: Start the apache-gui
# Description:       Start the apache-gui
### END INIT INFO
#
# chkconfig: 2345 20 80
# description: Runs the apache-gui
# processname: apache-gui
#
# Source function library
. /etc/init.d/functions

case "$1" in
    start)
    cd /opt/ApacheGUI/bin/
./run.sh
       ;;
    stop)
   cd /opt/ApacheGUI/bin/
./stop.sh
        ;;
restart)
cd /opt/ApacheGUI/bin/
./stop.sh
./run.sh
    *)
        echo $"Usage: $0 {start|stop}"
        exit 2
esac
exit $?

--- save & quit (:wq) ---

# chmod 755 /etc/init.d/apache-gui

** Start apchegui as the service now.

# service apache-gui start
# service apache-gui stop
# chkconfig apache-gui on

Thanks For Visiting on My Blog, For More Tutorials Keep Visiting My Blog.

Sunday, 7 February 2016

How to Install LAMP Server on Centos/RHEL 6.X

LAMP Server on Centos/RHEL 6.X

Step 1: Install Apache

# yum -y install httpd httpd-devel

Start httpd Service

#/etc/init.d/httpd start

Edit httpd.conf file

# vi /etc/httpd/conf/httpd.conf

### Just Add this Line
#ServerName www.example.com:80
ServerName (ip address of server):80

--- Save &amp; Quit (:wq) ---

Step 2: Go to /var/www/html and Make A HTML page

# vi index.html

Restart httpd Service:

#/etc/init.d/httpd restart

Step 3: Install MySQL Database Server

# yum -y install mysql mysql-server mysql-devel

Start Mysqld Service

# /etc/init.d/mysqld start

Changing MySQL Root Password:

# mysql
mysql&gt; USE mysql;
mysql&gt; UPDATE user SET Password=PASSWORD('sql') WHERE user='root';
mysql&gt; FLUSH PRIVILEGES;
mysql&gt; exit

Check by logging:

#mysql -u root -p
Enter Password:

mysql&gt; show databases;
++
| Database |
++
| information_schema |
| mysql |
++
2 rows in set (0.00 sec)

mysql&gt; exit

Step 4: Install PHP5 Scripting Language

# yum -y install php php-mysql php-common php-gd php-mbstring php-mcrypt php-devel php-xml

Step 5: Create a file named /var/www/html/info.php

# vi /var/www/html/info.php

phpinfo();
?&gt;

--- Save &amp; Quit (:wq) ---

# /etc/init.d/httpd restart

Step 6: Then point your browser to http://ip address/info.php

http://(Your-IP/Hostname)/info.php

Step 7: Download this phpMyAdmin rpm

# cd /var/www/html
# wget https://files.phpmyadmin.net/phpMyAdmin/4.0.10.14/phpMyAdmin-4.0.10.14-all-languages.tar.gz

Extract the tar File &amp; Rename it :

# tar -zxvf phpMyAdmin-4.0.10.14-all-languages.tar.gz
# ls
# mv phpMyAdmin-4.0.10.14-all-languages phpmyadmin
# ls

Edit the /etc/httpd/conf/httpd.conf File :

# vi /etc/httpd/conf/httpd.conf
Add those Lines :


Options +Indexes +Multiviews
DirectoryIndex index.php index.html
AllowOverride All
Allow from all

--- Save &amp; Quit (:wq) ---

Rename the config.sample.inc.php File

# mv config.sample.inc.php config.inc.php

Step 8: Start the httpd &amp; mysql Service on Boot &amp; stop iptables &amp; Disable the selinux

# chkconfig httpd on
# chkconfig mysqld on
# service iptables stop
# chkconfig iptables off
# setenforce 0

Point your browser to

http://(Your-IP/Hostname)/phpmyadmin

Thanks For Visiting on My Blog, For More Tutorials Keep Visiting My Blog.