web analytics

Category Misc

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

Sharding in MongoDB

Sharding refers to the process of distributing data across multiple servers which helps in retrieving it easily. When the data set is huge, it is said that sharding significantly improves the query response time.

Let us see how we can implement sharding. Sharding requires a  minimum of three servers for test purpose. In production scenario, sharding may require more servers.

Sharding is implemented through the following :-

1) Config Servers – These servers contain the metadata as to where the data belongs to. Means, it holds data as to which shard each data goes. A minimum of 2 config servers in a huge databases system is recommended.

2) Query Router Servers – These servers are the ones that communicate with the application directly...

Read More

Find the number of FTP connections along with the connected IP Addresses

You can use the following t o find which all IP Addresses are connected to server via FTP as well as the number of connections.

netstat -tpn | grep pure-ftpd | awk ‘{print $5}’ | cut -d”:” -f1 | sort | uniq -c | sort -nr

Read More

ERROR: Error creating index db.collection-101613_nno.csv: 16633 err: “text search not enabled”

I was trying to restore a database onto a new server, when I got the following error.

mongorestore -d db /backup/db

ERROR: Error creating index db.collection-101613_nno.csv: 16633 err: “text search not enabled”

In order to correct this, you need to enabled text search. Simply stop the mongo process and start it with text search enabled.

root@abc# /etc/rc.d/init.d/mongod stop

root@abc# /usr/bin/mongod -f /etc/mongod.conf –setParameter textSearchEnabled=true

Now try restoring again and it works.

Read More

Configuring SSL in nginx

Suppose you have a domain greproot.com for which you want to enable SSL. Make sure you have a dedicated IP for the domain. Say, 1.2.3.4 is the dedicated IP address for greproot.com

First, decide where you want to keep your certs and keys. In my case, I am going to place it in /etc/ssl/certs/ and /etc/ssl/keys respectively.

[root@abc ~]#mkdir /etc/ssl/certs/

[root@abc ~]#mkdir /etc/ssl/keys

Now we need to generate CSR and key for the greproot.com, get the cert signed and then install SSL.

[root@abc ~]#cd /etc/ssl/keys

[root@abc ~]#openssl genrsa -out greproot.com.key 2048

[root@abc ~]# chmod 600 greproot.com.key

[root@abc ~]# cd /etc/ssl/certs/

[root@abc ~]#openssl req -new -key greproot.com.key -out greproot.com.csr

Now we have the CSR and key...

Read More

Password Protecting a Site in nginx

This post will explain how to password protect a site in nginx. It is very simple and it uses the normal htpasswd protection

Suppose I need to password protect the site greproot.com whose document root is /var/www/greproot/public_html

Simple follow the steps given below

[root@abc ~]#  cd /var/www/greproot/public_html

[root@abc ~]#  htpasswd -c .htpasswd admin        where admin is the username chosen. It will prompt for password, give a strong password.

Now, your login details are stored to the file /var/www/greproot/public_html/.htpasswd and we need to call this file from greproot.com’s conf.

Simply add the following two lines before the locations

[root@abc ~]# cd /etc/nginx/sites-available/

[root@abc ~]# vi greproot.com

auth_basic “Restricted”;
auth_basic_user_file /var/www/g...

Read More

Adding domains under nginx

You can install nginx webserver as mentioned in this link

Now to add domains to it, we create two folders for the virtualhosts.

1) sites-available for all virtualhosts

2) sites-enabled for those virtualhosts that are active

We are going to create the domain greproot.com with username as greproot

The document root will be under /var/www/greproot/public_html. So create a user with home directory set to /var/www/greproot

[root@abc ~]# useradd -d /var/www/greproot  greproot

[root@abc ~]# passwd greproot                      # give a strong password for the user

[root@abc ~]# mkdir /var/www/greproot/public_html

[root@abc ~]# mkdir /var/www/greproot/logs

[root@abc ~]# touch /var/www/greproot/logs/access.log

[root@abc ~]# touch /var/www/greproot/logs/error.log

[root@abc ~]# chown -R...

Read More

Extend partitions in 1&1 dedicated servers

1&1 dedicated servers comes with pre-configured partitions which are too small in size. If you are to host websites, create databases etc, you should definitely extend those partitions, or you will soon be flooded with low disk space warnings.

This post will tell you how you can increase the partition size. In the example I consider here, the server has two disks with 1.5T space each. The server has RAID1, which means the total usable space is 1.5T. This is how my partitions are currently.


[root@abc ~]# df -h
Filesystem            Size  Used Avail Use% Mounted on
/dev/md1              4.0G  615M  3.4G  16% /
/dev/mapper/vg00-usr  4.0G  1.3G  2.5G  35% /usr
/dev/mapper/vg00-var  4.0G  334M  3.5G   9% /var
/dev/mapper/vg00-home
4.0G  136M  3...
Read More

Install nginx webserver in Centos6 server

You can install nginx webserver in Centos6 server with yum. It is simple and easy. Follow the steps given below.

First we need to install the nginx repo

[root@abc ~]# cd /etc/yum.repos.d/

[root@abc yum.repos.d]# wget http://nginx.org/packages/centos/6/noarch/RPMS/nginx-release-centos-6-0.el6.ngx.noarch.rpm

[root@abc yum.repos.d]# rpm -ivh nginx-release-centos-6-0.el6.ngx.noarch.rpm

Make sure that the repo nginx.repo is listed at /etc/yum.repos.d. Once it is done, you can install nginx using yum

[root@abc yum.repos.d]# yum install nginx

The nginx configuration file is available at /etc/nginx/nginx.conf. You need to update the worker process in it. The worker process can be equal to the number of CPUs in the server.

[root@abc ~]# cat /proc/cpuinfo  | grep processor | wc -l

8

The above ...

Read More

Error: Missing Dependency: python(abi) = 2.6 is needed by package s3cmd-1.0.0-4.1.x86_64 (s3tools)

I was trying to install s3cmd in my centos6 server when i got the following error.

s3cmd-1.0.0-4.1.i386 from s3tools has depsolving problems —> Missing Dependency: python(abi) = 2.6 is needed by package s3cmd-1.0.0-4.1.i386 (s3tools)
s3cmd-1.0.0-4.1.x86_64 from s3tools has depsolving problems —> Missing Dependency: python(abi) = 2.6 is needed by package s3cmd-1.0.0-4.1.x86_64 (s3tools)
Error: Missing Dependency: python(abi) = 2.6 is needed by package s3cmd-1.0.0-4.1.x86_64 (s3tools)
Error: Missing Dependency: python(abi) = 2.6 is needed by package s3cmd-1.0.0-4.1.i386 (s3tools) You could try using —skip-broken to work around the problem

If you are getting python dependency issues with s3cmd tools in centos6, please instal EPEL repo and it will solve it.

wget http://dl...

Read More