Tuesday, October 4, 2011

Using Rsync to synchronize files/folders from Windows to Linux with SSH tunnel


Rsync Server on Linux

1. Rsync can be found in Linux repository and is easy to install using yum or apt-get commands.
                >> yum install rsync
                >> apt-get install rsync

2. Create a file rsyncd.conf at /etc and add following lines
                >> nano /etc/rsyncd.conf
               [your_user_sync]
                path = /home/your_user/backup
                comment = backup
                uid = your_user
                gid = your_user
                read only = false
                auth users = your_user
                secrets file = /etc/rsyncd.secrets
Here your_user is the username in your Linux machine.

Thursday, July 28, 2011

Nagios Client (NRPE) installation in Linux

i. Create Account Information
Become the root user. You may have to use sudo -s on Ubuntu and other distros.
su -l
Create a new nagios user account and give it a password.
/usr/sbin/useradd nagios
passwd nagios

ii. Install the Nagios Plugins
Create a directory for storing the downloads.
mkdir ~/downloads
cd ~/downloads

Nagios Client(NSClient) Installation in Windows

Installing nagios client is very simple. Download NSClient from location:
http://nsclient.org/nscp/downloads

You can download NSClient for 64 or 32 bit computer as required.

Copy NSClient in any folder. For e.g. D:\Nagios

Double click and install it. You will be asked for following information:
Allowed host: 'IP of your nagios server'
NSClient Password: 'Password you used when installing nagios server'
Also, enable the modules you need.

 Now configuration is finished. Restart NSClient. Fo this, go to 
Control Panel->Administrative Tools->Services->NSClient++
Start/Restart it.

Quick Installation of Nagios in CentOS

Nagios is a system and network monitoring application. Installation process is as below:

Prerequisites:
Before installing Nagios, you need to install the following on your linux machine:
     Apache
     PHP
     GCC compiler
     GD development libraries
You can use yum to install these packages by running the command:
yum install httpd php
yum install gcc glibc glibc-common
yum install gd gd-devel

Thursday, July 21, 2011

Completely Unistall MySQL

Whenever you install MySQL, uninstall it and try to install it again, you might not be able to do so because MySQL will ask for the old password. You cannot install MySQL if you do not have the old password. Solution for this is:

  • Uninstall MySQL
  • Go to your MySQL installation folder for e.g. C:\Program Files and delete the MySQL folder
  • Delete MySQL from your AppData folder. I am using windows XP and in my case, the location is C:\Documents and Settings\All Users\Application Data. Here you will find MySQL folder. Delete this folder.
  • Finally, reinstall MySQL and you should be able to install it successfully.

Sunday, July 17, 2011

Transferring cake baked code from windows to centos (linux)

First thing to do is to install cakephp in centos. Please refer to my previous blog on this(http://codebyte.blogspot.com/2011/07/installing-cakephp-in-centos.html) if you have not already installed cakphp.

Now, transfer your code to your document root (For e.g. /var/www/html in my case). Suppose, the name of your application is myapp, then
1. Open var/www/html/myapp/webroot/index.php

  • Search for if (!defined('CAKE_CORE_INCLUDE_PATH')).
  • You may find something like: define('CAKE_CORE_INCLUDE_PATH', 'C:' . DS. 'xampp' .DS. 'cake' if you used xampp in windows.
  • Change this to the location of your installed cakephp folder. For e.g. define('CAKE_CORE_INCLUDE_PATH', .DS . 'var' . DS. 'www' .DS. 'html' .DS. 'cake')

2. Open /var/www/html/myapp/config/database.php and provide appropriate database settings.

Finally, restart your apache server (/etc/init.d/httpd restart).

Installing CakePHP on CentOS

Download Cakephp
https://github.com/cakephp/cakephp/downloads

Rename it to something like cake. Extract from .tar.gz files.
tar -xvzf cake

Put 'cake' folder inside your document root. For e.g. if your document root is /var/www/html, put the cake folder inside it. Then follow some guidelines below.
1. Give appropriate permission setting for your 'cake' folder.
2. Open /cake/app/config/core.php. Go to the line where security.salt is defined and change it to some other value. Also do the same for security.cipherSeed.
3. Rename database.default.php to database.php and provide appropriate database settings

Now, open your browser and go to http://localhost/cake.

If you do no see any color in the page, you might want to check two things. Go to /etc/httpds/conf/httpd.conf and
1.  Search for mod_rewrite.so and check if LoadModule rewrite_module_modules modules/mod_rewrite.so is commented. If so, remove the comment.
2. Search for 'Options Indexed FollowSymLinks' and change 'AllowOverride None' to 'AllowOverride All' as below:
   <Directory />
    Options Indexed FollowSymLinks
    AllowOverride All
   </Directory>
 Note: Make sure you make the change in 'Options Indexed FollowSymLinks' and not in 'Options FollowSymLinks'.

Finally, restart apache (/etc/init.d/httpd restart).

Slow Connection to MySQL installed on windows from linux (Solved)

If you have MySQL installed in Windows server and you are querying from Linux, you might notice that the performance of you application is very slow. This is because, when your application in Linux connects to database in Windows, even a simple query takes 3-4 seconds to execute.

The solution for this problem is to put a line 'skip-nam-resovle' in my.ini of your mysql server. Search for [mysqld] in my.ini and put that line below it as below.

[mysqld]
skip-name-resolve

Saturday, June 25, 2011

Installing SugarCRM on Apache Web Server

Steps:
1. Create a database say 'sugarcrm'.

2. If you want to use open source SugarCRM, download SugarCRM Community Edition
   http://www.sugarcrm.com/crm/download/sugar-suite.html

3. Unzip it and place inside your application server deployment folder. Rename it with some name for e.g. sugarcrm.

4. Open your browser and type the url of your sugarcrm. For e.g. http://localhost/sugarcrm in my case. You will then see the sugarcrm page, click next. After that you will see a page as shown below.



  • Check if  php, database and web server are of supported version. If you are working in linux:     
    • You might need to give enough write permission to session variables by giving read and write access to 'session' located in  /var/lib/php/session
    •  Give appropriate read and write permission to config.php file located inside sugarcrm folder
    •  Give appropriate read and write permission to folders inside sugarcrm like custom, cache and modules
    • To install MB string and curl
      • yum install php_curl, php_mbstring (for CentOS)
    • If you are working in windows and want to  install MB strings, go to php.ini and    
      • ;extension=php_mbstring.dll with
      • extension=php_mbstring.dll
        check if php_mbstring.dll is present inside php 'ext' folder. 
      • To enable curl, uncheck php_curl.dll and check if it is present inside php 'ext' folder
    • Restart web server

5. Finally, you should be able to see 'Confirm Setting' page as shown below. In this page, if you see some of the modules not found, then you can enable the modules in php.ini as mentioned in step 4.


Now, after some steps, you will be redirected to sugarcrm login page. Login to the page and make the settings according to your requirement.

Connect MSSQL using ODBC in Linux (CentOS)

For connecting MSSQL using ODBC in Linux you can use unixODBC and freeTDS.  unixODBC is a tool for using ODBC in Non Windows platform. MSSQL uses Tabular Data Stream (TDS) as a communication protocol which is same like in Sybase. freeTDS is an implementation of TDS protocol.

Installing unixODBC
      1.      Install gcc
#yum install gcc

      2.      Download unixODBC and untar it
#mkdir /root/downloads
#cd /root/downloads
#wget ftp://ftp.unixodbc.org/pub/unixODBC/unixODBC-2.3.0.tar.gz
#tar –xzf unixODBC-2.3.0.tar.gz
#cd unixODBC-2.3.0

      3.      Install unixODBC
#./configure
#make
#make install

Installing freeTDS
     1.      Set environmental variable at /etc/profile. Add following lines at end
#nano /etc/profile


# TDS
SYBASE=/usr/local 
LD_LIBRARY_PATH=${LD_LIBRARY_PATH}:$SYBASE/lib 
export SYBASE LD_LIBRARY_PATH 
/etc/profile

     2.      Download freeTDS and untar it
#cd /root/downloads
#wget http://ibiblio.org/pub/Linux/ALPHA/freetds/stable/freetds-0.82.tar.gz
#tar –xzf freetds-0.82.tar.gz
#cd freetds-0.82
     3.      Install freeTDS
# ./configure --with-tdsver=8.0 --with-unixodbc=/usr/local
#make
#make install

     4.      Now all your library will be inside /usr/local/lib and configuration files inside /usr/local/etc

     5.      Make template to register ODBC driver with unixODBC
#nano /usr/local/etc/tds.driver.template


[FreeTDS]
Description     = v0.63 with protocol v8.0
Driver          = /usr/local/lib/libtdsodbc.so
tds.driver.template
     6.      Now install the driver entry using above template
# odbcinst -i -d -f /usr/local/etc/tds.driver.template

     7.      Make template to create ODBC data source name
#nano /usr/local/etc/tds.datasource.template


[MSSQLTest]
Driver  = FreeTDS
Description     = Sample Database
Trace   = No
Server      = 192.168.0.1
Port      = 1433
Database        = TestDB
tds.datasource.template
     8.      Now create odbc data source using above template
# odbcinst -i -s -f /usr/local/etc/tds.datasource.template

     9.      Finish. You can test it by giving command
                       # isql -v MSSQLTest username password 

Friday, June 17, 2011

CakePHP for beginners

This is my attempt to help you out if you are starting to learn cakephp.

If you want to install CakePHP in xampp, the below link will be helpful for you.
http://narenbimal.blogspot.com/2008/07/cake-is-php-web-development-framework.html

For the basic knowledge and tutorial you can go to the site.
http://book.cakephp.org/view/879/Beginning-With-CakePHP

To start learning with CakePHP, I found tutorials on youtube. It makes learning easy and convenient as we get the clear idea of what should be done. The uploader 'Andrew Perk' has made 10 tutorials starting from:
http://www.youtube.com/watch?v=nO9oSQhRa9s
You can view the rest 9 tutorials from the suggestions.

He has also made 3 more tutorials for authentication i.e. for login and logout which starts from:
http://www.youtube.com/watch?v=FjXAnizmR94
You can also see other tutorials there.

Hope you found this information useful.
Happy Coding!!