Archive for Ubuntu

Subversion: Installation and Basic Use

Posted in Apache, civiCRM, Dolphin, Drupal, Eclipse, Flex, IDE, Joomla, Linux, mysql, NoSQL, PHP, Technical, Uncategorized, Versioning, Wordpress, work with tags , , , , , , , , , , on November 16, 2010 by saffrongeek

Installing subversion:

saffrongeek@saffrongeek-laptop:/var/www/worksvndemo/drupal$ sudo apt-get install subversion

3 modes of svn setup & use:

svn with ssh=> especially, when the number of users is very few , this is best.

svn with svnserve=> custom server ‘svnserve’ is used when its not necessary to have high security,fine grained access.

svn with webdav=> when many projects and users.

 

svn architecture pic to help give a feel

Basic Setting up repository and familiarising:-

saffrongeek@saffrongeek-laptop:~$ sudo mkdir /var/svnrepo
saffrongeek@saffrongeek-laptop:~$ ls /var/svnrepo/
saffrongeek@saffrongeek-laptop:~$ svnadmin create /var/svnrepo/

saffrongeek@saffrongeek-laptop:~$ ls /var/svnrepo/
conf  db  format  hooks  locks  README.txt

Note:Recommended layout for a subversion project includes three folders called branches, tags and trunk. Now, @ webroot, I have my project folder wordpress which I would prefer to import to repository.

saffrongeek@saffrongeek-laptop:/var/www$ sudo svn import wordpress/ file:///var/svnrepo/wordpress/trunk -m “Initial import”

….

Adding         wordpress/wp-admin/themes.php
Adding         wordpress/wp-admin/custom-background.php
Adding         wordpress/wp-feed.php

Committed revision 1.

Now, deleted the project folder from webroot.

saffrongeek@saffrongeek-laptop:/var/www/wordpress$ rm -rf wordpress

checking out

saffrongeek@saffrongeek-laptop:/var/www/wordpress$ svn co file:///var/svnrepo/wordpress/trunk wordpress

…….

A    wordpress/wp-admin/custom-background.php
A    wordpress/wp-feed.php
Checked out revision 1.

After checkout, watever we add folder or files, add the root of the folder added.

saffrongeek@saffrongeek-laptop:/var/www/wordpress$ svn add {foldername}

Any changes reflect on svn after a commit statement

saffrongeek@saffrongeek-laptop:/var/www/wordpress$ svn commit -m “Added folder and text file in it”

Same way, we can delete using ‘delete’ instead of ‘add’ above. Again after delete u have to commit to reflect this on server.

Subversion using svnserve:-

Note: SVN repo is created in my case at /var/svnrepo as u can find from above.

Setting the access rules first:-

Go to /var/svnrepo/conf/ and open svnserve.conf.

Uncomment following in the conf.

[general]
anon-access = read
auth-access = write
realm = wordpress
password-db = passwd

saffrongeek@saffrongeek-laptop:/var/svnrepo/conf$ sudo gedit passwd  ( I kept harry:rekha )

svnserve can now be started using => saffrongeek@saffrongeek-laptop:/var/svnrepo/conf$ svnserve -d -r /var/svnrepo/

Note: if u get this error, “svnserve: Can’t bind server socket: Address already in use” all u need to do is make ur attempt to start , asking svnserve to listen to another port. Default is 631.

saffrongeek@saffrongeek-laptop:/var/svnrepo/conf$svnserve -d –listen-port {someportnumber} -r /var/svnrepo/ should resolve bind problem.

I dint find svnserve init script in /etc/init.d/ but this script came handy for me. I took this from internet. note that u can also set crontab.

#!/bin/sh
#File: /etc/init.d/svnserve
REPO_ROOT=/home/user/myrepo/
SVN_UID=user
SVN_GID=user
. /etc/rc.status
rc_reset
case “$1” in
start)
echo -n “Starting svnserve ”
startproc -u $SVN_UID -g $SVN_GID -e svnserve -d -R -r $REPO_ROOT
rc_status -v
;;
stop)
echo -n “Shutting down svnserve ”
killproc -TERM svnserve
rc_status -v
;;
restart)
$0 stop
$0 start
rc_status
;;
*)
echo “Usage: $0 {start|stop|restart}”
exit 1
;;
esac
rc_exit

After this, repo is accessible as svn://username@urlhostname. Also from ur local machine when u make a change and commit it , now since access permissions are defined, commit syntax luks as below

$svn commit -m "Added folder" --username harish
password for 'harish': rekha , pressed enter and it shows status of command execution.

Readable links which could be quite handy and useful:- https://help.ubuntu.com/community/Subversion
Advertisements

Installing Eclipse

Posted in Apache, civiCRM, Dolphin, Drupal, Eclipse, Flex, IDE, Joomla, Linux, PHP, Technical, Wordpress, work with tags , , , on November 14, 2010 by saffrongeek

On Ubuntu Machine:-

Addressing primary pre-requisite:-

#. Open a shell terminal and type the following command or open system -> synaptic package manager

$ sudo apt-get install sun-java6-bin sun-java6-jre sun-java6-jdk

Now, let us install Eclipse via synaptic package manager. System-> Synaptic Package Manager, when open type “eclipse “.

Note:- I have selected following eclipse, eclipse-rcp, eclipse-platform, eclipse-emf, eclipse-platform-data, eclipse-pde, eclipse-plugin-cvs, eclipse-wtp, eclipse-dltk,eclipse-dtp, eclipse-jdt,eclipse-pdt, eclipse-gef etc..

Post Completion

Go to Applications->Programming->Eclipse.

 

Enabling Clean – Urls in Drupal 6.3

Posted in Apache, Linux, mysql, PHP, Technical, work with tags , , , on November 11, 2010 by saffrongeek

Drupal 6.3, Ubuntu , PHP5

How to reach clean url admin page:-
Administration Section->Site configuration->Clean URLs

Default Screen


Now, here I found that enable disable was not working. Somewhr I had read about JS based environment luk up happening for clean urls in threads. So I disabled JS from firefox browser. ( Edit menu->Preferences )

 

JS disabling gets the link to run test manually

After disabling, I refreshed clean url admin page. The page now gives me the “Run test for clean-url”.

I click on the link and it takes me to ‘Not found’ page.

What to review at this point??
#1. .htaccess got copied to root of your install
#2. If #1 is true, Test whether its seen by Apache for handling directives in it. For this type some random chars/text and restart server and access your install. This should break your install. If so, then it luks good. Remove the chars / text and continue to read the following.
#3. Uncomment ‘RewriteBase /drupal’. Note that ‘drupal’ used here is my folder name where I have drupal extracted in my webroot.

Now refresh your clean url admin page. I hope you got a smile seeing the change. 🙂 Cheers.

enable disable controls 🙂

Enabling rewrite mod

Posted in Uncategorized with tags , , , , on May 26, 2010 by saffrongeek

saffrongeek@saffrongeek-laptop:~$ a2enmod rewrite
Enabling module rewrite.
Could not create /etc/apache2/mods-enabled/rewrite.load: Permission denied
saffrongeek@saffrongeek-laptop:~$ sudo a2enmod rewrite
[sudo] password for saffrongeek:
Enabling module rewrite.
Run ‘/etc/init.d/apache2 restart’ to activate new configuration!
saffrongeek@saffrongeek-laptop:~$ /etc/init.d/apache2 restart
* Restarting web server apache2 apache2: Could not reliably determine the server’s fully qualified domain name, using 127.0.1.1 for ServerName
apache2: Could not reliably determine the server’s fully qualified domain name, using 127.0.1.1 for ServerName
(13)Permission denied: make_sock: could not bind to address 0.0.0.0:80
no listening sockets available, shutting down
Unable to open logs
[fail]
saffrongeek@saffrongeek-laptop:~$ sudo /etc/init.d/apache2 restart
* Restarting web server apache2 apache2: Could not reliably determine the server’s fully qualified domain name, using 127.0.1.1 for ServerName
… waiting .apache2: Could not reliably determine the server’s fully qualified domain name, using 127.0.1.1 for ServerName
[ OK ]
saffrongeek@saffrongeek-laptop:~$

Checking GD library installation

Posted in Uncategorized with tags , , on May 26, 2010 by saffrongeek

In Ubuntu, open a terminal and type the following:-
saffrongeek@saffrongeek-laptop:~$ php -r “var_dump(function_exists(‘imagecreatefromjpeg’));”
if bool(true) is the status implies installed.

To check whether is limited installation, try below
saffrongeek@saffrongeek-laptop:~$ php -r “var_dump(function_exists(‘imagerotate’));”
bool(false)

Meld : File Comaprison UI Tool [ Ubuntu ]

Posted in coldfusion, Linux, PHP, Technical, work with tags , , , , , , , , on September 21, 2009 by saffrongeek

I was in need of a file comparison tool , which is UI based and very handy application. Luckily, even though I heard about Kdiff and Emacs to do the purpose, I decided to try for Meld.

My comment : Wow!! Easy to get, set , Run. Very Handy to use.

Available @ CLICK_LINK Or Open a terminal and type the below command:

saffrongeek@saffrongeek-laptop:~$ sudo apt-get install meld

Note: You could also use Synaptic package manager for installation of this package.
meldBlog

cwarn2’s classic function handles dates pre-1970

Posted in Apache, Linux, mysql, PHP, Technical, work with tags , , , , , , , , , on September 5, 2009 by saffrongeek

I would like to share a neat decent function to handle the dates pre-1970 which normally would find getting reset to 1970, January 01. I had a need where I need to handle birthdates pre-1970 and PHP’s in built functions like strtotime (), date(), mktime() , including safestrotime() of no help.

Thanks to the patience and effort of cwarn2, whom I met at Daniweb, I now have a function that address my need. This post is an acknowledgment to cwarn2 friendly mind. Thanks cwarn2.

To know more about cwarn2 and other contributions , please visit http://syntax.cwarn23.info/PHP:_Contents . There are other great scenarios where cwarn2 has contributed with solutions.

Below is the cwarn2’s function to handle dates pre-1970:

==================================================================================
=================== cwarn2 function to handle dates pre-1970 ================================

function get_date($date,$timestamp=false) {
    if ($timestamp==false) {
        $timestamp=time();
        } else {
        $timestamp=round($timestamp);
        }
    if ($timestamp>=0) {
        return date($date,$timestamp);
        } else {
        if ($timestamp$timestamp;) { //year loop
            $year--;
            for ($k=31; $k>0;$k--) { //month loop (December)
                $month=12;
                $day=$k;
                if (($i-86400)>$timestamp) {
                    $i-=86400;
                    $l=24; $hour=24;
                    $m=59; $minute=59;
                    $n=59; $second=59;
                    } else {
                    for ($l=24; $l>0;$l--) {
                        $hour=$l;
                        for ($m=59; $m>-1;$m--) {
                            $minute=$m;
                            for ($n=59; $n>-1;$n--, $i--) {
                                $second=$n;
                                if ($i==$timestamp) { break;break;break;break;break; }
                                }
                            if ($i==$timestamp) { break;break;break;break; }
                            }
                        if ($i==$timestamp) { break;break;break; }
                        }
                    }
                if ($i==$timestamp) { break;break; }
                }
            if ($i==$timestamp) { break; }
            for ($k=30; $k>0;$k--) { //month loop (November)
                $month=11;
                $day=$k;
                if (($i-86400)>$timestamp) {
                    $i-=86400;
                    $l=24; $hour=24;
                    $m=59; $minute=59;
                    $n=59; $second=59;
                    } else {
                    for ($l=24; $l>0;$l--) {
                        $hour=$l;
                        for ($m=59; $m>-1;$m--) {
                            $minute=$m;
                            for ($n=59; $n>-1;$n--, $i--) {
                                $second=$n;
                                if ($i==$timestamp) { break;break;break;break;break; }
                                }
                            if ($i==$timestamp) { break;break;break;break; }
                            }
                        if ($i==$timestamp) { break;break;break; }
                        }
                    }
                if ($i==$timestamp) { break;break; }
                }
            if ($i==$timestamp) { break; }
            for ($k=31; $k>0;$k--) { //month loop (October)
                $month=10;
                $day=$k;
                if (($i-86400)>$timestamp) {
                    $i-=86400;
                    $l=24; $hour=24;
                    $m=59; $minute=59;
                    $n=59; $second=59;
                    } else {
                    for ($l=24; $l>0;$l--) {
                        $hour=$l;
                        for ($m=59; $m>-1;$m--) {
                            $minute=$m;
                            for ($n=59; $n>-1;$n--, $i--) {
                                $second=$n;
                                if ($i==$timestamp) { break;break;break;break;break; }
                                }
                            if ($i==$timestamp) { break;break;break;break; }
                            }
                        if ($i==$timestamp) { break;break;break; }
                        }
                    }
                if ($i==$timestamp) { break;break; }
                }
            if ($i==$timestamp) { break; }
            for ($k=30; $k>0;$k--) { //month loop (September)
                $month=9;
                $day=$k;
                if (($i-86400)>$timestamp) {
                    $i-=86400;
                    $l=24; $hour=24;
                    $m=59; $minute=59;
                    $n=59; $second=59;
                    } else {
                    for ($l=24; $l>0;$l--) {
                        $hour=$l;
                        for ($m=59; $m>-1;$m--) {
                            $minute=$m;
                            for ($n=59; $n>-1;$n--, $i--) {
                                $second=$n;
                                if ($i==$timestamp) { break;break;break;break;break; }
                                }
                            if ($i==$timestamp) { break;break;break;break; }
                            }
                        if ($i==$timestamp) { break;break;break; }
                        }
                    }
                if ($i==$timestamp) { break;break; }
                }
            if ($i==$timestamp) { break; }
            for ($k=31; $k>0;$k--) { //month loop (August)
                $month=8;
                $day=$k;
                if (($i-86400)>$timestamp) {
                    $i-=86400;
                    $l=24; $hour=24;
                    $m=59; $minute=59;
                    $n=59; $second=59;
                    } else {
                    for ($l=24; $l>0;$l--) {
                        $hour=$l;
                        for ($m=59; $m>-1;$m--) {
                            $minute=$m;
                            for ($n=59; $n>-1;$n--, $i--) {
                                $second=$n;
                                if ($i==$timestamp) { break;break;break;break;break; }
                                }
                            if ($i==$timestamp) { break;break;break;break; }
                            }
                        if ($i==$timestamp) { break;break;break; }
                        }
                    }
                if ($i==$timestamp) { break;break; }
                }
            if ($i==$timestamp) { break; }
            for ($k=31; $k>0;$k--) { //month loop (July)
                $month=7;
                $day=$k;
                if (($i-86400)>$timestamp) {
                    $i-=86400;
                    $l=24; $hour=24;
                    $m=59; $minute=59;
                    $n=59; $second=59;
                    } else {
                    for ($l=24; $l>0;$l--) {
                        $hour=$l;
                        for ($m=59; $m>-1;$m--) {
                            $minute=$m;
                            for ($n=59; $n>-1;$n--, $i--) {
                                $second=$n;
                                if ($i==$timestamp) { break;break;break;break;break; }
                                }
                            if ($i==$timestamp) { break;break;break;break; }
                            }
                        if ($i==$timestamp) { break;break;break; }
                        }
                    }
                if ($i==$timestamp) { break;break; }
                }
            if ($i==$timestamp) { break; }
            for ($k=30; $k>0;$k--) { //month loop (June)
                $month=6;
                $day=$k;
                if (($i-86400)>$timestamp) {
                    $i-=86400;
                    $l=24; $hour=24;
                    $m=59; $minute=59;
                    $n=59; $second=59;
                    } else {
                    for ($l=24; $l>0;$l--) {
                        $hour=$l;
                        for ($m=59; $m>-1;$m--) {
                            $minute=$m;
                            for ($n=59; $n>-1;$n--, $i--) {
                                $second=$n;
                                if ($i==$timestamp) { break;break;break;break;break; }
                                }
                            if ($i==$timestamp) { break;break;break;break; }
                            }
                        if ($i==$timestamp) { break;break;break; }
                        }
                    }
                if ($i==$timestamp) { break;break; }
                }
            if ($i==$timestamp) { break; }
            for ($k=31; $k>0;$k--) { //month loop (May)
                $month=5;
                $day=$k;
                if (($i-86400)>$timestamp) {
                    $i-=86400;
                    $l=24; $hour=24;
                    $m=59; $minute=59;
                    $n=59; $second=59;
                    } else {
                    for ($l=24; $l>0;$l--) {
                        $hour=$l;
                        for ($m=59; $m>-1;$m--) {
                            $minute=$m;
                            for ($n=59; $n>-1;$n--, $i--) {
                                $second=$n;
                                if ($i==$timestamp) { break;break;break;break;break; }
                                }
                            if ($i==$timestamp) { break;break;break;break; }
                            }
                        if ($i==$timestamp) { break;break;break; }
                        }
                    }
                if ($i==$timestamp) { break;break; }
                }
            if ($i==$timestamp) { break; }
            for ($k=30; $k>0;$k--) { //month loop (April)
                $month=4;
                $day=$k;
                if (($i-86400)>$timestamp) {
                    $i-=86400;
                    $l=24; $hour=24;
                    $m=59; $minute=59;
                    $n=59; $second=59;
                    } else {
                    for ($l=24; $l>0;$l--) {
                        $hour=$l;
                        for ($m=59; $m>-1;$m--) {
                            $minute=$m;
                            for ($n=59; $n>-1;$n--, $i--) {
                                $second=$n;
                                if ($i==$timestamp) { break;break;break;break;break; }
                                }
                            if ($i==$timestamp) { break;break;break;break; }
                            }
                        if ($i==$timestamp) { break;break;break; }
                        }
                    }
                if ($i==$timestamp) { break;break; }
                }
            if ($i==$timestamp) { break; }
            for ($k=31; $k>0;$k--) { //month loop (March)
                $month=3;
                $day=$k;
                if (($i-86400)>$timestamp) {
                    $i-=86400;
                    $l=24; $hour=24;
                    $m=59; $minute=59;
                    $n=59; $second=59;
                    } else {
                    for ($l=24; $l>0;$l--) {
                        $hour=$l;
                        for ($m=59; $m>-1;$m--) {
                            $minute=$m;
                            for ($n=59; $n>-1;$n--, $i--) {
                                $second=$n;
                                if ($i==$timestamp) { break;break;break;break;break; }
                                }
                            if ($i==$timestamp) { break;break;break;break; }
                            }
                        if ($i==$timestamp) { break;break;break; }
                        }
                    }
                if ($i==$timestamp) { break;break; }
                }
            if ($i==$timestamp) { break; }
            if (round((1972-$year)/4)==((1972-$year)/4)) {
                $j=29;
                } else {
                $j=28;
                }
            for ($k=$j; $k>0;$k--) { //month loop (February)
                $month=2;
                $day=$k;
                if (($i-86400)>$timestamp) {
                    $i-=86400;
                    $l=24; $hour=24;
                    $m=59; $minute=59;
                    $n=59; $second=59;
                    } else {
                    for ($l=24; $l>0;$l--) {
                        $hour=$l;
                        for ($m=59; $m>-1;$m--) {
                            $minute=$m;
                            for ($n=59; $n>-1;$n--, $i--) {
                                $second=$n;
                                if ($i==$timestamp) { break;break;break;break;break; }
                                }
                            if ($i==$timestamp) { break;break;break;break; }
                            }
                        if ($i==$timestamp) { break;break;break; }
                        }
                    }
                if ($i==$timestamp) { break;break; }
                }
            if ($i==$timestamp) { break; }
            for ($k=31; $k>0;$k--) { //month loop (January)
                $month=1;
                $day=$k;
                if (($i-86400)>$timestamp) {
                    $i-=86400;
                    $l=24; $hour=24;
                    $m=59; $minute=59;
                    $n=59; $second=59;
                    } else {
                    for ($l=24; $l>0;$l--) {
                        $hour=$l;
                        for ($m=59; $m>-1;$m--) {
                            $minute=$m;
                            for ($n=59; $n>-1;$n--, $i--) {
                                $second=$n;
                                if ($i==$timestamp) { break;break;break;break;break; }
                                }
                            if ($i==$timestamp) { break;break;break;break; }
                            }
                        if ($i==$timestamp) { break;break;break; }
                        }
                    }
                if ($i==$timestamp) { break;break; }
                }
            if ($i==$timestamp) { break; }
 
            }
        }
        if ($hour>12) {
            $ampm='PM';
            $pmam='pm';
            } else {
            $ampm='AM';
            $pmam='am';
            }
        if ($hour>12) {
            $hr=$hour-12;
            } else {
            $hr=$hour;
            }
        if ($second<10) {
            $second='0'.$second;
            }
        if ($minute<10) {
            $minute='0'.$minute;
            }
        return str_replace(array('Y','n','j','H','h','i','s','a','A'),array($year,$month,$day,$hour,$hr,$minute,$second,$pmam,$ampm),$date);
    }
%d bloggers like this: