Looking into the zend framework I noticed their coding standards at
http://framework.zend.com/manual/en/coding-standard.php-file-formatting.html#coding-standard.php-file-formatting.max-line-length
Far as I'm concern looks very good to me (except perhaps the auto loading as this can be done in different ways).
The autoload function can be then done like this:
function __autoload($class)
{
$file = str_replace('_','/',substr($class,2)).'.php';
require_once(FR_BASE_PATH.'/includes/'.$file);
}
or like where you can change the $parts and $path with more options
function __autoload($class)
{
$parts = explode('_', $class);
$path = implode(DIRECTORY_SEPARATOR, $parts);
require_once (DIRECTORY_SEPARATOR . $path . '.php');
}
Wednesday, April 14, 2010
Monday, March 8, 2010
NFS server setup (getport(nfs): request from unauthorized host| dump(): request from unauthorized host ) RedHat EL
I tried to make a simple nfs server on a redhat el 5.4 that uses /etc/hosts.allow and /etc/hosts.deny
I have the following nfs setup:
server
into /etc/hosts
10.0.0.2 client
10.0.0.1 server
into /etc/exports
/home/nfs-server client(rw,no_root_squash)
into /etc/hosts.deny
# wildcard that denies all
ALL:ALL
into /etc/hosts.allow
mountd: 10.0.0.2
statd: 10.0.0.2
portmap: 10.0.0.2
rquotad: 10.0.0.2
I start the portmap (service portmap start) on both machines and try to mount the server from client ... by my surprise there is no luck && try to do a rpcinfo -p - it failed with - No remote programs registered
Looking into the server logs I can see
portmap[3058]: connect from x.x.x.x to getport(nfs): request from unauthorized host
portmap[3061]: connect from x.x.x.x to dump(): request from unauthorized host
Doing different searches on the subject I came accross a bug redhat has on their site
https://bugzilla.redhat.com/show_bug.cgi?id=465412
So ... the solution seems to be the following - you need to add the ip address of the client AND the client host name into /etc/hosts.allow - even though portmap has the tcp_wrappers / libwrap compiled static and doesn't read directly the files /etc/hosts.allow|deny.
This is what I added on the server /etc/hosts.allow
mountd: client
statd: client
portmap: client
rquotad: client
After this - happy NFS.
I have the following nfs setup:
server
into /etc/hosts
10.0.0.2 client
10.0.0.1 server
into /etc/exports
/home/nfs-server client(rw,no_root_squash)
into /etc/hosts.deny
# wildcard that denies all
ALL:ALL
into /etc/hosts.allow
mountd: 10.0.0.2
statd: 10.0.0.2
portmap: 10.0.0.2
rquotad: 10.0.0.2
I start the portmap (service portmap start) on both machines and try to mount the server from client ... by my surprise there is no luck && try to do a rpcinfo -p - it failed with - No remote programs registered
Looking into the server logs I can see
portmap[3058]: connect from x.x.x.x to getport(nfs): request from unauthorized host
portmap[3061]: connect from x.x.x.x to dump(): request from unauthorized host
Doing different searches on the subject I came accross a bug redhat has on their site
https://bugzilla.redhat.com/show_bug.cgi?id=465412
So ... the solution seems to be the following - you need to add the ip address of the client AND the client host name into /etc/hosts.allow - even though portmap has the tcp_wrappers / libwrap compiled static and doesn't read directly the files /etc/hosts.allow|deny.
This is what I added on the server /etc/hosts.allow
mountd: client
statd: client
portmap: client
rquotad: client
After this - happy NFS.
Labels:
linux,
nfs,
sysadmin,
troubleshooting
Disable at runtime selinux
There are times when you need to test something quick and selinux is in your way ... what do you do then ?
Instead of going with a full reboot you can just do the following
echo 0 > /selinux/enforce
This will disable the selinux at runtime. If the system is configured with selinux enabled into his config file
(on redhat/centos /etc/sysconfig/selinux ) next time you reboot it will be enable.
To enable at runtime
echo 1 > /selinux/enforce
Instead of going with a full reboot you can just do the following
echo 0 > /selinux/enforce
This will disable the selinux at runtime. If the system is configured with selinux enabled into his config file
(on redhat/centos /etc/sysconfig/selinux ) next time you reboot it will be enable.
To enable at runtime
echo 1 > /selinux/enforce
Labels:
command line,
linux,
security,
selinux,
sysadmin
Thursday, January 28, 2010
Lvm linux - how to create logical volumes
Steps to have lvm running on your system.
- find a partition or disk that is not used - I have /dev/sda10
- pvcreate /dev/sda10 (creates the physical volume)
- vgcreate VolGroup00 /dev/sda10 (creates a volume group)
- lvcreate -L 40GB -nTempVolume VolGroup00 (create a volume with 40GB with the name TempVolume under the volume group VolGroup00)
- mkfs.ext3 /dev/mapper/VolGroup00-TempVolume (creates the filesystem ext3 type on the TempVolume)
- mkdir /mnt/IMAGE (create a directory to mount the volume)
- mount /dev/mapper/VolGroup00-TempVolume /mnt/IMAGE
- mount (shows /dev/mapper/VolGroup00-TempVolume on /mnt/IMAGE type ext3 (rw))
That's it! You can start using the new mount point.
- find a partition or disk that is not used - I have /dev/sda10
- pvcreate /dev/sda10 (creates the physical volume)
- vgcreate VolGroup00 /dev/sda10 (creates a volume group)
- lvcreate -L 40GB -nTempVolume VolGroup00 (create a volume with 40GB with the name TempVolume under the volume group VolGroup00)
- mkfs.ext3 /dev/mapper/VolGroup00-TempVolume (creates the filesystem ext3 type on the TempVolume)
- mkdir /mnt/IMAGE (create a directory to mount the volume)
- mount /dev/mapper/VolGroup00-TempVolume /mnt/IMAGE
- mount (shows /dev/mapper/VolGroup00-TempVolume on /mnt/IMAGE type ext3 (rw))
That's it! You can start using the new mount point.
Saturday, January 9, 2010
Rsync from linux mirrors without warning
Did you try to rsync and get lots of warnings because it can't change the owner or
the group ? This is caused by the fact that the rsync servers have a user id as owner
that doesn't exists on your system. Same goes for the group.
So if you want to have the verbose -v and no warnings you will need to use the
--no-o meaning no owner
--no-g meaning no group
This tells rsync on your server not to preserve the above
rsync -avz --no-g --no-o rsync://centos.mirror/centos/5/os/i386/ /my/repo
the group ? This is caused by the fact that the rsync servers have a user id as owner
that doesn't exists on your system. Same goes for the group.
So if you want to have the verbose -v and no warnings you will need to use the
--no-o meaning no owner
--no-g meaning no group
This tells rsync on your server not to preserve the above
rsync -avz --no-g --no-o rsync://centos.mirror/centos/5/os/i386/ /my/repo
Labels:
command line,
linux,
rsync
Thursday, October 15, 2009
Wednesday, September 23, 2009
Screen as window manager
In case that you didn't know screen is a window manager and a very useful one however for consoles ...
This is my .screenrc file
hardstatus alwayslastline
hardstatus string '%{= kG}[ %{G}%H %{g}][%= %{=kw}%?%-Lw%?%{r}(%{W}%n*%f%t%?(%u)%?%{r})%{w}%?%+Lw%?%?%= %{g}][%{B}%Y-%m-%d %{W}%c %{g}]'
# Default screens
screen -t shell1 0
screen -t shell2 1
screen -t shell3 2
screen -t shell4 3
To switch between screens type CTRL+a 0 - goes on screen 0 - replace 0 with 1-3 to end up on a different window(screen)
To detach is a simple CTRL+a d - this will put screen into the background and you can reatach with
screen -r or if you have multiple sessions
screen -ls will list the screens that you have running and then
screen -r sessionName
This is my .screenrc file
hardstatus alwayslastline
hardstatus string '%{= kG}[ %{G}%H %{g}][%= %{=kw}%?%-Lw%?%{r}(%{W}%n*%f%t%?(%u)%?%{r})%{w}%?%+Lw%?%?%= %{g}][%{B}%Y-%m-%d %{W}%c %{g}]'
# Default screens
screen -t shell1 0
screen -t shell2 1
screen -t shell3 2
screen -t shell4 3
To switch between screens type CTRL+a 0 - goes on screen 0 - replace 0 with 1-3 to end up on a different window(screen)
To detach is a simple CTRL+a d - this will put screen into the background and you can reatach with
screen -r or if you have multiple sessions
screen -ls will list the screens that you have running and then
screen -r sessionName
Labels:
command line,
linux,
screen
Monday, September 21, 2009
Simple benchmark programs for Linux
In case that you want to test a new server for disk performance you
can do it very quickly with the following tools
bonnie++ from http://www.coker.com.au/bonnie++/
iozone from http://www.iozone.org/
These two will make different tests to your file systems.
Also you can use hdparam (do hdparam --help for all the options)
This is an example from a very old computer with SATA2
# hdparm -t /dev/sda
/dev/sda:
Timing buffered disk reads: 170 MB in 3.03 seconds = 56.06 MB/sec
can do it very quickly with the following tools
bonnie++ from http://www.coker.com.au/bonnie++/
iozone from http://www.iozone.org/
These two will make different tests to your file systems.
Also you can use hdparam (do hdparam --help for all the options)
This is an example from a very old computer with SATA2
# hdparm -t /dev/sda
/dev/sda:
Timing buffered disk reads: 170 MB in 3.03 seconds = 56.06 MB/sec
Thursday, September 17, 2009
Create from scratch a Xen image [Part-1]
This is a mini howto on creating from scratch a xen domU guest system cloning the
hostOS.
What you need:
- have a host os which runs xen in dom0 (you can install a centOS and choose virtualization as profile)
- some disk space (i put 20Gb for the / and 2 for swap)
- run the following two commands to set the volumes
pvcreate /dev/sda7 -- change the /dev/sda7 with whatever you want to
vgcreate VolGroup00 /dev/sda7 -- change the /dev/sda7 with whatever you want to
if unsure what to do look it on on how to create volumes in linux (google it ... )
The following script will create you and image:
hostOS.
What you need:
- have a host os which runs xen in dom0 (you can install a centOS and choose virtualization as profile)
- some disk space (i put 20Gb for the / and 2 for swap)
- run the following two commands to set the volumes
pvcreate /dev/sda7 -- change the /dev/sda7 with whatever you want to
vgcreate VolGroup00 /dev/sda7 -- change the /dev/sda7 with whatever you want to
if unsure what to do look it on on how to create volumes in linux (google it ... )
The following script will create you and image:
#!/bin/sh ########################################## echo $0 "Starting" # echo "This script will clone the guestOS # creating a new xen image" # # # echo "Author: dioda11@gmail.com" # ########################################## if [ $@ ne 1 ]; then echo "please give a numeric identifier for the clone between 10 and 100" exit 1; # if ![ $1 lt 100 ] fi IMGID=$1 BASEDIRMOUNT=/mnt VOLGROUP=VolGroup00 lvcreate -L 20G -n LV_VM$IMGID_RH5.3_ROOT $VOLGROUP lvcreate -L 2G -n LV_VM$IMGID_RH5.3_SWAP $VOLGROUP mkfs.ext3 /dev/$VOLGROUP/LV_VM$IMGID_RH5.3_ROOT mkswap /dev/$VOLGROUP/LV_VM$IMGID_RH5.3_SWAP if [ -d $BASEDIRMOUNT/$IMGID ]; then mount /dev/$VOLGROUP/LV_VM$IMGID_RH5.3_ROOT $BASEDIRMOUNT/$IMGID echo "Mounting the /dev/$VOLGROUP/LV_VM$IMGID_RH5.3_ROOT was " $? else mkdir -p $BASEDIRMOUNT/$IMGID echo "Creating $BASEDIRMOUNT/$IMGID was " $? mount /dev/$VOLGROUP/LV_VM$IMGID_RH5.3_ROOT $BASEDIRMOUNT/$IMGID echo "Mounting the /dev/$VOLGROUP/LV_VM$IMGID_RH5.3_ROOT was " $? fi echo "Cloning the host OS === " ARCH=`uname -m` if [ $ARCH == "x86_64" ]; then cp -ax /{bin,dev,etc,lib,lib64,root,sbin,usr,var} $BASEDIRMOUNT/$IMGID else cp -ax /{bin,dev,etc,lib,root,sbin,usr,var} $BASEDIRMOUNT/$IMGID fi mkdir $BASEDIRMOUNT/$IMGID/{home,proc,opt,sys,tmp} chmod 777 $BASEDIRMOUNT/$IMGID/tmp echo "Cloning finished === " $? echo "At this point you need to fix the /etc/fstab and create the xen config file" # umount $BASEDIRMOUNT/$IMGID ------------------------
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
- 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
Labels:
cakephp,
frameworks,
php,
programming
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
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++
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
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
Labels:
command line,
dotfiles,
linux,
vim
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.
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 #
Thursday, February 7, 2008
Xen install via CFengine on linux CentOS5.0
Objective:
Have a linux host with the xen kernel on CentOS5.0
The hosts OS has 5 machines inside that run CentOS 4.4 with different applications.
Have a linux host with the xen kernel on CentOS5.0
The hosts OS has 5 machines inside that run CentOS 4.4 with different applications.
Labels:
centos,
linux,
virtualization,
xen
Subscribe to:
Posts (Atom)