Sunday, November 1, 2015

Install Cacti - CentOS 6

Install Cacti - CentOS 6

OS: CentOS 6.5 - 64bits
IP: 124.124.124.160/24

Install Apache
yum install httpd httpd-devel
Install MySQL
yum install mysql mysql-server
Start service mysqld
/etc/init.d/mysqld start
Enable mysqld service permanently
chkconfig mysqld on
Reset password for mysql to new password is "rhce2015"
mysqladmin -u root -p password rhce2015
Install PHP
yum install php-mysql php-pear php-common php-gd php-devel php php-mbstring php-cli php-mysql
Install PHP-SNMP
yum install php-snmp
Install NET-SNMP
yum install net-snmp-utils net-snmp-libs php-pear-Net-SMTP
Install RRDtool
yum install rrdtool
Start service: Apache, MySQL and SNMP
/etc/init.d/httpd start
/etc/init.d/mysqld start
/etc/init.d/snmpd start
Enable service: Apache, MySQL and SNMP to startup
chkconfig httpd on
chkconfig mysqld on
chkconfig snmpd on
Add Repository
wget http://download.fedoraproject.org/pub/epel/6/x86_64/epel-release-6-8.noarch.rpm
rpm -ivh epel-release-6-8.noarch.rpm
Installing Cacti Tool
yum install cacti
Configure MySQL
Login to mysql as user "root" and create user and database for cacti
mysql -u root -p
mysql> create database cacti;
mysql> GRANT ALL ON cacti.* TO cacti@localhost IDENTIFIED BY 'centos65';
mysql> flush privileges;
mysql> exit
Find cacti.sql file
rpm -ql cacti | grep cacti.sql
/usr/share/doc/cacti-0.8.8b/cacti.sql
Restore default cacti database to our created database
mysql -u cacti -p cacti < /usr/share/doc/cacti-0.8.8b/cacti.sql
Edit cacti database
vi /etc/cacti/db.php
/* make sure these values refect your actual database/host/user/password */
$database_type = "mysql";
$database_default = "cacti";        ## Name of the Cacti Database ##
$database_hostname = "localhost";
$database_username = "cacti";       ## Username for Cacti database ##  
$database_password = "centos65";              ## Database password ##
$database_port = "3306";
$database_ssl = false;
/*

Configure Apache server
vi /etc/httpd/conf.d/cacti.conf
With content
Alias /cacti /usr/share/cacti
 <Directory /usr/share/cacti/>
     <IfModule mod_authz_core.c>
     # httpd 2.4
     Require host localhost
          </IfModule>
               <IfModule !mod_authz_core.c>
                 # httpd 2.2
                 Order deny,allow
                 Deny from all
                 Allow from 124.124.124.0/24
          </IfModule>
 </Directory>
  

Restart Apache
/etc/init.d/httpd restart
Allow port 80 in iptables
vi /etc/sysconfig/iptables
Add this line
-A INPUT -m state --state NEW -m tcp -p tcp --dport 80 -j ACCEPT
Restart iptables
/etc/init.d/iptables restart
Configure Cron for Cacti
vi /etc/cron.d/cacti
with this content
*/5 * * * * cacti /usr/bin/php /usr/share/cacti/poller.php > /dev/null 2>&1

Run Cacti installer
http://124.124.124.160/cacti
New Install
Finish installation

Login into cacti with default username and password is admin.
And this page will forced us to change the default password
Loged in


Add other server:
Devices --> Add -->

Here is the sample of graph Memory Usage


#CentOS #Cacti #Vannakk

Install Mail Server - CentOS

Install Mail Server - CentOS

OS: CentOS 6.5 - 64bits

ServerName: mailsrv01.lnx.org
Server IP: 124.124.124.201

What we are going to set up:
1. Install and configure Postfix
2. Install and configure Dovecot
3. Install and configure Web Mail (Squirrel Mail)

1. Install and configure Postfix
yum install postfix
Copy the the original file
cp /etc/postfix/main.cf /etc/postfix/main.cf.orig

Edit main configuration file of postfix
vi /etc/postfix/main.cf
With content
myhostname = mailsrv01.lnx.org

mydomain = lnx.org

myorigin = $mydomain

inet_interfaces = all

inet_protocols = all


mydestination = $myhostname, localhost.$mydomain, localhost, $mydomain

mynetworks = 124.124.124.0/24, 127.0.0.0/8

home_mailbox = Maildir/

Restart postfix and enable in start up
service postfix restart
chkconfig postfix on

Create username : userlnx1 and set the password
useradd userlnx1
passwd userlnx1

Install telnet and test smtp
yum install telnet
telnet localhost smtp

ehlo localhost

mail from: 

rcpt to: 

data

welcome to LNX mail server 
.
quit

ls /home/userlnx1/Maildir/new/
(We should see the file that contain the email content)

2. Install and configure Dovecot

yum install dovecot
Copy the original file
cp /etc/dovecot/dovecot.conf /etc/dovecot/dovecot.conf.orig
Edit File
vi /etc/dovecot/dovecot.conf
With content
protocols = imap pop3 lmtp
Copy the original file
cp /etc/dovecot/conf.d/10-mail.conf /etc/dovecot/conf.d/10-mail.conf.orig
Edit File
vi /etc/dovecot/conf.d/10-mail.conf 
With content
mail_location = maildir:~/Maildir
Copy the original file
cp /etc/dovecot/conf.d/10-auth.conf  /etc/dovecot/conf.d/10-auth.conf.orig
Edit File:
vi /etc/dovecot/conf.d/10-auth.conf 
With content
disable_plaintext_auth = yes

auth_mechanisms = plain login
Copy the original file
cp /etc/dovecot/conf.d/10-master.conf  /etc/dovecot/conf.d/10-master.conf.orig
Edit File
vi /etc/dovecot/conf.d/10-master.conf 
With content
## Line 83, 84 - Uncomment and add "postfix"
#mode = 0600
   user = postfix
  group = postfix

Start service and enable in start up
service dovecot start
chkconfig dovecot on
Test POP3
telnet localhost pop3
user userlnx1
pass rhce2015
retr 1

quit

3. Install and configure Web mail  (Squirrel Mail)
Download and install  CentOS 6. repostory
wget http://download.fedoraproject.org/pub/epel/6/x86_64/epel-release-6-8.noarch.rpm
rpm -ivh epel-release-6-8.noarch.rpm
Install Squirrelmail
yum install squirrelmail
Go to configure directory
cd /usr/share/squirrelmail/config/
and Run the perl script
./conf.pl
The following wizard will open. Enter choice “1” to set your organization details:
The following wizard will open. Enter “1” again to modify your organization details:
[SquirrelMail]: LNX-Org

By this way, setup all the details such as organization title, logo, provider name in the above wizard.
Once you done, press “S” to save changes and press “R” to return back to your main menu:

Now enter “2” to setup mail Server settings such as domain name and mail agent etc.:

Enter “1”, Enter your mail domain (ex. lnx.org) and press Enter key.

Enter “3” and change from sendmail to Postfix MTA (i.e. SMTP):

Enter “2” to switch from sendmail MTA to postfix.

Now enter “S” followed by “Q” to save and exit Squirrelmail configuration.
Command >> Q


Exiting conf.pl.
You might want to test your configuration by browsing to
http://your-squirrelmail-location/src/configtest.php
Happy SquirrelMailing!
Access to check the config of squirrelmail
http://124.124.124.201/webmail/src/configtest.php
If you got this error message
ERROR: Error connecting to SMTP server "localhost:25".Server error: (13) Permission denied
Run this command
setsebool httpd_can_network_connect=1
Allow port 25 in iptables
vi /etc/sysconfig/iptables
Add this line
-A INPUT -m state --state NEW -m tcp -p tcp --dport 25 -j ACCEPT
Restart iptables
/etc/init.d/iptables restart
Copy the original file
cp /etc/httpd/conf/httpd.conf /etc/httpd/conf/httpd.conf.orig
Edit file
vi /etc/httpd/conf/httpd.conf 
With content
Alias /webmail /usr/share/squirrelmail

    Options Indexes FollowSymLinks
    RewriteEngine On
    AllowOverride All
    DirectoryIndex index.php
    Order allow,deny
    Allow from all

Restart Apache
service httpd restart
Allow port 80 in iptables
Edit file
vi /etc/sysconfig/iptables
with this content
-A INPUT -m state --state NEW -m tcp -p tcp --dport 80 -j ACCEPT
Restart iptables
/etc/init.d/iptables restart

Create username: userlnx2 and set the password
useradd userlnx2
passwd userlnx2

Log into webmail with user : userlnx1 and send email to userlnx2.
http://124.124.124.201/webmail/

and login as user: userlnx2 to check the mail mail server we can login and send the email.
Done,



#Postfix #Dovecot #Webmail #SquirrelMail #Vannak