How to Setup Apache httpd on CentOS Dedicated Server

apachehttpdThe Apache HTTP Server is a free or open source Web server developed by the Apache Software Foundation (http://www.apache.org/). This post describes the basic steps to setup Apache httpd on CentOS 6.4 64 bit dedicated server to host the website and blog. Having dedicated web server, you will get more control and flexibility on the configuration and you does not share its resources with anyone else. With at least 2GB RAM, you will get fairly consistent load times and better speed if compared to shared hosting and virtual private server (VPS). Bloggers or webmasters can get reasonable dedicated server price starting at $139 at very reputable companies such as hostgator.

1. How to Install httpd :

[root@centos64 ~]# yum install httpd -y

2. How to Check Apache server version :

[root@centos64 ~]# httpd -V
Server version: Apache/2.2.15 (Unix)
Server built:   Feb 22 2013 11:19:58
Server's Module Magic Number: 20051115:25
Server loaded:  APR 1.3.9, APR-Util 1.3.9
Compiled using: APR 1.3.9, APR-Util 1.3.9
Architecture:   64-bit
Server MPM:     Prefork
  threaded:     no
    forked:     yes (variable process count)
Server compiled with....
 -D APACHE_MPM_DIR="server/mpm/prefork"
 -D APR_HAS_SENDFILE
 -D APR_HAS_MMAP
 -D APR_HAVE_IPV6 (IPv4-mapped addresses enabled)
 -D APR_USE_SYSVSEM_SERIALIZE
 -D APR_USE_PTHREAD_SERIALIZE
 -D SINGLE_LISTEN_UNSERIALIZED_ACCEPT
 -D APR_HAS_OTHER_CHILD
 -D AP_HAVE_RELIABLE_PIPED_LOGS
 -D DYNAMIC_MODULE_LIMIT=128
 -D HTTPD_ROOT="/etc/httpd"
 -D SUEXEC_BIN="/usr/sbin/suexec"
 -D DEFAULT_PIDLOG="run/httpd.pid"
 -D DEFAULT_SCOREBOARD="logs/apache_runtime_status"
 -D DEFAULT_LOCKFILE="logs/accept.lock"
 -D DEFAULT_ERRORLOG="logs/error_log"
 -D AP_TYPES_CONFIG_FILE="conf/mime.types"
 -D SERVER_CONFIG_FILE="conf/httpd.conf"

3. Change /etc/hosts file :

[root@centos64 ~]# vi /etc/hosts
127.0.0.1   localhost localhost.localdomain localhost4 localhost4.localdomain4
::1         localhost localhost.localdomain localhost6 localhost6.localdomain6

192.168.2.62 centos64.ehowstuff.local

4. Always backup the original configuration file before doing any changes :

[root@centos64 ~]# cp -p /etc/httpd/conf/httpd.conf /etc/httpd/conf/httpd.conf.backup.01042013

Note : -p mean preserve the specified attributes (default: mode,ownership,timestamps)

5. How to Configure httpd Apache service :

[root@centos64 ~]# vi /etc/httpd/conf/httpd.conf
ServerTokens Prod
KeepAlive On
ServerAdmin root@ehowstuff.local
ServerName www.ehowstuff.local:80
Options Indexes FollowSymLinks ExecCGI
AllowOverride All
DirectoryIndex index.html index.cgi index.php
ServerSignature Off
#AddDefaultCharset UTF-8
AddHandler cgi-script .cgi .pl

6. Restart Apache httpd :

[root@centos64 ~]# /sbin/service httpd restart
Stopping httpd:                                            [  OK  ]
Starting httpd:                                            [  OK  ]

7. How to configure Apache httpd auto start at boot :

[root@centos64 ~]# chkconfig httpd on

8. How to check the apache access log :

[root@centos64 ~]# tail -f /var/log/httpd/access_log
192.168.2.52 - - [01/Apr/2013:23:14:35 +0800] "GET /index.php?=PHPE9568F34-D428-11d2-A769-00AA001ACF42 HTTP/1.1" 200 2524 "http://192.168.2.62/" "Mozilla/5.0 (Windows NT 5.1; rv:18.0) Gecko/20100101 Firefox/18.0"
192.168.2.52 - - [01/Apr/2013:23:14:35 +0800] "GET /index.php?=PHPE9568F35-D428-11d2-A769-00AA001ACF42 HTTP/1.1" 200 2146 "http://192.168.2.62/" "Mozilla/5.0 (Windows NT 5.1; rv:18.0) Gecko/20100101 Firefox/18.0"
192.168.2.52 - - [01/Apr/2013:23:14:35 +0800] "GET / HTTP/1.1" 200 71412 "-" "Mozilla/5.0 (Windows NT 5.1; rv:18.0) Gecko/20100101 Firefox/18.0"
192.168.2.52 - - [01/Apr/2013:23:14:36 +0800] "GET /favicon.ico HTTP/1.1" 404 209 "-" "Mozilla/5.0 (Windows NT 5.1; rv:18.0) Gecko/20100101 Firefox/18.0"
192.168.2.52 - - [01/Apr/2013:23:14:36 +0800] "GET /favicon.ico HTTP/1.1" 404 209 "-" "Mozilla/5.0 (Windows NT 5.1; rv:18.0) Gecko/20100101 Firefox/18.0"

How to Configure Static IP Address on CentOS 6.4

When you run one or more of any type of Web, DNS, Email, FTP or any other application server’s directly on your site, then you are require Static IP address. If you run a website hosting in Virtual Private Server (VPS), end user will types the domain name (e.g www.example.com) into their web browser it is translated via a DNS service to a specific IP address of your web server. Rules of thumb, any type of server is mandatory to have static IP Address because it is constant, otherwise the end user or the websites visitors will experience inaccessible website. This post will share how to setup Static IP Address on CentOS 6.4.

1. Configure static IP address on eth0 :

[root@centos64 ~]# vi /etc/sysconfig/network-scripts/ifcfg-eth0

Original :

DEVICE=eth0
HWADDR=00:0C:29:F1:24:F0
TYPE=Ethernet
UUID=324bfeb3-2a7c-409c-98d0-5cf1607596c4
ONBOOT=no
NM_CONTROLLED=yes
BOOTPROTO=dhcp

Set to the following :

DEVICE=eth0
HWADDR=00:0C:29:F1:24:F0
TYPE=Ethernet
UUID=324bfeb3-2a7c-409c-98d0-5cf1607596c4
ONBOOT=yes
NM_CONTROLLED=yes
BOOTPROTO=none
IPADDR=192.168.2.62
NETMASK=255.255.0.0

2. Configure gateway :

[root@centos64 ~]# vi /etc/sysconfig/network

Add gateway line :

NETWORKING=yes
HOSTNAME=centos64.ehowstuff.local
GATEWAY=192.168.2.1

3. Configure DNS :

; generated by /sbin/dhclient-script
search Belkin ehowstuff.local
nameserver 192.168.2.1

Update to the following :

search ehowstuff.local
nameserver 8.8.8.8

4. Restart network service to apply the changes :

[root@centos64 ~]# service network restart
Shutting down interface eth0: [ OK ]
Shutting down loopback interface: [ OK ]
Bringing up loopback interface: [ OK ]
Bringing up interface eth0: [ OK ]

9 Steps to Setup Dedicated Server for your Website

dedicated serverThere are different types of hosting services are used in the computer technology such as shared hosting, VPS (Virtual Private Server) and Dedicated Server hosting. For new websites with low numbers of visitors, I would highly recommend getting a shared hosting. If you need more control of the server, then you should moving from shared hosting to a VPS. There are plenty of hosting companies offering Virtual Private Servers, and VPS hosting is getting cheaper. This blog hosted at RamNode VPS.

At some point, your site will get super slow server performance impact on limited resources when running VPS hosting. More server resources required is due to the increased number of visitors to the tens of thousands or hundreds of thousands per day.

At the situation when you are hitting super slow website performance due to huge numbers of traffic, I would recommend you to getting dedicated servers. Cheaper way is to setup VPS additional to balance the load. If cost is not an issue, I always recommend you to purchase a dedicated server as this will give you excellent processing performance. In a dedicated server environment , resources such as memory , hard drive storage capacity, processing power, and network access are all 100% to dedicated servers instead of shared with multiple VPS or dozens of shared hosting customers. Popular websites on the Internet certainly have excellent servers behind them. Without such an excellent server, web sites with high concurrency of visitors will not be able to survive.

If you are an experienced system administrator, the following articles may not attract you, but for web developers and those new to the web hosting, the following article can be a useful guide on their first steps. I believe the popular website on the internet has been setup by a consultant who specializes in servers or installed by an experienced system administrator. In this article, I would like to share 9 steps to setup Dedicated Server for your Website.

Once you have purchased a dedicated server, you can log in to your server to complete the setup of your server from start to finish. Below is a guide and checklist for you who are new to server administration.

9 Steps to Setup Dedicated Server

1. Choose and Install Linux operating system :

Choosing the right platform on which to host your dedicated server. Please make sure that you are familiar with the preferred operating system (OS) either CentOS or Fedora or Ubuntu or maybe Windows OS. If you choose linux OS, I would recommend you to do a clean minimal installed of the OS.

2. Update operating system :

Make sure that the OS has been applied the latest patches.
How to Update CentOS 6.4 System using ‘yum update’

3. Install Apache or Nginx Web server :

Apache httpd is one of the most popular web servers and has a lot of features that make it very extensible and useful for many different types of websites. As an alternative to Apache http server, you also can install NGINX. Nginx or “engine x” is a free, open-source HTTP server that provide high-performance edge web server with the lowest memory footprint and the key features to build modern and efficient web infrastructure. I used Nginx to run this blog.

How to Setup Nginx With PHP-FastCGI on CentOS 6.2/CentOS 6.3 VPS Server

4. Install MySQL Database server :

MySQL server is a database server that can stores and retrieves data for the blog, websites and applications. It is one of the most popular most used in the internet especially for content management and blogging site.

5. Install PHP :

PHP: Hypertext Preprocessor is a widely used, free and open-source server-side scripting language that was especially designed for web development to produce dynamic web pages and can be embedded into HTML.

6. Install Bind DNS server :

BIND (the Berkeley Internet Name Domain) also known as NAMED is the most widely used DNS server in the internet. Bind DNS helps to resolve domain name to ip address and ip address to domain name.

7. Install FTP server :

File Transfer Protocol (FTP) is a network protocol used transfer file in the network. one of the most popular FTP server for Unix/Linux is vsftpd. Vsftpd stand for Very Secure FTP Daemon. Vsftpd not only just another popular FTP server for Unix/Linux systems, but vsftpd delivers excellent performance by consuming less memory.

8. Harden and Secure the dedicated server :

There are a few steps to harden the OS of dedicated server.
a) Install a host based firewall to protect your dedicated server from unauthorized access:
Once you have your web server running, you have to install host based firewall and open only certain port in your firewall. I would recommend you tosetting up iptables on your linux dedicated server.

b) Use Strong passwords :
Password complexity requirements should be in place to enforce strong password. A strong password should have mixed case, special characters, numbers, and be longer than 8 characters. Additional security, the passwords should be changed regularly.

c) Disable Unnecessary Processes, Services and Daemons :
I would recommend you to disable unneeded processes,services and daemon such as bluetooth, hidd, cups, yum-updatesd, ypbind, nfs, snmpd, saslauthd, netfs, gpm, pcmcia and sendmail. SELinux also should be set to “Disabled”. This is still very experimental so I would leave this disabled unless you really know what you are doing.

9. Install or migrate over the content of your website or blog :

You can start to migrate over the content of your website or blog to your new dedicated server. For dynamic content blog, i would recommend you to use WordPress as a platform. WordPress is an open-source blogging platform. It’s a free blogging tool and content management system (CMS) based on PHP and MySQL.

I hope that this 9 steps to setup dedicated server can be a useful guide on your first steps to have your own dedicated server to run a websites.

How to Update CentOS 6.4 System using ‘yum update’

Linux LogoThis post will show how you can update CentOS 6.4 system with ‘yum‘ command. You should update the linux to newer release or latest linux kernal because you will get security fixes, stability improvements, updated device drivers, get new kernel functions and to increased speed of the linux operating system. After get all above benefits, it’s very worthwhile to update your kernel for Linux often as soon as new update released. Now let’s take a look at the most common linux command that we can use for updating linux system. This steps has been tested on CentOS 6.4.

1 Get ‘yum-plugin-fastestmirror’ plugin installed. This plugin will looks for fast server to download packages :

[root@centos64 ~]# yum install yum-plugin-fastestmirror -y

2. Check current version and current kernel version :

[root@centos64 ~]# cat /etc/redhat-release
CentOS release 6.4 (Final)
[root@centos64 ~]# uname -a
Linux centos64.ehowstuff.local 2.6.32-358.el6.x86_64 #1 SMP Fri Feb 22 00:31:26 UTC 2013 x86_64 x86_64 x86_64 GNU/Linux

3. Perform system update by ‘yum update’ command :

[root@centos64 ~]# yum update -y

Example :

[root@centos64 ~]# yum update -y
Loaded plugins: fastestmirror
Loading mirror speeds from cached hostfile
 * base: centos.ipserverone.com
 * extras: centos.ipserverone.com
 * updates: centos.ipserverone.com
Setting up Update Process
Resolving Dependencies
--> Running transaction check
---> Package dbus-glib.x86_64 0:0.86-5.el6 will be updated
---> Package dbus-glib.x86_64 0:0.86-6.el6 will be an update
---> Package kernel.x86_64 0:2.6.32-358.2.1.el6 will be installed
---> Package kernel-firmware.noarch 0:2.6.32-358.el6 will be updated
---> Package kernel-firmware.noarch 0:2.6.32-358.2.1.el6 will be an update
---> Package libxml2.x86_64 0:2.7.6-8.el6_3.4 will be updated
---> Package libxml2.x86_64 0:2.7.6-12.el6_4.1 will be an update
---> Package mysql-libs.x86_64 0:5.1.66-2.el6_3 will be updated
---> Package mysql-libs.x86_64 0:5.1.67-1.el6_3 will be an update
---> Package openldap.x86_64 0:2.4.23-31.el6 will be updated
---> Package openldap.x86_64 0:2.4.23-32.el6_4 will be an update
---> Package openssl.x86_64 0:1.0.0-27.el6 will be updated
---> Package openssl.x86_64 0:1.0.0-27.el6_4.2 will be an update
---> Package selinux-policy.noarch 0:3.7.19-195.el6 will be updated
---> Package selinux-policy.noarch 0:3.7.19-195.el6_4.3 will be an update
---> Package selinux-policy-targeted.noarch 0:3.7.19-195.el6 will be updated
---> Package selinux-policy-targeted.noarch 0:3.7.19-195.el6_4.3 will be an update
---> Package tzdata.noarch 0:2012j-1.el6 will be updated
---> Package tzdata.noarch 0:2012j-2.el6 will be an update
--> Finished Dependency Resolution

Dependencies Resolved

==============================================================================================================
 Package                            Arch              Version                        Repository          Size
==============================================================================================================
Installing:
 kernel                             x86_64            2.6.32-358.2.1.el6             updates             26 M
Updating:
 dbus-glib                          x86_64            0.86-6.el6                     updates            170 k
 kernel-firmware                    noarch            2.6.32-358.2.1.el6             updates             11 M
 libxml2                            x86_64            2.7.6-12.el6_4.1               updates            799 k
 mysql-libs                         x86_64            5.1.67-1.el6_3                 updates            1.2 M
 openldap                           x86_64            2.4.23-32.el6_4                updates            265 k
 openssl                            x86_64            1.0.0-27.el6_4.2               updates            1.4 M
 selinux-policy                     noarch            3.7.19-195.el6_4.3             updates            1.8 M
 selinux-policy-targeted            noarch            3.7.19-195.el6_4.3             updates            2.8 M
 tzdata                             noarch            2012j-2.el6                    updates            453 k

Transaction Summary
==============================================================================================================
Install       1 Package(s)
Upgrade       9 Package(s)

Total download size: 46 M
Downloading Packages:
(1/10): dbus-glib-0.86-6.el6.x86_64.rpm                                                | 170 kB     00:01
(2/10): kernel-2.6.32-358.2.1.el6.x86_64.rpm                                           |  26 MB     04:11
(3/10): kernel-firmware-2.6.32-358.2.1.el6.noarch.rpm                                  |  11 MB     01:45
(4/10): libxml2-2.7.6-12.el6_4.1.x86_64.rpm                                            | 799 kB     00:06
(5/10): mysql-libs-5.1.67-1.el6_3.x86_64.rpm                                           | 1.2 MB     00:11
(6/10): openldap-2.4.23-32.el6_4.x86_64.rpm                                            | 265 kB     00:05
(7/10): openssl-1.0.0-27.el6_4.2.x86_64.rpm                                            | 1.4 MB     00:12
(8/10): selinux-policy-3.7.19-195.el6_4.3.noarch.rpm                                   | 1.8 MB     00:17
(9/10): selinux-policy-targeted-3.7.19-195.el6_4.3.noarch.rpm                          | 2.8 MB     00:27
(10/10): tzdata-2012j-2.el6.noarch.rpm                                                 | 453 kB     00:07
--------------------------------------------------------------------------------------------------------------
Total                                                                         105 kB/s |  46 MB     07:27
warning: rpmts_HdrFromFdno: Header V3 RSA/SHA1 Signature, key ID c105b9de: NOKEY
Retrieving key from file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-6
Importing GPG key 0xC105B9DE:
 Userid : CentOS-6 Key (CentOS 6 Official Signing Key) 
 Package: centos-release-6-4.el6.centos.10.x86_64 (@anaconda-CentOS-201303020151.x86_64/6.4)
 From   : /etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-6
Running rpm_check_debug
Running Transaction Test
Transaction Test Succeeded
Running Transaction
  Updating   : openssl-1.0.0-27.el6_4.2.x86_64                                                           1/19
  Updating   : selinux-policy-3.7.19-195.el6_4.3.noarch                                                  2/19
  Updating   : kernel-firmware-2.6.32-358.2.1.el6.noarch                                                 3/19
  Installing : kernel-2.6.32-358.2.1.el6.x86_64                                                          4/19
  Updating   : selinux-policy-targeted-3.7.19-195.el6_4.3.noarch                                         5/19
  Updating   : mysql-libs-5.1.67-1.el6_3.x86_64                                                          6/19
  Updating   : openldap-2.4.23-32.el6_4.x86_64                                                           7/19
  Updating   : tzdata-2012j-2.el6.noarch                                                                 8/19
  Updating   : dbus-glib-0.86-6.el6.x86_64                                                               9/19
  Updating   : libxml2-2.7.6-12.el6_4.1.x86_64                                                          10/19
  Cleanup    : selinux-policy-targeted-3.7.19-195.el6.noarch                                            11/19
  Cleanup    : selinux-policy-3.7.19-195.el6.noarch                                                     12/19
  Cleanup    : tzdata-2012j-1.el6.noarch                                                                13/19
  Cleanup    : kernel-firmware-2.6.32-358.el6.noarch                                                    14/19
  Cleanup    : mysql-libs-5.1.66-2.el6_3.x86_64                                                         15/19
  Cleanup    : openssl-1.0.0-27.el6.x86_64                                                              16/19
  Cleanup    : openldap-2.4.23-31.el6.x86_64                                                            17/19
  Cleanup    : dbus-glib-0.86-5.el6.x86_64                                                              18/19
  Cleanup    : libxml2-2.7.6-8.el6_3.4.x86_64                                                           19/19
  Verifying  : libxml2-2.7.6-12.el6_4.1.x86_64                                                           1/19
  Verifying  : kernel-firmware-2.6.32-358.2.1.el6.noarch                                                 2/19
  Verifying  : dbus-glib-0.86-6.el6.x86_64                                                               3/19
  Verifying  : selinux-policy-3.7.19-195.el6_4.3.noarch                                                  4/19
  Verifying  : tzdata-2012j-2.el6.noarch                                                                 5/19
  Verifying  : mysql-libs-5.1.67-1.el6_3.x86_64                                                          6/19
  Verifying  : openssl-1.0.0-27.el6_4.2.x86_64                                                           7/19
  Verifying  : kernel-2.6.32-358.2.1.el6.x86_64                                                          8/19
  Verifying  : openldap-2.4.23-32.el6_4.x86_64                                                           9/19
  Verifying  : selinux-policy-targeted-3.7.19-195.el6_4.3.noarch                                        10/19
  Verifying  : tzdata-2012j-1.el6.noarch                                                                11/19
  Verifying  : kernel-firmware-2.6.32-358.el6.noarch                                                    12/19
  Verifying  : selinux-policy-3.7.19-195.el6.noarch                                                     13/19
  Verifying  : openssl-1.0.0-27.el6.x86_64                                                              14/19
  Verifying  : selinux-policy-targeted-3.7.19-195.el6.noarch                                            15/19
  Verifying  : mysql-libs-5.1.66-2.el6_3.x86_64                                                         16/19
  Verifying  : libxml2-2.7.6-8.el6_3.4.x86_64                                                           17/19
  Verifying  : openldap-2.4.23-31.el6.x86_64                                                            18/19
  Verifying  : dbus-glib-0.86-5.el6.x86_64                                                              19/19

Installed:
  kernel.x86_64 0:2.6.32-358.2.1.el6

Updated:
  dbus-glib.x86_64 0:0.86-6.el6                     kernel-firmware.noarch 0:2.6.32-358.2.1.el6
  libxml2.x86_64 0:2.7.6-12.el6_4.1                 mysql-libs.x86_64 0:5.1.67-1.el6_3
  openldap.x86_64 0:2.4.23-32.el6_4                 openssl.x86_64 0:1.0.0-27.el6_4.2
  selinux-policy.noarch 0:3.7.19-195.el6_4.3        selinux-policy-targeted.noarch 0:3.7.19-195.el6_4.3
  tzdata.noarch 0:2012j-2.el6

Complete!

How to Add Network Adapter Without Reboot on CentOS 6/RHEL 6

This article will explain how to prepare more than one network interface on a VMware virtual machine (VM) without reboot the linux server. Normally, a network interface is sufficient to run a linux server. To ensure a balance of traffic or to enable multiple network segments in a VM, it is advisable to install more than one interface card. It was assumed that the card eth0 is configured properly and working. The process of adding a second network interface card is very easy in VMware ESXi / ESX and VMware workstation. What you need is through the vCenter or ESXi host, start the add hardware wizard and then select “Network Adapter” and let the wizard complete successfully. The following are the tested steps on CentOS 6.4 and may be applied on CentOS 6.5 and CentOS 6.6 operating system.

1. Check existing network setting.

[root@centos64 ~]# ifconfig
eth0      Link encap:Ethernet  HWaddr 00:0C:29:F1:24:F0
          inet addr:192.168.2.62  Bcast:192.168.255.255  Mask:255.255.0.0
          inet6 addr: fe80::20c:29ff:fef1:24f0/64 Scope:Link
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:735 errors:0 dropped:0 overruns:0 frame:0
          TX packets:81 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000
          RX bytes:72242 (70.5 KiB)  TX bytes:8635 (8.4 KiB)

lo        Link encap:Local Loopback
          inet addr:127.0.0.1  Mask:255.0.0.0
          inet6 addr: ::1/128 Scope:Host
          UP LOOPBACK RUNNING  MTU:16436  Metric:1
          RX packets:0 errors:0 dropped:0 overruns:0 frame:0
          TX packets:0 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:0
          RX bytes:0 (0.0 b)  TX bytes:0 (0.0 b)

2. Enter network configuration folder, and look for ethx file. By default, first network interface will start with eth0. Next added network adapter will be eth1.

[root@centos64 ~]# cd /etc/sysconfig/network-scripts/
[root@centos64 network-scripts]# ls
ifcfg-eth0   ifdown-ippp  ifdown-routes  ifup-bnep  ifup-plip    ifup-sit          network-functions
ifcfg-lo     ifdown-ipv6  ifdown-sit     ifup-eth   ifup-plusb   ifup-tunnel       network-functions-ipv6
ifdown       ifdown-isdn  ifdown-tunnel  ifup-ippp  ifup-post    ifup-wireless
ifdown-bnep  ifdown-post  ifup           ifup-ipv6  ifup-ppp     init.ipv6-global
ifdown-eth   ifdown-ppp   ifup-aliases   ifup-isdn  ifup-routes  net.hotplug

3. After you add secondary network interface from VMware level, the file will automatically added the mac address in /etc/udev/rules.d/70-persistent-net.rules. Please take note on the mac address for eth1.

[root@centos64 ~]# more /etc/udev/rules.d/70-persistent-net.rules
# This file was automatically generated by the /lib/udev/write_net_rules
# program, run by the persistent-net-generator.rules rules file.
#
# You can modify it, as long as you keep each rule on a single
# line, and change only the value of the NAME= key.

# PCI device 0x8086:0x100f (e1000)
SUBSYSTEM=="net", ACTION=="add", DRIVERS=="?*", ATTR{address}=="00:0c:29:f1:24:f0", ATTR{type}=="1", KERNEL=="
eth*", NAME="eth0"

# PCI device 0x8086:0x100f (e1000)
SUBSYSTEM=="net", ACTION=="add", DRIVERS=="?*", ATTR{address}=="00:0c:29:f1:24:fa", ATTR{type}=="1", KERNEL=="
eth*", NAME="eth1"

4. Now you need to create the configuration file for your new interface. The network interface configuration files are placed in /etc/sysconfig/network-scripts/. change the mac address according based on /etc/udev/rules.d/70-persistent-net.rules.

[root@centos64 ~]# vi /etc/sysconfig/network-scripts/ifcfg-eth1

Add below setting :

DEVICE=eth1
HWADDR=00:0c:29:f1:24:fa
TYPE=Ethernet
ONBOOT=yes
NM_CONTROLLED=yes
BOOTPROTO=none
IPADDR=192.168.2.63
NETMASK=255.255.0.0

5. Based on the type interface being added, issue an ifup command. In this case, we have added eth1.

[root@centos64 ~]# ifup eth1

6. Verify new Network interfaces :

[root@centos64 ~]# ifconfig eth0
eth0      Link encap:Ethernet  HWaddr 00:0C:29:F1:24:F0
          inet addr:192.168.2.62  Bcast:192.168.255.255  Mask:255.255.0.0
          inet6 addr: fe80::20c:29ff:fef1:24f0/64 Scope:Link
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:8019 errors:0 dropped:0 overruns:0 frame:0
          TX packets:6949 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000
          RX bytes:804606 (785.7 KiB)  TX bytes:694075 (677.8 KiB)

[root@centos64 ~]# ifconfig eth1
eth1      Link encap:Ethernet  HWaddr 00:0C:29:F1:24:FA
          inet addr:192.168.2.63  Bcast:192.168.255.255  Mask:255.255.0.0
          inet6 addr: fe80::20c:29ff:fef1:24fa/64 Scope:Link
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:450 errors:0 dropped:0 overruns:0 frame:0
          TX packets:23 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000
          RX bytes:40087 (39.1 KiB)  TX bytes:1182 (1.1 KiB)

How to Fix “Could not reliably determine the server’s fully qualified domain name”

apache-http-serverQuestion :
How to fix “Could not reliably determine the server’s fully qualified domain name” when starting apache httpd service ?

[root@centos64 ~]# service httpd start
Starting httpd: httpd: apr_sockaddr_info_get() failed for centos64.ehowstuff.local
httpd: Could not reliably determine the server's fully qualified domain name, using 127.0.0.1 for ServerName
                                                           [  OK  ]

Answer :

Step 1:

Update /etc/hosts and do server’s ip address resolvable to the fully qualified domain name(fqdn) or hostname.

[root@centos64 ~]# vi /etc/hosts
127.0.0.1   localhost localhost.localdomain localhost4 localhost4.localdomain4
::1         localhost localhost.localdomain localhost6 localhost6.localdomain6

192.168.2.62 centos64.ehowstuff.local

Step 2:

Restart apache httpd service :

[root@centos64 ~]# service httpd restart
Stopping httpd:                                            [  OK  ]
Starting httpd:                                            [  OK  ]

How to Install VMware Tools on CentOS 6.4

vmware-toolsThis post provides steps to install VMware Tools in CentOS 6.4. It is very important to install VMware Tools in the guest operating system. Without the VMware Tools, guest OS performance will lacks some of the important functionality. VMware Tools is a group of utilities that enhances the overall performance of the virtual machine’s guest operating system (OS) and improves management of the virtual machine (VM). This is one of important components in order to provide perfect VM OS.

1. Choose your VM –> Click “Install VMware Tools” from the VMware Workstation menu, VMware Workstation temporarily connects the virtual machine’s first virtual CD-ROM drive to the ISO image file that contains the VMware Tools installer for your guest operating system and you are ready to begin the installation process.

2. Install prerequisites :

[root@centos64 ~]# yum install perl gcc make -y

Example :

[root@centos64 ~]# yum install perl gcc make -y
Loaded plugins: fastestmirror
Loading mirror speeds from cached hostfile
 * base: centos.ipserverone.com
 * extras: centos.ipserverone.com
 * updates: centos.ipserverone.com
Setting up Install Process
Resolving Dependencies
--> Running transaction check
---> Package gcc.x86_64 0:4.4.7-3.el6 will be installed
--> Processing Dependency: libgomp = 4.4.7-3.el6 for package: gcc-4.4.7-3.el6.x86_64
--> Processing Dependency: cpp = 4.4.7-3.el6 for package: gcc-4.4.7-3.el6.x86_64
--> Processing Dependency: glibc-devel >= 2.2.90-12 for package: gcc-4.4.7-3.el6.x86_64
--> Processing Dependency: cloog-ppl >= 0.15 for package: gcc-4.4.7-3.el6.x86_64
--> Processing Dependency: libgomp.so.1()(64bit) for package: gcc-4.4.7-3.el6.x86_64
---> Package make.x86_64 1:3.81-20.el6 will be installed
---> Package perl.x86_64 4:5.10.1-129.el6 will be installed
--> Processing Dependency: perl-libs = 4:5.10.1-129.el6 for package: 4:perl-5.10.1-129.el6.x86_64
--> Processing Dependency: perl-libs for package: 4:perl-5.10.1-129.el6.x86_64
--> Processing Dependency: perl(version) for package: 4:perl-5.10.1-129.el6.x86_64
--> Processing Dependency: perl(Pod::Simple) for package: 4:perl-5.10.1-129.el6.x86_64
--> Processing Dependency: perl(Module::Pluggable) for package: 4:perl-5.10.1-129.el6.x86_64
--> Processing Dependency: libperl.so()(64bit) for package: 4:perl-5.10.1-129.el6.x86_64
--> Running transaction check
---> Package cloog-ppl.x86_64 0:0.15.7-1.2.el6 will be installed
--> Processing Dependency: libppl_c.so.2()(64bit) for package: cloog-ppl-0.15.7-1.2.el6.x86_64
--> Processing Dependency: libppl.so.7()(64bit) for package: cloog-ppl-0.15.7-1.2.el6.x86_64
---> Package cpp.x86_64 0:4.4.7-3.el6 will be installed
--> Processing Dependency: libmpfr.so.1()(64bit) for package: cpp-4.4.7-3.el6.x86_64
---> Package glibc-devel.x86_64 0:2.12-1.107.el6 will be installed
--> Processing Dependency: glibc-headers = 2.12-1.107.el6 for package: glibc-devel-2.12-1.107.el6.x86_64
--> Processing Dependency: glibc-headers for package: glibc-devel-2.12-1.107.el6.x86_64
---> Package libgomp.x86_64 0:4.4.7-3.el6 will be installed
---> Package perl-Module-Pluggable.x86_64 1:3.90-129.el6 will be installed
---> Package perl-Pod-Simple.x86_64 1:3.13-129.el6 will be installed
--> Processing Dependency: perl(Pod::Escapes) >= 1.04 for package: 1:perl-Pod-Simple-3.13-129.el6.x86_64
---> Package perl-libs.x86_64 4:5.10.1-129.el6 will be installed
---> Package perl-version.x86_64 3:0.77-129.el6 will be installed
--> Running transaction check
---> Package glibc-headers.x86_64 0:2.12-1.107.el6 will be installed
--> Processing Dependency: kernel-headers >= 2.2.1 for package: glibc-headers-2.12-1.107.el6.x86_64
--> Processing Dependency: kernel-headers for package: glibc-headers-2.12-1.107.el6.x86_64
---> Package mpfr.x86_64 0:2.4.1-6.el6 will be installed
---> Package perl-Pod-Escapes.x86_64 1:1.04-129.el6 will be installed
---> Package ppl.x86_64 0:0.10.2-11.el6 will be installed
--> Running transaction check
---> Package kernel-headers.x86_64 0:2.6.32-358.2.1.el6 will be installed
--> Finished Dependency Resolution

Dependencies Resolved

==============================================================================================================
 Package                          Arch              Version                          Repository          Size
==============================================================================================================
Installing:
 gcc                              x86_64            4.4.7-3.el6                      base                10 M
 make                             x86_64            1:3.81-20.el6                    base               389 k
 perl                             x86_64            4:5.10.1-129.el6                 base                10 M
Installing for dependencies:
 cloog-ppl                        x86_64            0.15.7-1.2.el6                   base                93 k
 cpp                              x86_64            4.4.7-3.el6                      base               3.7 M
 glibc-devel                      x86_64            2.12-1.107.el6                   base               974 k
 glibc-headers                    x86_64            2.12-1.107.el6                   base               604 k
 kernel-headers                   x86_64            2.6.32-358.2.1.el6               updates            2.3 M
 libgomp                          x86_64            4.4.7-3.el6                      base               118 k
 mpfr                             x86_64            2.4.1-6.el6                      base               157 k
 perl-Module-Pluggable            x86_64            1:3.90-129.el6                   base                38 k
 perl-Pod-Escapes                 x86_64            1:1.04-129.el6                   base                31 k
 perl-Pod-Simple                  x86_64            1:3.13-129.el6                   base               210 k
 perl-libs                        x86_64            4:5.10.1-129.el6                 base               576 k
 perl-version                     x86_64            3:0.77-129.el6                   base                50 k
 ppl                              x86_64            0.10.2-11.el6                    base               1.3 M

Transaction Summary
==============================================================================================================
Install      16 Package(s)

Total download size: 31 M
Installed size: 75 M
Downloading Packages:
(1/16): cloog-ppl-0.15.7-1.2.el6.x86_64.rpm                                            |  93 kB     00:01
(2/16): cpp-4.4.7-3.el6.x86_64.rpm                                                     | 3.7 MB     00:36
(3/16): gcc-4.4.7-3.el6.x86_64.rpm                                                     |  10 MB     01:36
(4/16): glibc-devel-2.12-1.107.el6.x86_64.rpm                                          | 974 kB     00:08
(5/16): glibc-headers-2.12-1.107.el6.x86_64.rpm                                        | 604 kB     00:10
(6/16): kernel-headers-2.6.32-358.2.1.el6.x86_64.rpm                                   | 2.3 MB     00:23
(7/16): libgomp-4.4.7-3.el6.x86_64.rpm                                                 | 118 kB     00:00
(8/16): make-3.81-20.el6.x86_64.rpm                                                    | 389 kB     00:03
(9/16): mpfr-2.4.1-6.el6.x86_64.rpm                                                    | 157 kB     00:01
(10/16): perl-5.10.1-129.el6.x86_64.rpm                                                |  10 MB     01:40
(11/16): perl-Module-Pluggable-3.90-129.el6.x86_64.rpm                                 |  38 kB     00:00
(12/16): perl-Pod-Escapes-1.04-129.el6.x86_64.rpm                                      |  31 kB     00:00
(13/16): perl-Pod-Simple-3.13-129.el6.x86_64.rpm                                       | 210 kB     00:02
(14/16): perl-libs-5.10.1-129.el6.x86_64.rpm                                           | 576 kB     00:05
(15/16): perl-version-0.77-129.el6.x86_64.rpm                                          |  50 kB     00:00
(16/16): ppl-0.10.2-11.el6.x86_64.rpm                                                  | 1.3 MB     00:11
--------------------------------------------------------------------------------------------------------------
Total                                                                         103 kB/s |  31 MB     05:06
Running rpm_check_debug
Running Transaction Test
Transaction Test Succeeded
Running Transaction
  Installing : 1:perl-Pod-Escapes-1.04-129.el6.x86_64                                                    1/16
  Installing : 4:perl-libs-5.10.1-129.el6.x86_64                                                         2/16
  Installing : 3:perl-version-0.77-129.el6.x86_64                                                        3/16
  Installing : 1:perl-Module-Pluggable-3.90-129.el6.x86_64                                               4/16
  Installing : 1:perl-Pod-Simple-3.13-129.el6.x86_64                                                     5/16
  Installing : 4:perl-5.10.1-129.el6.x86_64                                                              6/16
  Installing : ppl-0.10.2-11.el6.x86_64                                                                  7/16
  Installing : cloog-ppl-0.15.7-1.2.el6.x86_64                                                           8/16
  Installing : kernel-headers-2.6.32-358.2.1.el6.x86_64                                                  9/16
  Installing : glibc-headers-2.12-1.107.el6.x86_64                                                      10/16
  Installing : glibc-devel-2.12-1.107.el6.x86_64                                                        11/16
  Installing : libgomp-4.4.7-3.el6.x86_64                                                               12/16
  Installing : mpfr-2.4.1-6.el6.x86_64                                                                  13/16
  Installing : cpp-4.4.7-3.el6.x86_64                                                                   14/16
  Installing : gcc-4.4.7-3.el6.x86_64                                                                   15/16
  Installing : 1:make-3.81-20.el6.x86_64                                                                16/16
  Verifying  : glibc-devel-2.12-1.107.el6.x86_64                                                         1/16
  Verifying  : gcc-4.4.7-3.el6.x86_64                                                                    2/16
  Verifying  : 1:perl-Pod-Escapes-1.04-129.el6.x86_64                                                    3/16
  Verifying  : 1:perl-Pod-Simple-3.13-129.el6.x86_64                                                     4/16
  Verifying  : mpfr-2.4.1-6.el6.x86_64                                                                   5/16
  Verifying  : libgomp-4.4.7-3.el6.x86_64                                                                6/16
  Verifying  : 4:perl-5.10.1-129.el6.x86_64                                                              7/16
  Verifying  : 4:perl-libs-5.10.1-129.el6.x86_64                                                         8/16
  Verifying  : cpp-4.4.7-3.el6.x86_64                                                                    9/16
  Verifying  : 1:make-3.81-20.el6.x86_64                                                                10/16
  Verifying  : 3:perl-version-0.77-129.el6.x86_64                                                       11/16
  Verifying  : 1:perl-Module-Pluggable-3.90-129.el6.x86_64                                              12/16
  Verifying  : kernel-headers-2.6.32-358.2.1.el6.x86_64                                                 13/16
  Verifying  : ppl-0.10.2-11.el6.x86_64                                                                 14/16
  Verifying  : cloog-ppl-0.15.7-1.2.el6.x86_64                                                          15/16
  Verifying  : glibc-headers-2.12-1.107.el6.x86_64                                                      16/16

Installed:
  gcc.x86_64 0:4.4.7-3.el6          make.x86_64 1:3.81-20.el6          perl.x86_64 4:5.10.1-129.el6

Dependency Installed:
  cloog-ppl.x86_64 0:0.15.7-1.2.el6                     cpp.x86_64 0:4.4.7-3.el6
  glibc-devel.x86_64 0:2.12-1.107.el6                   glibc-headers.x86_64 0:2.12-1.107.el6
  kernel-headers.x86_64 0:2.6.32-358.2.1.el6            libgomp.x86_64 0:4.4.7-3.el6
  mpfr.x86_64 0:2.4.1-6.el6                             perl-Module-Pluggable.x86_64 1:3.90-129.el6
  perl-Pod-Escapes.x86_64 1:1.04-129.el6                perl-Pod-Simple.x86_64 1:3.13-129.el6
  perl-libs.x86_64 4:5.10.1-129.el6                     perl-version.x86_64 3:0.77-129.el6
  ppl.x86_64 0:0.10.2-11.el6

Complete!

3. Reboot VM.

[root@centos64 ~]# reboot

4. Mount the installer.

[root@centos64 ~]# mount -t iso9660 /dev/cdrom /mnt
mount: block device /dev/sr0 is write-protected, mounting read-only

5. Copy the installer to /tmp :

[root@centos64 ~]# cd /mnt
[root@centos64 mnt]# cp VMwareTools-9.2.2-893683.tar.gz /tmp

6. Extract the installer :

[root@centos64 ~]# cd /tmp
[root@centos64 tmp]# tar xzvf VMwareTools-9.2.2-893683.tar.gz

7. Enter the vmware-tools-distrib directory :

[root@centos64 tmp]# cd vmware-tools-distrib/

8. Install the VMware Tools :

[root@centos64 vmware-tools-distrib]# ./vmware-install.pl

Download CentOS 6.4 x86_64 and x86 ISO

CentOS 6.4 has been released 9th March 2013. As we know, CentOS is an Enterprise-class Linux Distribution derived from sources freely provided to the public. It has 100% binary compatibility with its upstream source, Red Hat Enterprise Linux (RHEL).

Released Note :
http://wiki.centos.org/Manuals/ReleaseNotes/CentOS6.4

Download URL for x86 and x64 ISO
http://isoredirect.centos.org/centos/6/isos/i386/
http://isoredirect.centos.org/centos/6/isos/x86_64/

Install Media and sha1sum :

sha1sum i386:

4bd3a1de6f6dfcd7a2199487abf5a9304d696cae  CentOS-6.4-i386-bin-DVD1.iso
fb096cd6ac88959a287256c76c7292ae2ef53f32  CentOS-6.4-i386-bin-DVD2.iso
ddb63a0af2c1d63b8e9b7342c7f52a86b1842689  CentOS-6.4-i386-minimal.iso
6ffc9f3a5f4332b55cc35f1eb3ebb39f5aa8edb6  CentOS-6.4-i386-netinstall.iso

sha1sum x86_64:

8672dc087f1b0eda60b9efaa41b82f034f185e24  CentOS-6.4-x86_64-bin-DVD1.iso
db16ec15897dcb7a01e7434486075f43ca982c4b  CentOS-6.4-x86_64-bin-DVD2.iso
6232efa014d9c6798396b63152c4c9a08b279f5e  CentOS-6.4-x86_64-minimal.iso
77817ed6e879da155b6f3dc98e0698e8993e28f8  CentOS-6.4-x86_64-netinstall.iso

7 Useful Linux Utilities

Linux UtilitiesThere are 7 useful linux utilities that you must install on new linux server. Most Linux distributions are equipped with tons of linux command utility, but if you have installed minimal operating system, all these software will not exist. These tools will very useful in your troubleshooting and will help to find possible causes of a problem. Most of the utilities have the same function in CentOS or Red Hat Enterprise Linux (RHEL).

You can easily identify whether the utility installed on your linux operating system or not. You will see one or more below warning :

[root@rhel62 ~]# wget
-bash: wget: command not found
[root@rhel62 ~]# telnet
-bash: telnet: command not found
[root@rhel62 ~]# scp
-bash: scp: command not found
[root@rhel62 ~]# man scp
-bash: man: command not found
[root@rhel62 ~]# nslookup
-bash: nslookup: command not found
[root@rhel62 ~]# dig
-bash: dig: command not found
[root@rhel62 ~]# host
-bash: host: command not found

7 Useful Linux Utilities

1. What is wget ?
Wget is a network utility to retrieve files from the Web using http and ftp, the two most widely used Internet protocols.

Example :

[root@rhel62 ~]# wget http://files2.zimbra.com/downloads/8.0.2_GA/zcs-8.0.2_GA_5569.RHEL6_64.20121210115059.tgz

2. What is telnet ?
Telnet is a network protocol used on the Internet or local area networks. Telnet is a user command and an underlying TCP/IP protocol for accessing remote computers and very useful for troubleshooting and verify the opened ports.

Example :

[root@rhel62 ~]# telnet localhost 25
Trying ::1...
Connected to localhost.
Escape character is '^]'.
220 rhel62.ehowstuff.local ESMTP Postfix

3. What is scp ?
scp also call secure copy, is remote file copy utility between hosts on a network. It uses ssh for data transfer and provides the same authentication and same level of security as ssh.

Example :

[root@rhel62 ~]# scp root@192.168.2.60:/tmp/VMwareTools-9.2.2-893683.tar.gz .
The authenticity of host '192.168.2.60 (192.168.2.60)' can't be established.
RSA key fingerprint is 76:78:87:36:44:c1:46:fa:c4:b4:61:4a:e5:b3:be:e3.
Are you sure you want to continue connecting (yes/no)? yes
Warning: Permanently added '192.168.2.60' (RSA) to the list of known hosts.
root@192.168.2.60's password:
VMwareTools-9.2.2-893683.tar.gz                                                       100%   63MB  63.3MB/s   00:01

4. What is man ?
man is used to display the manual page for other commands It’s help to explain the functions for the commands that commonly used. The term “man” is short for manual.

Example :

[root@rhel62 ~]# man wget
WGET(1)                            GNU Wget                            WGET(1)

NAME
       Wget - The non-interactive network downloader.

SYNOPSIS
       wget [option]... [URL]...

DESCRIPTION
       GNU Wget is a free utility for non-interactive download of files from the Web.  It supports HTTP,
       HTTPS, and FTP protocols, as well as retrieval through HTTP proxies.

       Wget is non-interactive, meaning that it can work in the background, while the user is not logged on.
       This allows you to start a retrieval and disconnect from the system, letting Wget finish the work.
       By contrast, most of the Web browsers require constant userâs presence, which can be a great
       hindrance when transferring a lot of data.

       Wget can follow links in HTML, XHTML, and CSS pages, to create local versions of remote web sites,
       fully recreating the directory structure of the original site.  This is sometimes referred to as
       "recursive downloading."  While doing that, Wget respects the Robot Exclusion Standard (/robots.txt).
       Wget can be instructed to convert the links in downloaded files to point at the local files, for
       offline viewing.

5. What is nslookup, dig, host ?
nslookup, dig and host are part of the bind utilities.These utilities are the basic tools for DNS client and DNS server troubleshooting.

Examples :

[root@rhel62 ~]# nslookup
> set type=mx
> ehowstuff.com
Server:         8.8.8.8
Address:        8.8.8.8#53

Non-authoritative answer:
ehowstuff.com   mail exchanger = 0 ehowstuff.com.

Authoritative answers can be found from:
>
[root@rhel62 ~]# dig ehowstuff.com

; < <>> DiG 9.7.3-P3-RedHat-9.7.3-8.P3.el6 < <>> ehowstuff.com
;; global options: +cmd
;; Got answer:
;; ->>HEADER<
[root@rhel62 ~]# host -t mx ehowstuff.com
ehowstuff.com mail is handled by 0 ehowstuff.com.

How to install wget, scpt, telnet, man, nslookup, dig and host utilities ?

Simply run the following commands :

[root@rhel62 ~]# yum install wget telnet openssh-clients bind-utils man -y

How to Setup MailWatch on CentOS 6.3

mailwatch logoMailWatch for MailScanner is a open source or free web-based front-end to Mailscanner that use to displays the inbound/outbound mail queue, spam, viruses and blocked content on each page header. MailWatch has been written in PHP, MySQL and JpGraph. By using Mailwatch, it allows you to delete, release or run sa-learn across any messages that was quarantined. This post describes how to setup MailWatch on CentOS 6.3 and assumed that you already installed MailScanner and postfix.

1. Install required php and mysql :

[root@mx1 ~]# yum install php mysql-server mysql php-gd php-mysql -y

2. Modify the php.ini :

[root@mx1 ~]# vim /etc/php.ini

PHP should have the following set in php.ini

 short_open_tag = On
 safe_mode = Off
 register_globals = Off
 magic_quotes_gpc = On
 magic_quotes_runtime = Off
 session.auto_start = 0

3. Download the latest version from mailwatch.sourceforge.net :

[root@mx1 ~]# wget http://sourceforge.net/projects/mailwatch/files/mailwatch/1.1.5.1/mailwatch-1.1.5.1.tar.gz

4. Extract downloaded mailwatch package :

[root@mx1 ~]# tar xzvf mailwatch-1.1.5.1.tar.gz

5. Start mysql service :

[root@mx1 ~]# service mysqld start
Initializing MySQL database:  WARNING: The host 'mx1.ehowstuff.local' could not be looked up with resolveip.
This probably means that your libc libraries are not 100 % compatible
with this binary MySQL version. The MySQL daemon, mysqld, should work
normally with the exception that host name resolving will not work.
This means that you should use IP addresses instead of hostnames
when specifying MySQL privileges !
Installing MySQL system tables...
OK
Filling help tables...
OK

To start mysqld at boot time you have to copy
support-files/mysql.server to the right place for your system

PLEASE REMEMBER TO SET A PASSWORD FOR THE MySQL root USER !
To do so, start the server, then issue the following commands:

/usr/bin/mysqladmin -u root password 'new-password'
/usr/bin/mysqladmin -u root -h mx1.ehowstuff.local password 'new-password'

Alternatively you can run:
/usr/bin/mysql_secure_installation

which will also give you the option of removing the test
databases and anonymous user created by default.  This is
strongly recommended for production servers.

See the manual for more instructions.

You can start the MySQL daemon with:
cd /usr ; /usr/bin/mysqld_safe &

You can test the MySQL daemon with mysql-test-run.pl
cd /usr/mysql-test ; perl mysql-test-run.pl

Please report any problems with the /usr/bin/mysqlbug script!

                                                           [  OK  ]
Starting mysqld:                                           [  OK  ]

6. Enter extracted mailwatch-x.x directory :

[root@mx1 mailwatch-1.1.5.1]# ls
CHANGELOG   fix_quarantine_permissions  LICENSE  mailscanner               Remote_DB.txt  upgrade.php  USER_FILTERS
create.sql  INSTALL                     luser    MailScanner_perl_scripts  tools          UPGRADING
[root@mx1 mailwatch-1.1.5.1]# mysql -p < create.sql

7. Create the database and import create.sql. The following commands below should be run as the ‘root’ :

[root@mx1 mailwatch-1.1.5.1]# mysql -p < create.sql
Enter password:

8. Login to mysql as a root :

[root@mx1 mailwatch-1.1.5.1]# mysql -u root -p
Enter password:
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 3
Server version: 5.1.67 Source distribution

Copyright (c) 2000, 2012, Oracle and/or its affiliates. All rights reserved.

Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

mysql>

9. Proceed to create a MySQL user and then set password and configure MailScanner for SQL logging :

mysql> GRANT ALL ON mailscanner.* TO mailwatch@localhost IDENTIFIED BY 'password';
Query OK, 0 rows affected (0.00 sec)

mysql> GRANT FILE ON *.* TO mailwatch@localhost IDENTIFIED BY 'password';
Query OK, 0 rows affected (0.00 sec)

mysql> FLUSH PRIVILEGES;
Query OK, 0 rows affected (0.00 sec)

mysql> show databases;
+--------------------+
| Database           |
+--------------------+
| information_schema |
| mailscanner        |
| mysql              |
| test               |
+--------------------+
4 rows in set (0.00 sec)

10. Edit MailWatch.pm and change the database values accordingly :

a. Enter to the perl_scripts’s folder :

[root@mx1 mailwatch-1.1.5.1]# cd MailScanner_perl_scripts
[root@mx1 MailScanner_perl_scripts]# pwd
/root/mailwatch-1.1.5.1/MailScanner_perl_scripts

b. Edit MailWatch.pm :

[root@mx1 MailScanner_perl_scripts]# vim MailWatch.pm

c.Modify this as necessary for your configuration

my($db_name) = 'mailscanner';
my($db_host) = 'localhost';
my($db_user) = 'mailwatch';
my($db_pass) = 'password';

11. Move MailWatch.pm to /usr/lib/MailScanner/MailScanner/CustomFunctions :

[root@mx1 MailScanner_perl_scripts]# cp MailWatch.pm /usr/lib/MailScanner/MailScanner/CustomFunctions

12. Create a MailWatch web user. This user will able to monitor the mailscanner through MailWatch web interface.

[root@mx1 ~]# mysql mailscanner -u mailwatch -p
Enter password:
Reading table information for completion of table and column names
You can turn off this feature to get a quicker startup with -A

Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 8
Server version: 5.1.67 Source distribution

Copyright (c) 2000, 2012, Oracle and/or its affiliates. All rights reserved.

Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

mysql> INSERT INTO users SET username = 'admin', password = md5('password'), fullname = 'MAilwatch Administrator', type ='A';
Query OK, 1 row affected (0.00 sec)

13. Install & Configure MailWatch :
a. Enter to mailwatch directory :

[root@mx1 ~]# cd mailwatch-1.1.5.1

b. Move mailscanner folder for web root folder. For apache, default root folder is /var/www/html :

[root@mx1 mailwatch-1.1.5.1]# mv mailscanner /var/www/html/

c. Enter to mailscanner folder in web root directory :

[root@mx1 ~]# cd /var/www/html/mailscanner

d. Verify and check the permissions of /var/www/html/mailscanner/images and /var/www/html/images/cache. The permissions and ownerships should be as below :

[root@mx1 mailscanner]# chown root:apache images
[root@mx1 mailscanner]# chmod ug+rwx images
[root@mx1 mailscanner]# chown root:apache images/cache
[root@mx1 mailscanner]# chmod ug+rwx images/cache

14. Create conf.php by copying conf.php.example. Edit the values to any details as you created earlier :

a. Copy the conf.php :

[root@mx1 mailscanner]# cp conf.php.example conf.php

b. Open conf.php :

[root@mx1 mailscanner]# vim conf.php

c. Edit the details as below :

define('DB_TYPE', 'mysql');
define('DB_USER', 'mailwatch');
define('DB_PASS', 'password');
define('DB_HOST', 'localhost');
define('DB_NAME', 'mailscanner');

15. Before setup the mailscanner, make sure it’s Stopped. Run 3 to 4 times to ensure the mailscanner completely stop. The status will FAILED if mailscanner completely stop.

[root@mx1 ~]# service MailScanner stop
Shutting down MailScanner daemons:
         MailScanner:                                      [  OK  ]
         incoming postfix:                                 [  OK  ]
         outgoing postfix:                                 [  OK  ]
[root@mx1 ~]# service MailScanner stop
Shutting down MailScanner daemons:
         MailScanner:                                      [  OK  ]
         incoming postfix:                                 [  OK  ]
         outgoing postfix:                                 [  OK  ]
[root@mx1 ~]# service MailScanner stop
Shutting down MailScanner daemons:
         MailScanner:                                      [  OK  ]
         incoming postfix:                                 [  OK  ]
         outgoing postfix:                                 [  OK  ]
[root@mx1 ~]# service MailScanner stop
Shutting down MailScanner daemons:
         MailScanner:                                      [  OK  ]
         incoming postfix:                                 [  OK  ]
         outgoing postfix:                                 [  OK  ]
[root@mx1 ~]# service MailScanner stop
Shutting down MailScanner daemons:
         MailScanner:                                      [FAILED]
         incoming postfix:                                 [  OK  ]
         outgoing postfix:                                 [  OK  ]

16. Edit /etc/MailScanner/MailScanner.conf.

[root@mx1 ~]# vim /etc/MailScanner/MailScanner.conf

Make sure that the following options are set:

 Always Looked Up Last = &MailWatchLogging
 Detailed Spam Report = yes
 Quarantine Whole Message = yes
 Quarantine Whole Message As Queue Files = no
 Include Scores In SpamAssassin Report = yes
 Quarantine User = root
 Quarantine Group = apache (this should be the same group as your web server)
 Quarantine Permissions = 0660

17. Start MailScanner :

[root@mx1 ~]# service MailScanner start
Starting MailScanner daemons:
         incoming postfix:                                 [  OK  ]
         outgoing postfix:                                 [  OK  ]
         MailScanner:                                      [  OK  ]

18. Restart httpd service :

[root@mx1 ~]# service httpd restart

19. Make sure all the related service such as httpd, mysql and MailScanner configured to start at boot :

[root@mx1 ~]# chkconfig mysqld on
[root@mx1 ~]# chkconfig httpd on
[root@mx1 ~]# chkconfig MailScanner on
[root@mx1 ~]# chkconfig spamassassin on
[root@mx1 ~]# chkconfig postfix on

20. Check the mail log.

[root@mx1 ~]# tail -f /var/log/maillog

You should see something as below :

Mar  5 22:14:42 mx1 MailScanner[1718]: Using locktype = flock
Mar  5 22:14:43 mx1 MailScanner[1697]: Requeue: C297BA1C3F.AA850 to E7373A1DD6
Mar  5 22:14:43 mx1 postfix/qmgr[1687]: E7373A1DD6: from=<root@mx1.ehowstuff.local>, size=609, nrcpt=1 (queue active)
Mar  5 22:14:43 mx1 MailScanner[1697]: Uninfected: Delivered 1 messages
Mar  5 22:14:43 mx1 MailScanner[1697]: Deleted 1 messages from processing-database
Mar  5 22:14:43 mx1 MailScanner[1697]: Logging message C297BA1C3F.AA850 to SQL
Mar  5 22:14:43 mx1 postfix/local[1768]: E7373A1DD6: to=<root@mx1.ehowstuff.local>, orig_to=, relay=local, delay=166894, delays=166894/0.13/0/0.02, dsn=2.0.0, status=sent (delivered to mailbox)
Mar  5 22:14:43 mx1 postfix/qmgr[1687]: E7373A1DD6: removed
Mar  5 22:56:25 mx1 postfix/postfix-script[1869]: fatal: the Postfix mail system is already running
Mar  5 23:01:08 mx1 update.bad.phishing.sites: Delaying cron job up to 600 seconds

21. Login to mailwatch web interface :
1

2

How to Install PHP 5.3 on CentOS 5.9

phpThis post focus on how to install PHP 5.3 on CentOS 5.9. PHP: Hypertext Preprocessor is a widely used, free and open-source server-side scripting language that was especially designed for web development to produce dynamic web pages and can be embedded into HTML. PHP applications are commonly found with the filename extensions .php, .php4, or .php5. Follow this steps to install php 5.3.

Syntax :

[root@centos59 ~]# yum install php53*

or

[root@centos59 ~]# yum install php53* -y

Example :

[root@centos59 ~]# yum install php53*
Loaded plugins: fastestmirror
Loading mirror speeds from cached hostfile
 * base: mirror.nus.edu.sg
 * extras: mirror.nus.edu.sg
 * updates: mirror.nus.edu.sg
Setting up Install Process
Resolving Dependencies
--> Running transaction check
..
..
..
Dependencies Resolved

====================================================================================================
 Package                      Arch              Version                     Repository         Size
====================================================================================================
Installing:
 php53                        i386              5.3.3-13.el5_8              base              1.3 M
 php53-bcmath                 i386              5.3.3-13.el5_8              base               43 k
 php53-cli                    i386              5.3.3-13.el5_8              base              2.5 M
 php53-common                 i386              5.3.3-13.el5_8              base              605 k
 php53-dba                    i386              5.3.3-13.el5_8              base               40 k
 php53-devel                  i386              5.3.3-13.el5_8              base              592 k
 php53-gd                     i386              5.3.3-13.el5_8              base              109 k
 php53-imap                   i386              5.3.3-13.el5_8              base               51 k
 php53-intl                   i386              5.3.3-13.el5_8              base               74 k
 php53-ldap                   i386              5.3.3-13.el5_8              base               36 k
 php53-mbstring               i386              5.3.3-13.el5_8              base              1.2 M
 php53-mysql                  i386              5.3.3-13.el5_8              base               88 k
 php53-odbc                   i386              5.3.3-13.el5_8              base               52 k
 php53-pdo                    i386              5.3.3-13.el5_8              base               67 k
 php53-pgsql                  i386              5.3.3-13.el5_8              base               73 k
 php53-process                i386              5.3.3-13.el5_8              base               38 k
 php53-pspell                 i386              5.3.3-13.el5_8              base               26 k
 php53-snmp                   i386              5.3.3-13.el5_8              base               29 k
 php53-soap                   i386              5.3.3-13.el5_8              base              147 k
 php53-xml                    i386              5.3.3-13.el5_8              base              113 k
 php53-xmlrpc                 i386              5.3.3-13.el5_8              base               53 k

Transaction Summary
====================================================================================================
Install      21 Package(s)
Upgrade       0 Package(s)

Total download size: 7.1 M
Is this ok [y/N]: y
Downloading Packages:
(1/21): php53-pspell-5.3.3-13.el5_8.i386.rpm                                 |  26 kB     00:00
(2/21): php53-snmp-5.3.3-13.el5_8.i386.rpm                                   |  29 kB     00:00
(3/21): php53-ldap-5.3.3-13.el5_8.i386.rpm                                   |  36 kB     00:00
(4/21): php53-process-5.3.3-13.el5_8.i386.rpm                                |  38 kB     00:00
(5/21): php53-dba-5.3.3-13.el5_8.i386.rpm                                    |  40 kB     00:00
(6/21): php53-bcmath-5.3.3-13.el5_8.i386.rpm                                 |  43 kB     00:00
(7/21): php53-imap-5.3.3-13.el5_8.i386.rpm                                   |  51 kB     00:00
(8/21): php53-odbc-5.3.3-13.el5_8.i386.rpm                                   |  52 kB     00:00
(9/21): php53-xmlrpc-5.3.3-13.el5_8.i386.rpm                                 |  53 kB     00:00
(10/21): php53-pdo-5.3.3-13.el5_8.i386.rpm                                   |  67 kB     00:00
(11/21): php53-pgsql-5.3.3-13.el5_8.i386.rpm                                 |  73 kB     00:00
(12/21): php53-intl-5.3.3-13.el5_8.i386.rpm                                  |  74 kB     00:00
(13/21): php53-mysql-5.3.3-13.el5_8.i386.rpm                                 |  88 kB     00:00
(14/21): php53-gd-5.3.3-13.el5_8.i386.rpm                                    | 109 kB     00:00
(15/21): php53-xml-5.3.3-13.el5_8.i386.rpm                                   | 113 kB     00:00
(16/21): php53-soap-5.3.3-13.el5_8.i386.rpm                                  | 147 kB     00:01
(17/21): php53-devel-5.3.3-13.el5_8.i386.rpm                                 | 592 kB     00:04
(18/21): php53-common-5.3.3-13.el5_8.i386.rpm                                | 605 kB     00:05
(19/21): php53-mbstring-5.3.3-13.el5_8.i386.rpm                              | 1.2 MB     00:10
(20/21): php53-5.3.3-13.el5_8.i386.rpm                                       | 1.3 MB     00:11
(21/21): php53-cli-5.3.3-13.el5_8.i386.rpm                                   | 2.5 MB     00:23
----------------------------------------------------------------------------------------------------
Total                                                               107 kB/s | 7.1 MB     01:07
Running rpm_check_debug
Running Transaction Test
Finished Transaction Test
Transaction Test Succeeded
Running Transaction
  Installing     : php53-common                                                                1/21
  Installing     : php53-pdo                                                                   2/21
  Installing     : php53-cli                                                                   3/21
  Installing     : php53                                                                       4/21
  Installing     : php53-ldap                                                                  5/21
  Installing     : php53-mysql                                                                 6/21
  Installing     : php53-process                                                               7/21
  Installing     : php53-soap                                                                  8/21
  Installing     : php53-intl                                                                  9/21
  Installing     : php53-pgsql                                                                10/21
  Installing     : php53-devel                                                                11/21
  Installing     : php53-xmlrpc                                                               12/21
  Installing     : php53-imap                                                                 13/21
  Installing     : php53-gd                                                                   14/21
  Installing     : php53-dba                                                                  15/21
  Installing     : php53-pspell                                                               16/21
  Installing     : php53-bcmath                                                               17/21
  Installing     : php53-xml                                                                  18/21
  Installing     : php53-snmp                                                                 19/21
  Installing     : php53-odbc                                                                 20/21
  Installing     : php53-mbstring                                                             21/21

Installed:
  php53.i386 0:5.3.3-13.el5_8                       php53-bcmath.i386 0:5.3.3-13.el5_8
  php53-cli.i386 0:5.3.3-13.el5_8                   php53-common.i386 0:5.3.3-13.el5_8
  php53-dba.i386 0:5.3.3-13.el5_8                   php53-devel.i386 0:5.3.3-13.el5_8
  php53-gd.i386 0:5.3.3-13.el5_8                    php53-imap.i386 0:5.3.3-13.el5_8
  php53-intl.i386 0:5.3.3-13.el5_8                  php53-ldap.i386 0:5.3.3-13.el5_8
  php53-mbstring.i386 0:5.3.3-13.el5_8              php53-mysql.i386 0:5.3.3-13.el5_8
  php53-odbc.i386 0:5.3.3-13.el5_8                  php53-pdo.i386 0:5.3.3-13.el5_8
  php53-pgsql.i386 0:5.3.3-13.el5_8                 php53-process.i386 0:5.3.3-13.el5_8
  php53-pspell.i386 0:5.3.3-13.el5_8                php53-snmp.i386 0:5.3.3-13.el5_8
  php53-soap.i386 0:5.3.3-13.el5_8                  php53-xml.i386 0:5.3.3-13.el5_8
  php53-xmlrpc.i386 0:5.3.3-13.el5_8

Complete!

How to check php version :

[root@centos59 ~]# php -v
PHP 5.3.3 (cli) (built: Jun 27 2012 12:25:37)
Copyright (c) 1997-2010 The PHP Group
Zend Engine v2.3.0, Copyright (c) 1998-2010 Zend Technologies

How to check installed php packages :

[root@centos59 ~]# rpm -qa | grep php*
php53-5.3.3-13.el5_8
php53-soap-5.3.3-13.el5_8
php53-xmlrpc-5.3.3-13.el5_8
php53-pspell-5.3.3-13.el5_8
php53-odbc-5.3.3-13.el5_8
php53-common-5.3.3-13.el5_8
php53-cli-5.3.3-13.el5_8
php53-ldap-5.3.3-13.el5_8
php53-process-5.3.3-13.el5_8
php53-intl-5.3.3-13.el5_8
php53-devel-5.3.3-13.el5_8
php53-imap-5.3.3-13.el5_8
php53-dba-5.3.3-13.el5_8
php53-bcmath-5.3.3-13.el5_8
php53-snmp-5.3.3-13.el5_8
php53-mbstring-5.3.3-13.el5_8
php53-pdo-5.3.3-13.el5_8
php53-mysql-5.3.3-13.el5_8
php53-pgsql-5.3.3-13.el5_8
php53-gd-5.3.3-13.el5_8
php53-xml-5.3.3-13.el5_8

Work around for error “php53-odbc64 conflicts with php53-odbc”

Question :
When i try to run “yum install php53*”, or “yum install php” to install php package on CentOS5.9, i get the following error :

..
..
..
  --> php53-odbc64 conflicts with php53-odbc
Error: php53-odbc64 conflicts with php53-odbc
 You could try using --skip-broken to work around the problem
 You could try running: package-cleanup --problems
                        package-cleanup --dupes
                        rpm -Va --nofiles --nodigest
..
..

Example :

[root@centos59 ~]# yum install php53*
Loaded plugins: fastestmirror
Loading mirror speeds from cached hostfile
 * base: mirror.nus.edu.sg
 * extras: mirror.nus.edu.sg
 * updates: mirror.nus.edu.sg
Setting up Install Process
Resolving Dependencies
--> Running transaction check
---> Package php53.i386 0:5.3.3-13.el5_8 set to be updated
---> Package php53-bcmath.i386 0:5.3.3-13.el5_8 set to be updated
---> Package php53-cli.i386 0:5.3.3-13.el5_8 set to be updated
---> Package php53-common.i386 0:5.3.3-13.el5_8 set to be updated
---> Package php53-dba.i386 0:5.3.3-13.el5_8 set to be updated
---> Package php53-devel.i386 0:5.3.3-13.el5_8 set to be updated
---> Package php53-gd.i386 0:5.3.3-13.el5_8 set to be updated
---> Package php53-imap.i386 0:5.3.3-13.el5_8 set to be updated
---> Package php53-intl.i386 0:5.3.3-13.el5_8 set to be updated
---> Package php53-ldap.i386 0:5.3.3-13.el5_8 set to be updated
---> Package php53-mbstring.i386 0:5.3.3-13.el5_8 set to be updated
---> Package php53-mysql.i386 0:5.3.3-13.el5_8 set to be updated
---> Package php53-odbc.i386 0:5.3.3-13.el5_8 set to be updated
---> Package php53-odbc64.i386 0:5.3.3-2.el5 set to be updated
--> Processing Dependency: libodbc.so.2 for package: php53-odbc64
---> Package php53-pdo.i386 0:5.3.3-13.el5_8 set to be updated
---> Package php53-pgsql.i386 0:5.3.3-13.el5_8 set to be updated
---> Package php53-process.i386 0:5.3.3-13.el5_8 set to be updated
---> Package php53-pspell.i386 0:5.3.3-13.el5_8 set to be updated
---> Package php53-snmp.i386 0:5.3.3-13.el5_8 set to be updated
---> Package php53-soap.i386 0:5.3.3-13.el5_8 set to be updated
---> Package php53-xml.i386 0:5.3.3-13.el5_8 set to be updated
---> Package php53-xmlrpc.i386 0:5.3.3-13.el5_8 set to be updated
--> Running transaction check
---> Package unixODBC64-libs.i386 0:2.2.14-3.el5 set to be updated
--> Processing Dependency: libltdl.so.3 for package: unixODBC64-libs
--> Running transaction check
---> Package libtool-ltdl.i386 0:1.5.22-7.el5_4 set to be updated
--> Processing Conflict: php53-odbc64 conflicts php53-odbc
--> Finished Dependency Resolution
php53-odbc64-5.3.3-2.el5.i386 from base has depsolving problems
  --> php53-odbc64 conflicts with php53-odbc
Error: php53-odbc64 conflicts with php53-odbc
 You could try using --skip-broken to work around the problem
 You could try running: package-cleanup --problems
                        package-cleanup --dupes
                        rpm -Va --nofiles --nodigest

Solution :
Anyway, I’ve got the workaround for this issue as mentioned in the log above.

[root@centos59 ~]# yum install php53* --skip-broken