Friday, July 15, 2011

Make current directory DocumentRoot in apache

Create the following bash file and put it in the directory you want to use as apache root directory

#!/bin/sh
sed 's!\DocumentRoot .*!DocumentRoot '"`pwd`"'!' /etc/apache2/sites-available/default > default
sudo mv default  /etc/apache2/sites-available/
sudo /etc/init.d/apache2 restart

Friday, April 8, 2011

Connect Oracle with CakePHP

Tested with Windows XP and XAMPP 
1. Install XAMPP
2. Install OracleXEUniv
3. In php.iniuncomment the following line:
     extension=php_oci8.dll
4. Set app/config/database.php :
var $default = array('driver' => 'oracle',
             'connect' => 'oci',
            'persistent' => false,
            'host' => 'localhost',
            'port'=>1521,
            'login' => 'root',
            'password' => 'pass',
            'schema'=>'schama_name',
            'database' => 'localhost:1521/xe',
            'prefix' => ''
         );

Tuesday, January 25, 2011

Connect Cakephp application to remote database via SSH

Tested on ubuntu 10.4
Edit /etc/ssh/sshd_config on your local machine
Add:
AllowTcpForwarding yes
GatewayPorts yes

restart sshd
sudo /etc/init.d/ssh restart


Edit /etc/mysql/my.cnf on remote machine.
Uncomment the following line.
bind-address           = 127.0.0.1

restart mysql
sudo restart mysql

On you local machine run the following command
ssh -i e-keypair -f remoteuser@remote.com -N -L 4444:localhost:3306
If you are not using ssh key you will be prompt for remote user assword

Edit database.php

var $default = array(
        'driver' => 'mysqli',
        'persistent' => false,
        'host' => '127.0.0.1',
        'port'=>4444,
        'login' => 'user',
        'password' => 'pass',
        'database' => 'schema',
        'prefix' => '',
        );