Friday, August 21, 2009

CakePHP - start a project with the console application

To start fast a new project with cakephp 1.2 you will need:

- web server - I use apache 2.2
- php4 or php5 - I use php5
- mysql server - I use mysql 5.0.45
- cakephp - I use cake_1.2.4.8284

After the web and mysql servers are installed install the cakephp - I choosed the path

/var/www/frameworks/cake_1.2.4.8284

Then open a xterm or any shell:

cd /var/www/frameworks/cake_1.2.4.8284/cake/console
cake bake help

Will give you all the info you need to know on how to bootstrap your new project.
I choosed the following:

cake bake project
Then just answer the questions that cake asks:


Welcome to CakePHP v1.2.4.8284 Console
---------------------------------------------------------------
App : app
Path: /var/www/frameworks/cake_1.2.4.8284/app
---------------------------------------------------------------
What is the full path for this app including the app directory name?
Example: /var/www/frameworks/cake_1.2.4.8284/app/myapp
[/var/www/frameworks/cake_1.2.4.8284/app/myapp] > /var/www/frameworks/cake_1.2.4.8284/app/slash0
Bake Project
Skel Directory: /var/www/frameworks/cake_1.2.4.8284/cake/console/libs/templates/skel
Will be copied to: /var/www/frameworks/cake_1.2.4.8284/app/slash0
---------------------------------------------------------------
Look okay? (y/n/q)
[y] > y
Do you want verbose output? (y/n)
[n] > n
---------------------------------------------------------------
Created: slash0 in /var/www/frameworks/cake_1.2.4.8284/app/slash0
---------------------------------------------------------------

Creating file /var/www/frameworks/cake_1.2.4.8284/app/slash0/views/pages/home.ctp
Wrote /var/www/frameworks/cake_1.2.4.8284/app/slash0/views/pages/home.ctp
Welcome page created
Random hash key created for 'Security.salt'
CAKE_CORE_INCLUDE_PATH set to /var/www/frameworks/cake_1.2.4.8284 in webroot/index.php
CAKE_CORE_INCLUDE_PATH set to /var/www/frameworks/cake_1.2.4.8284 in webroot/test.php
Remember to check these value after moving to production server



Change myapp to whatever name you want to have for the app.I put slash0.
At this point the application project is created into the path you specified.

/var/www/frameworks/cake_1.2.4.8284/app/slash0

From now on all you have to do is follow the cakephp book on how to develop :)
See http://book.cakephp.org

Monday, August 17, 2009

ssh-agent(ssh-add) from X under Gnome and CentOS5

Ok you connect to multiple servers and want NOT to type your very secret passphrase every time you
connect to a server.
If you use any type of X window manager is very easy to use a the file

$HOME/.xinitrc in which you have the following

exec ssh-agent

Then after you login into GNOME/KDE etc open a xterm, kterm or any other xterminal and type
ssh-add - you will be prompted to input your secret passphrase.

Be aware that if you don't have any type of keys into your $HOME/.ssh then all the above won't work
because ssh-add needs to have some keys to work with.

In case you need to generate keys is simple:

open a shell

$ssh-keygen -t rsa -b 1024 -- will make you a rsa key 1024 bits
$ssh-keygen -t dsa -b 1024 -- will make you a dsa key 1024 bits

Friday, August 14, 2009

Small size powerful editor for Windows - Notepad++

If you are looking for a powerful editor for windows that understands a large number of
programming languages - Notepad++ -
is very good.

I use it mainly for php but has support for so much more.

Thursday, August 13, 2009

My .vimrc file for vim text editor

I tried a few big names editors but I tell you what for *nix console is nothing else like vi (new vi called vim) ... ok I admit perhaps emacs-nox but I don't use it.

In order to get a little from a lot of options of vim I'll show you my .vimrc file

set softtabstop=2
set shiftwidth=2
set expandtab
set cindent
set smartindent
set autoindent
syntax enable

This enables the indentation and puts spaces instead of tab characters into the file.

For more info see - the following

https://github.com/dioda11/dotfiles

Common tasks with OpenVZ

You just want to skip all the reading about OpenVZ and start using it ?!
This is just for you.
It will install the openvz kernel and utilities and have a container ready.
Feel free to execute all or just a few commands.

### 
# info http://wiki.openvz.org/Quick_installation
# install script

cd /etc/yum.repos.d
wget http://download.openvz.org/openvz.repo
rpm --import  http://download.openvz.org/RPM-GPG-Key-OpenVZ
yum -y install ovzkernel

# edit grub.conf if you want to change labels etc

reboot

yum install vzctl vzquota
/sbin/service vz start


### 
# info http://wiki.openvz.org/OS_template_cache_preparation
# os templates

# to make templates
# utilities
yum install vzpkg vzyum vzrpm43-python vzrpm44-python vzctl-lib

# metadata
yum search vztmpl

# create cache
vzpkgcache centos-4-i386-minimal



# Precreated template cache 
# YOU NEED TO DO THIS - there are many templates
# download from http://wiki.openvz.org/Download/template/precreated


#  Create and start a container 
# To create and start a container, run the following commands:
# 
# [host-node]# vzctl create CTID --ostemplate osname
# [host-node]# vzctl set CTID --ipadd a.b.c.d --save
# [host-node]# vzctl set CTID --nameserver a.b.c.d --save
# [host-node]# vzctl start CTID
# 

###########
vzctl create 1 --ostemplate centos-5-x86
vzctl set 1 --ipadd 10.0.51.254 --save
vzctl set  1 --nameserver 192.168.1.20 --save
vzctl start 1


# Here CTID is the numeric ID for the container; osname is the name of the OS template for the container, and a.b.c.d is the IP address to be assigned to the container.
# Your freshly-created container should be up and running now; you can see its processes:
# 
[host-node]# vzctl exec CTID ps ax
# 
# Enter to and exit from the container
# 
# To enter container give the following command:
# 
[host-node]# vzctl enter CTID
# entered into container CTID
# [container]#
# 
# To exit from container, just type exit and press Enter:
# 
[container]# exit
# exited from container VEID
# [host-node]#
# 
# Stop and destroy the container
# 
# To stop container:
# 
[host-node]# vzctl stop CTID
# Stopping container ...
# Container was stopped
# Container is unmounted
# 
# And to destroy container:
# 
[host-node]# vzctl destroy CTID
# Destroying container private area: /vz/private/CTID
# Container private area was destroyed
#