Skip to main content

Posts

Showing posts from 2010

CakePHP - Update fields with conditions

Kita boleh update field database berdasarkan conditions seperti berikut : $this->Model->updateAll(             array('Model.backup'=>'1'),             array('Model.name'=>$a)             );         $this->redirect(array('controller'=>'Controller', 'action'=>'Action'));

Nginx PhpMyAdmin PHP - Cannot Start Session Without Errors

PhpMyAdmin should work properly with normal PHP installation with Nginx as the web server. Unfortunately there's an error regarding session error. Default PHP installation will configure the session path owner to Apache. This isn't right for the nginx and to store the session. More investigation from the php.ini will show you the path for the session. Take a note : session.save_path = "/var/lib/php/session" Solutions : 1) Change the owner for the /var/lib/php/session From : bash# ls -l /var/lib/php total 4 drwxrwx--- 2 root apache 4096 Nov 13  2009 session To : # ls -l /var/lib/php total 4 drwxrwx--- 2 root www-data 4096 Nov 18 03:18 session Finally restart your Nginx and try to browse your phpmyadmin. This should work for now :) Yatta~

CentOS 5.5 - PHP 5.1.x to PHP 5.2.x

Secara default CentOS akan membekalkan versi PHP yang stable iaitu PHP 5.1 didalam repos. Tetapi ada beberapa aplikasi web contohnya PhpMyAdmin yang memerlukan versi PHP yang terkini. Untuk itu kita kena edit di bahagian yum repos untuk memasukkan PHP terkini dari repos testing. Sebelum  bash#php -v PHP 5.1.6 (cli) (built: Mar 31 2010 02:39:17) Copyright (c) 1997-2006 The PHP Group Zend Engine v2.1.0, Copyright (c) 1998-2006 Zend Technologies 1. Edit /etc/yum.repos.d/CentOS-Testing.repo  Masukkan code dibawah dalam file tersebut. # CentOS-Testing: # !!!! CAUTION !!!! # This repository is a proving grounds for packages on their way to CentOSPlus and CentOS Extras. # They may or may not replace core CentOS packages, and are not guaranteed to function properly. # These packages build and install, but are waiting for feedback from testers as to # functionality and stability. Packages in this repository will come and go during the # development period, so it should not be left en

Rumah Pertama

Assalamualaikum, Seminggu yang lepas aku dan isteri usha-usha rumah baru kitaorg. Yang pasti rumah dekat melaka :). Well, ini adalah pengalaman pertama kitaorg beli rumah sendiri. Memang rasa janggal dan tak reti juga, tapi kena belajar macam mana nak deal dengan pemaju. Antara taman yang menjadi idaman aku dan isteri ialah Taman Tun Kudu dekat area Bukit Katil, Melaka. Kawasan ni kira ok juga, dekat dengan bandar Melaka, Masjid, klinik, sekolah dan kawasan kedai-kedai. Kitaorg pon memang sangat-sangat berkenan area rumah tu. Yang penting sekali senang nak ke tempat kerja hehe.. Jumaat lepas aku dan wife pergi ke pejabat pemaju tu dekat Melaka Raya. Antara yang kitaorg bincang : - Harga rumah - Pinjaman (full loan / 10% deposit ) - Hak milik kekal - Free gift ada ke tak :P Itu antara yang kitaorg bincang setakat tu, 2 hari lepas tu kitaorg terus booking rumah tu sebab memang dah berkenan sangat! yatta~

Selamat Hari Raya | Maaf Zahir Batin

Dikesempatan ini aku sekeluarga ingin mengucapkan Selamat Hari Raya buat pengunjung maya blog aku dah juga rakan-rakan yang sempat membaca entri ini. Setelah kita berpuasa sebulan kini tiba masanya untuk hari kemenangan perjuangan dan pengorbanan kita kepada Allah. Semoga ibadah yang kita lakukan pada bulan Ramadhan diterima oleh Allah, Insyallah. Tidak lupa kepada ibu bapa di Muar dan juga mertua di Melaka, Selamat Hari Raya Maaf Zahir Batin :) p/s:pada yang pulang ke kampung, diharap berhati-hati di jalan raya dan pandu dengan cermat :)

Ajaxterm-0.10 patch for Firefox 3.6

Last night just got an idea for my project to use ajaxenterm for my vps web console and other things that need to be done for. When I testing to use the ajaxenterm, everything is fine for Chrome except Firefox 3.6 that doesn't show the terminal box (I don't have IE to test on this issue :P ) Searching around I found interesting discussion and thanks to open source and the person that made the patch for this issue ( https://bugs.launchpad.net/silva/+bug/512236 ) Download the patch and patch the file immediately :) bash> patch -p1 sarissa.js.patch

Ubuntu - Restore toolbar

If you've messing up the toolbar and want to restore to the default setting you can do like this : bash> rm -rf ~/.gnonf/apps/panel bash> killall gnome-panel the toolbar will restore to the default value and you can configure it back :)

Ubuntu - Enable mod_rewrite

Enabling mod_rewrite for cakephp 1.3 in 3 easy steps : 1) Enable the module bash>sudo a2enmode rewrite 2) Make a soft link bash>sudo ln -s /etc/apache2/mods-available/rewrite.load /etc/apache2/mods-enabled/ 3) Restart the apache server bash> sudo /etc/init.d/apache2 restart p/s:Check in your phpinfo() if mod_rewrite is enable :)

Python - How to check active domain

This is python and libvirt related post, beware!! Ok now I want to check from my script, let's say : bash> xencheck.py nameofvps So I want the script to check if the vps name is available and active. This is what I done : #!/usr/bin/python -u import libvirt import sys import os def Startup():  if not os.access("/proc/xen", os.R_OK):     print "System is not running Xen kernel!"     sys.exit(1) #connect to hypervisor conn = libvirt.open("xen:///default") if conn == None:     print 'Failed to connect to hypervisor'     sys.exit(1) dom0 = conn.listDomainsID() for id in dom0:  dom1 = conn.lookupByID(id)  if dom1.name() == sys.argv[1]:   print dom1.name() #main function to execute def main():  Startup() if __name__ == "__main__":  main()

Installing Nginx on FreeBSD 8.0

Nginx (engine-X) is a light and fast web server to serve a static & dynamic web content. It has many features that can be enable from the modules. Witha lower memory consumption, it is the choice for a busy web server. Nginx can be configured to replace the popular Apache web server next time :) we are going to install Nginx with a basic configuration on FreeBSD 8.0. 1) Update your ports shell> cvsup -g -L 2 ports-supfile 2) Install from ports shell> cd /usr/ports/www/nginx shell> make configure shell> make install distclean Make sure you install modules that you required to use. 3) Enable at boot shell> nano /etc/rc.conf add : nginx_enable="YES" To start the nginx simply run this command : shell> /usr/local/etc/rc.d/nginx start Configuration file : /usr/local/etc/nginx/nginx.conf Log file : /var/log/nginx-error.log /var/log/nginx-access.log Document root : /usr/local/www/nginx yatta~

PAM SSH Failed

The problem occur today when I'm installing ShellinaBox for our project purporse. As you can see it said that tty 'pts/2' is not secure. so what to do? May 20 19:41:35 localhost login: pam_securetty(remote:auth): access denied: tty 'pts/2' is not secure ! May 20 19:41:39 localhost login: FAILED LOGIN 1 FROM 192.168.1.110 FOR root, Authentication failure 1) Edit your /etc/securetty default: console vc/1 vc/2 vc/3 vc/4 vc/5 vc/6 vc/7 vc/8 vc/9 vc/10 vc/11 tty1 tty2 tty3 tty4 tty5 tty6 tty7 tty8 tty9 tty10 tty11 2) Just add the pts/2 in the list console vc/1 vc/2 vc/3 vc/4 vc/5 vc/6 vc/7 vc/8 vc/9 vc/10 vc/11 tty1 tty2 tty3 tty4 tty5 tty6 tty7 tty8 tty9 tty10 tty11 pts/2 Run back the ShellinaBox, and you are good to go.. yatta~~

Install Django on Ubuntu

If you are geek then this post is not for your level.. :) 1)Download django 2)Extract and install shell> tar xzvf Django-1.1.1.tar.gz shell> mv Django-1.1.1 django shell> cd django shell> sudo python setup.py install Then test on your console : django$ python Python 2.6.4 (r264:75706, Dec  7 2009, 18:45:15) [GCC 4.4.1] on linux2 Type "help", "copyright", "credits" or "license" for more information. >>> import django >>> If no error, then you are good to go! yatta~

MySQL Enterprise thingy

It's been a weird thing when you install MySQL server especially the one that is 'enterprise' version is not working with your PHP. That is the problem that my friend and I facing today. Since PHP require php-mysql extension to connect to MySQL server but php-mysql is only work with mysql-server from the Repos (Redhat/Centos). 1) Remove default mysql-server/php-mysql 2) Install MySQL Enterprise 3) Dependencies conflict occur + headache + install php-mysql shell> yum install php-mysql Loaded plugins: rhnplugin, security Setting up Install Process Resolving Dependencies --> Running transaction check ---> Package php-mysql.x86_64 0:5.1.6-27.el5 set to be updated --> Processing Dependency: libmysqlclient.so.15(libmysqlclient_15)(64bit) for package: php-mysql --> Processing Dependency: libmysqlclient.so.15()(64bit) for package: php-mysql --> Running transaction check ---> Package mysql.x86_64 0:5.0.77-4.el5_4.2 set to be updated --> Process

Python - Xen and libvirt

more function can be found in python dir libvirtclass.txt shell> find / -name libvirtclass.txt Generated Classes for libvir-python # # Global functions of the module # # functions from module libvirt open() openReadOnly() virEventRegisterImpl() virInitialize() # functions from module virterror virGetLastError() virResetLastError() # # Set of classes of the module # Class virDomain()     # functions from module libvirt     ID()     OSType()     XMLDesc()     attachDevice()     blockPeek()     connect()     coreDump()     create()     destroy()     detachDevice()     maxMemory()     maxVcpus()     memoryPeek() migrate()     name()     reboot()     ref()     resume()     save()     setAutostart()     setMaxMemory()     setMemory()     setVcpus()     shutdown()     suspend()     undefine()     # functions from module python     UUID()     UUIDString()     autostart()     blockStats()     info()     interfaceStats()     pinVc

Python - Xen and libvirt

basic python script with libvirt #!/usr/bin/python -u import libvirt import sys import os if not os.access("/proc/xen", os.R_OK):     print 'System is not running a Xen kernel'     sys.exit(1) conn = libvirt.openReadOnly(None) if conn == None:     print 'Failed to open connection to the hypervisor'     sys.exit(1) # print conn for id in conn.listDomainsID():        dom0 = conn.lookupByID(id)     print "Dom %s State %s" % ( dom0.name(), dom0.info()[0]) Some example : python# ./script1.py Please choose : 1) Show VPS 2) test 2 1 Domain Domain-0 ID 0 State 1 OS linux (Active Domain) Domain zenvps2 ID 3 State 2 OS linux (Active Domain) Domain zenvps ID 4 State 2 OS linux (Active Domain)

Centos x86_64 subversion conflict

We are on testing stage for our new x86_64 Centos OS, where we currently fixing the 32GB RAM problem.. so after finish the installation, we try to update the OS and there's some error complaining about subversion. As googling around I found that on this 64bit OS it's include also with 32bit package, so that is why some conflict occur. file /usr/share/xemacs/site-packages/lisp/psvn.el from install of subversion-1.5.5-0.1.el5.rf conflicts with file from package subversion-1.4.2-2.el5   Solutions : 1) we have to remove the subversion.i386 2) update the x86_64 subversion   shell> yum erase subversion.i386 shell> yum update subversion yattta!~

Red Hat License

Today our task is to install and configure the OpenLDAP in one of our Red Hat server at our client data centre. We thought they already order the license for the Red Hat installation, but sad to say,they just bought only 1 license, which they believe 1 license can be install and used with other Red Hat server. 1 server license is almost RM6,000 or more with premium support. Wonder how much you need to spend for 14 servers in the data center ? :)

fsck headache

today I got a call from one of my client that they cannot access to the internet and told me that the gateway got some problem. Since the error makes the server inaccessible from the net, then I might got to the site to fix it. Further checking found that there's some power cut few days before and the server is not properly shutdown. SOFT UPDATE INCONSISTENCY The error prompted will give you 1 choice to enter to single mode and fix the problem. Either you reboot or fscking :) How to fix it? shell> fsck -y * -y will answer yes for all of the question given.

Warning Nuffnanger's!

Dear Nuffnangers, As you might already know, there are 2 different types of campaigns from Nuffnang: Metered (mCPM) Campaigns , which pay according to the number of visitors who see the ads; and Cost-Per-Click (CPC) campaigns, which pay bloggers based on the number of clicks generated on the ads. It has come to our attention that certain groups have been committing click fraud, which is defined as clicking on CPC advertisements intentionally just to generate earnings for a blog's owner. Do note that this act is an abuse of our Terms & Conditions under Section 6. Banner ads are only supposed to be clicked on if the viewer is interested to find out more about the advertising campaign, and not for the intention of earning extra money. Should this situation worsen, the frequency of ad campaigns might be significantly reduced as we'll only be able to sell ad spaces on blogs with no click fraud record. Our system is capable of tracking these illegal actions

Windows 2003 - Failed to copy, folder or file name is too long

Although this blog is about FreeBSD, but at my office we still maintain 2 server that installed with Windows Server 2003 which I believe it is outdated for now.. but the management still want to use it.. Couple years back, so of the staff created an index file, something like this : 1.0 data1 2.0 data2/2.1 data2_1/2.1.1 Data2 time date.xls This is a big problem when you tried to copied the entire folder to other folder (external hard disk). So I googling around the net and found this useful tools that can do the copied job using the command line Windows Server 2003 Resource Kit Tools   so what we can do to solve this problem is to open your cmd, and check if ROBOCOPY is installed in your batch. C:/ROBOCOPY /? Copy tools : C:/ROBOCOPY [SOURCE] [DESTINATION] Example : C:/ROBOCOPY "H:/YOUR FILE" "I:/YOUR 2ND FOLDER" /S Note : /S is to create subfolder  Yatttaaa~

FreeBSD - Custom Kernel

Our previous FreeBSD installation may lack of options like ALTQ for PF (Packet Filter) . So we have to compile our kernel to a new kernel with some option enable. Prepare yourself.. • Make sure you are on i386 architecture machine • Copy the original GENERIC kernel to a new one. • Bare in mind, you are not allowed to make any changes to the original kernel. Since we will use that for our 'work in hand' kernel if anything goes wrong. shell>cd /usr/src/sys/i386/conf shell>cp GENERIC MYKERNEL • Edit MYKERNEL using your prefered editor. Mine prefer nano :) shell>nano MYKERNEL • For this tutorial we will enable ALTQ for PF #options for pf (packet filter) ALTQ options ALTQ options ALTQ_CBQ options ALTQ_RED options ALTQ_RIO options ALTQ_HFSC options ALTQ_PRIQ options ALTQ_NOPCC #pf (packet filter) device pf device pflog device pfsync • Save and let's build them

BSDMag - Online Issue

New issue already out to download .

FreeBSD - SSHGuard

http://www.sshguard.net/ SSHGuard adalah salah satu tools yang ada di ports untuk melindungi ssh servis anda dari diserang secara bruteforce. Ia menggunakan sistem log dari syslog untuk mengesan IP yang gagal untuk login ke server. - Install dari ports proxy# /usr/ports/security/sshguard-pf proxy# make install clean - Konfigurasi PF shell> nano /etc/pf.conf #di bahagian table table " " persist #sila buang "", <> tak boleh :P #bahagian block rules block in quick on $ext_if proto tcp from to any port 22 label "ssh bruteforce" - Aktifkan rules pf yang baru shell> pfctl -ef /etc/pf.conf - Edit /etc/syslog.conf uncomment line yang berkenaan sshguard proxy# nano /etc/syslog.conf GNU nano 2.0.9 File: /etc/syslog.conf # $FreeBSD: src/etc/syslog.conf,v 1.28.20.1 2009/04/15 03:14:26 kensmith Exp $ # # Spaces ARE valid field separators in this file. However,

FreeBSD - DHCP Server

DHCP - adalah singkatan kepada "Dynamic Host Configuration Protocol". Servis ini adalah untuk memberikan IP kepada client di network kita. Dengan adanya servis DHCP ini, kita tidak perlulah menggunakan cara manual untuk menetapkan IP di setiap komputer yang terdapat di network kita. Bahan : - isc-dhcp30-server - Editor (nano,vi,vim,ee) - Secawan kopi Cara-Cara : - Install servis dhcp server seperti dibawah : shell> cd /usr/ports/net/isc-dhcp30-server shell> make config (disable chroot) shell> make install clean - Contoh file konfigurasi dhcpd.conf shell> ee /usr/local/etc/dhcpd.conf # dhcpd.conf # # Sample configuration file for ISC dhcpd # # option definitions common to all supported networks... # set kan domain,DNS server option domain-name "gateway.domain.local"; option domain-name-servers 192.168.2.1; option subnet-mask 255.255.255.0; default-lease-time 600; max-lease-time 7200; # If this DHCP server is

FAMPP - Installing PhpMyAdmin

Now we have already install apache,mysql and also PHP in our box.. so what next? I myself feel hard to manage my database using CLI :P and the solutions is using PhpMyAdmin lets begin.. as root #cd /usr/ports/databases/phpmy admin #make config #make install clean Once done the compiling session it will install to /usr/local/www/PhpMyAdmin next we have to configure the config.inc.php to make phpmyadmin can talk with mysql #cd /usr/local/www/phpmyadmin #cp config.sample.inc.php config.inc.php Now we will edit the file #ee config.inc.php /* set your secret password */ $cfg['blowfish_secret'] = 'password'; /* uncomment the following line and put your mysql login */ $cfg['Servers'][$i]['controluser'] = 'root'; $cfg['Servers'][$i]['controlpass'] = 'password'; Save! Then we have to configure httpd.conf to treat phpmyadmin as one of the aliases #ee /usr/local/etc/apache22/httpd.conf

FAMPP - Installing PHP 5

this time we will build from source and compile :) #cd /usr/ports/lang/php5 #make config *choose apache module *choose mysql module and others that suite for you #make install clean Now we will install other common module for web server such as : mysql database #cd /usr/ports/databases/php5- mysql #make install clean once done a message will appear : The following line has been added to your /usr/local/etc/php/extensions.ini configuration file to automatically load the installed extension: extension=mysql.so This will enable PHP to interact with mysql database Session #cd /usr/ports/www/php5-session #make install clean once done a message will appear : The following line has been added to your /usr/local/etc/php/extensions.ini configuration file to automatically load the installed extension: extension=session.so Graphic library #cd /usr/ports/graphics/php5-gd Once done a message will appear : The following line has been added to

FAMPP - Installing MySQL Server

simpler command :) #pkg_add -r mysql51-server from this command it will install mysql server and also mysql client for the server once done we can enable it on boot up by editing rc.conf #ee /etc/rc.conf add this following line mysql_enable="YES" After that we can start the service by this command : #sh /usr/local/etc/rc.d/mysql- server.sh start Then we have to configure our root login for mysql which is by default it is blank. By using a password for the root login it will be more safe to outsider :) #mysql -u root #SET PASSWORD FOR 'root'@'localhost' = PASSWORD('urpasswordhere'); once done try to login using root user #mysql -u root -p Enter password: If that appear then you have successfully configuring your mysql server :)

FAMPP - FreeBSD, Apache, MySQL, PHP, PhpMyAdmin

FAMPP adalah idea daripada (FreeBSD,Apache,MySQL,PHP,PhpMyAdmin) , Tutorial ini akan membangunkan basic web server bersama-sama FreeBSD 7.2 FreeBSD 7.2 : Install Apache2.2 Ada dua cara untuk install aplikasi di FreeBSD - ports - pre-compiled pakej kali ini kita akan gunakan cara yang mudah iaitu menggunakan pre-compiled pakej #pkg_add -r apache22 edit /etc/rc.conf to start apache at boot apache22_enable="YES" Reboot and try to start. #apachectl -k start if got error something like this : Syntax error on line 151 of /usr/local/etc/apache22/ht tpd.conf: DocumentRoot must be a directory Edit your httpd.conf and make sure your folder "data" is created in /usr/local/www/apache22/ Try to start again, #apachectl -k start if got warning something like this : [Mon Jan 01 08:31:17 2007] [warn] (2)No such file or directory: Failed to enable the 'httpready' Accept Filter It is because some module are not loaded for filtering the pack

Radix Fried Chicken

 (Credit to www.radixfriedchicken.com.my) Hari ini setelah mengidam nak makan RFC (Radix Fried Chicken) di MyDin MITC Melaka, akhirnya tercapai jua bersama tunang :). Walaupun berkunjung pada waktu selepas kerja namun masih dapat menikmati kesedapan RFC ni. Pada sapa yang tak tahu apa tu RFC, RFC ialah singkatan daripada ayat Radix Fried Chicken. Ia adalah salah satu produk keluaran HPA . Menu yang diorder ialah - Spicy burger - Radix Delight A Yang nak usha harga sebelum beli tu boleh tengok di web rasmi RFC Komen : - 1st entry dalam market fast food boleh dikatakan berjaya. - Harga yang tidak terlalu mahal. - Menu yang pelbagai, terutama ada pilihan untuk kanak2 (ala2 McD dan KFC) - Pekerja yang sopan, dan mesra pelanggan. - 4 bintang untuk RFC!!

Modul OpenOffice Bahasa Melayu

Hari ini salah sorang rakan aku encik Psychox telah menyiapkan modul ringkas untuk aplikasi OpenOffice. Pada sapa yang tak tahu pasal OpenOffice ni boleh rujuk sini  . Dengan kata mudah OpenOffice (OOo) adalah mirip kepada aplikasi M$ Office yang biasa kita guna. Cuma bezanya aplikasi OOo ni adalah percuma dan opensource. Yang paling penting OOo versi 3 adalah compatible kalau kita ingin buka file dari format XP,2003,2007 dan seangkatan dengannya. Tak perlu install compatibility pack :) Boleh download modul OOo di sini

FreeBSD 7.2-RELEASE EOF

I just 'freebsd-update' on one of my firewall, and got this message FreeBSD 7.2-RELEASE-p4 is approaching its End-of-Life date. It is strongly recommended that you upgrade to a newer release within the next 2 month  and as per security.freebsd.org The new 7.3-RELEASE is still on RC-ing and when the release come out, for a better system we should upgrade to the new one :)

FreeBSD stability

Recently I just configured our office PC which is Pentium III with 667Mhz speed. Can it be install with Windows XP or Windows 7 maybe ? :) I installed with a FreeBSD 7.2 and updated to 7.2-p6 to become one of our greatest firewall (hope so) and running for about : $ uname -a;uptime;date FreeBSD firewall.sm.local 7.2-RELEASE-p6 FreeBSD 7.2-RELEASE-p6 #2: Tue Jan 26 08:46:49 MYT 2010     root@firewall.sm.local:/usr/obj/usr/src/sys/SMKERNEL  i386  2:58AM  up 33 days, 16:26, 1 user, load averages: 0.00, 0.00, 0.00 Fri Mar  5 02:58:02 MYT 2010 without any failure and need to be restart. For now the box act as our firewall and also our NAT for about 50 people in our office. Before this we are using Dir-300 which i don't it can perform well and customized with what I need to protect my network. my future needs is to install Ntop for network monitoring..

Sendmail problem

I got my Jails running 3 web server with sendmail enable. This is to enable my web server to send an email using the PHP mail() function. After a while the server is in testing period, I encounter a slowness when trying to post/insert into the database(that's also one of the jail). Further investigation, I found that in my web server log (/var/log/messages) with the following warning (even the sendmail is still functioning) : Jan 13 16:25:44 httpd-2-server sendmail[46097]: unable to qualify my own domain name (httpd-2-server) -- using short name Jan 13 16:25:49 httpd-2-server sm-mta[46118]: o0DGPi16046116: SYSERR(root): hash map "Alias0": missing map file /etc/mail/aliases.db: No such file or directory For the "unable to qualify my own domain name (httpd-2-server) -- using short name", I resolve through setting up the /etc/hosts with something like this : ::1 localhost httpd-2-server.local 127.0.0.1 localhost httpd-2-se