web analytics

Linux Booting Process

You turn on a linux machine, a splash screen appears for a few seconds and then in a small delay you are greeted with a login page. You login and then starts working. Ever wondered what happens behind the scenes, when you turn on the machine? How does the machine boots? Continue reading.

The linux booting process happens in 6 stages.
Stages-of-Linux-Boot-Process

1) BIOS
————

When you power on the machine, CPU asks ROM what to do. ROM has a JUMP instruction which commands CPU to check the BIOS. BIOS stands for Basic Input/Output system. BIOS is the first thing that is loaded, and its main role is to check the hardware and performs integrity checks. Its main role is to identify the boot device as defined in the CMOS...

Read More

Class ‘horde_Hooks’ not found

After recent cpanel update, I started getting the following error while accessing horde webmail.

A fatal error has occurred

Class ‘horde_Hooks’ not found

Details have been logged for the administrator.

This problem is expected to be fixed before cPanel 11.51 becomes 11.52 and is published to CURRENT, but it is still occurring in the 11.51 build that is in EDGE right now. The temporary fix for that problem is as follows.

Run the below commands.

[root@abc ~]# find /usr/local/cpanel/base/horde -name ‘hooks.php’ -not -wholename ‘*/imp/*’

[root@abc ~]# find /usr/local/cpanel/3rdparty/php/54/lib/php/Horde/Core -name ‘hooks.php’ -not -wholename ‘*/imp/*’

Now, move or remove any files that are listed by the above find commands...

Read More

df showing wrong result

My mysql server suddenly started showing my disk space usage as almost full.

[root@abc /]# df -h
Filesystem      Size  Used Avail Use% Mounted on
/dev/sda3       550G  508G   14G  98% /
tmpfs            32G     0   32G   0% /dev/shm
/dev/sda1       2.0G  173M  1.8G   9% /tmp

But when I issued a disk usage check on / , it returned the usage to be very little.

[root@abc /]# du -sch
47G     .
47G     total

I was sure there is something wrong. Hence, I checked for deleted files. You can use either of the following commands.

[root@abc /]# lsof +L1

mysqld    23193     mysql    5u   REG    8,1          184     0       13 /tmp/ibrUf6yr (deleted)
mysqld    23193     mysql    6u   REG    8,1            0     ...

Read More

Enabling detailed debug log in imap

Sometimes your might need to check for detailed logging in email. One of my friends was  developing an email application and he wanted to check what was happening behind the screen when he received an email, moves it to another folder, deletes it etc.

Hence, we decided to enable detailed logging in imap. It was a cpanel server and we used the option imapdebug. Always keep a backup of the file you edit.

root@abc# cp -pv /usr/lib/courier-imap/etc/imapd /usr/lib/courier-imap/etc/imapd.bak.$(date +%F)

root@abc# vi /usr/lib/courier-imap/etc/imapd

Now uncomment the following line.

IMAPDEBUGFILE=”imaplog.txt”

Now touch a file named  imaplog.txt at the root of the account where you want to enable logging. Restart the courier service. Suppose I need to enable logging for greproot@abc.com.

root...

Read More

(28)No space left on device: mod_rewrite: Parent could not create RewriteLock file

Noticed this error in a cpanel server while starting apache. Apache refused to start with the following error.

(28)No space left on device: mod_rewrite: Parent could not create RewriteLock file

Seeing the error, the first thing that I checked was the disk space in the server but it looked fine.

root@abc [~]# df -h
Filesystem            Size  Used Avail Use% Mounted on
/dev/mapper/vg0-root   16G  1.2G   14G   8% /
/dev/mapper/vg0-home  249G  124G  113G  53% /home
/dev/mapper/vg0-var    23G  7.0G   15G  33% /var
/dev/mapper/vg0-usr    23G  7.6G   14G  36% /usr
/dev/mapper/vg0-tmp   9.5G  151M  8.9G   2% /tmp
/dev/sda1             7.4G  184M  6.9G   3% /boot
tmpfs                 7.9G     0  7...

Read More

PHP Warning: mysql_connect(): No such file or directory

I was getting the following error while trying out a basic mysql connection script.

PHP Warning: mysql_connect(): No such file or directory

The script I used was as follows.

<?php
$mysql_hostname = “localhost”;
$mysql_user = “root”;
$mysql_password = “abc123”;
$mysql_database = “testdb”;

$link = mysql_connect($mysql_hostname, $mysql_user, $mysql_password);
mysql_select_db($mysql_database,$link);
if (!$link) {
die(‘Could not connect: ‘ . mysql_error());
}
else
echo ‘Connected successfully’;
?>

Executing the script returned the following error.

root@abc:/var/www/html/scripts# php test.php
PHP Warning:  mysql_connect(): No such file or directory in /var/www/html/scripts/test.php on line 7
PHP Warning:  mysql_select_db() expects parameter 2 to be resource, boolean given in /var/www/html/...

Read More

Fatal error: Uncaught exception ‘MongoCursorException’ with message ‘localhost:27017: not authorized for query on admin.system.namespaces’ – Moadmin error after enabling authentication in mongodb

If you enabled authentication for mongodb, then moadmin will fail to show the databases. This is because moadmin is  not authenticated to list the databases. You might get the following error.

Fatal error: Uncaught exception ‘MongoCursorException’ with message ‘localhost:27017: not authorized for query on admin.system.namespaces’

I am considering a scenario where I enabled authentication as said in the link here. In that case open your moadmin.php file and make the following change, so that it authenticates itself.

You need to edit MONGO_CONNECTION parameter.

root@abc:~# vi /home/abc/public_html/moadmin.php

#define(‘MONGO_CONNECTION’, ”);        // Comment out the old connection parameter
define(‘MONGO_CONNECTION’, ‘mongodb://admin:admin@127.0.0...

Read More

Authentication in mongodb

Mysql databases allow username and password. Similarly if you require to keep authentication for your mongodb database as well, please do the following. Suppose, I have a database named abc, and I need to create a user named abc with password abc123.

First, create an admin user.

root@abc:~# mongo
MongoDB shell version: 2.4.10
connecting to: test
> use admin
> db.addUser("admin", "admin")

> use abc                   (Switch to the database abc)

> db.addUser("abc", "abc123")

Quit the mongoshell and stop mongo

root@abc:~# /etc/init.d/mongodb stop

root@abc:~# vi /etc/mongodb.conf    and make the following change

auth = true

root@abc:~#/etc/init.d/mongodb start

Now we need to test if authentication works...

Read More

Accessing Gmail with Roundcube

Requirement : I want to access my gmail under my own domain with the help of webmail.

Say my domain name is abc.com , I want to access it as http://abc.com/mail

Suppose I am on a cpanel server. Download and install Roundcube as follows.

root@me [/home/abc/public_html]# wget http://downloads.sourceforge.net/project/roundcubemail/roundcubemail/1.0.0/roundcubemail-1.0.0.tar.gz

root@me [/home/abc/public_html]# tar -xzvf roundcubemail-1.0.0.tar.gz

root@me [/home/abc/public_html]# mv roundcubemail-1.0.0 mail

root@me [/home/abc/public_html]# chown -R abc:abc mail

root@me [/home/abc/public_html]# cd mail

Now login to your cpanel and create a database for roundcube installation, create a database user and assign privileges. This can all be done from cpanel.

Once done, go to the installer link as ...

Read More

Migrating emails from mailenable to exim

I wanted to transfer my entire sites from my Windows Plesk server to Linux Cpanel server. I could simply create the new accounts in the new server and copy the files. The main issue was with emails. My windows server was using mail enable, where as the the cpanel server uses exim.

I realized I will have to create all email accounts manually in the new server. A simple tool which will do everything in a click was not available. Losing email was not something I could let happen, so I decided to go ahead with creating accounts and then copying emails. I used imapcopy for it. If anybody wants to do it, you can do it as follows. I am copying the email account test@abc.com to new server. Its password is test123c on both servers.

root@abc [~]# cd /usr/local/src/

root@abc [/usr/local/src]#  wget ...

Read More