未分類
Gearman Install OSX
by admin on 十一月.18, 2011, under 未分類
安裝Gearman 在OSX上面
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 | $ sudo -s $ cd /tmp $ wget https://github.com/downloads/libevent/libevent/libevent-2.0.15-stable.tar.gz $ tar zxvf libevent-2.0.15-stable.tar.gz $ cd libevent-2.0.15-stable $ ./configure $ make $ make install $ cd .. $ wget https://launchpad.net/ubuntu/lucid/+source/libdrizzle/0.7-1/+files/libdrizzle_0.7.orig.tar.gz $ tar libdrizzle_0.7.orig.tar.gz $ cd libdrizzle-0.7/ $ ./configure $ make $ make install $ cd .. $ wget http://launchpad.net/gearmand/trunk/0.14/+download/gearmand-0.14.tar.gz $ tar zxvf gearmand-0.14.tar.gz $ cd gearmand-0.14/ $ ./configure $ make $ make install $ cd .. $ wget http://pecl.php.net/get/gearman-0.8.0.tgz $ tar zxvf gearman-0.8.0.tgz $ cd gearman-0.8.0 $ phpize $ ./configure $ make $ sudo make install /bin/sh /tmp/gearman-0.8.0/libtool --mode=install cp ./gearman.la /tmp/gearman-0.8.0/modules cp ./.libs/gearman.so /tmp/gearman-0.8.0/modules/gearman.so cp ./.libs/gearman.lai /tmp/gearman-0.8.0/modules/gearman.la ---------------------------------------------------------------------- Libraries have been installed in: /tmp/gearman-0.8.0/modules If you ever happen to want to link against installed libraries in a given directory, LIBDIR, you must either use libtool, and specify the full pathname of the library, or use the `-LLIBDIR' flag during linking and do at least one of the following: - add LIBDIR to the `DYLD_LIBRARY_PATH' environment variable during execution See any operating system documentation about shared libraries for more information, such as the ld(1) and ld.so(8) manual pages. ---------------------------------------------------------------------- Installing shared extensions: /usr/lib/php/extensions/no-debug-non-zts-20090626/ $ which php /usr/bin/php $ php --info | grep -i configuration (11-17 13:30) Configuration File (php.ini) Path => /etc Loaded Configuration File => /private/etc/php.ini Configuration $ vi /private/etc/php.ini ======= 加入以下資訊 ====== extension_dir = " /usr/lib/php/extensions/no-debug-non-zts-20090626/" <~~這不一定要 extension="gearman.so" ======================== $ php --info | egrep -i "(configuration|gearman)" Configuration File (php.ini) Path => /etc Loaded Configuration File => /private/etc/php.ini Configuration gearman gearman support => enabled libgearman version => 0.14 |

MongoDB VS Mysql 簡單測試.
by admin on 八月.03, 2011, under PHP & MYSQL, 未分類
廢話不多說.
MongoDB 使用 MongoDB Object Document Mapper測試.
Mysql 使用 Object Relational Mapper測試.
MongoDB部分:
config.php
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 | < ?php require_once __DIR__ . '/../../lib/vendor/doctrine-common/lib/Doctrine/Common/ClassLoader.php'; use Doctrine\Common\ClassLoader, Doctrine\Common\Annotations\AnnotationReader, Doctrine\ODM\MongoDB\Configuration, Doctrine\ODM\MongoDB\Mapping\Driver\AnnotationDriver, Doctrine\MongoDB\Connection, Doctrine\ODM\MongoDB\DocumentManager; $classLoader = new ClassLoader('Doctrine\Common', __DIR__ . '/../../lib/vendor/doctrine-common/lib'); $classLoader->register(); $classLoader = new ClassLoader('Doctrine\ODM\MongoDB', __DIR__ . '/../../lib'); $classLoader->register(); $classLoader = new ClassLoader('Doctrine\MongoDB', __DIR__ . '/../../lib/vendor/doctrine-mongodb/lib'); $classLoader->register(); $classLoader = new ClassLoader('Symfony', __DIR__ . '/../../lib/vendor'); $classLoader->register(); $classLoader = new ClassLoader('Documents', __DIR__); $classLoader->register(); $config = new Configuration(); $config->setProxyDir(__DIR__ . '/Proxies'); $config->setProxyNamespace('Proxies'); $config->setHydratorDir(__DIR__ . '/Hydrators'); $config->setHydratorNamespace('Hydrators'); $config->setDefaultDB('doctrine_odm_sandbox'); //使用safe模式 $con = new Connection('localhost',array('safe'=>true, 'w' => 2,'wtimeoutMS' => 2000)); //使用一般模式 //$con = new Connection('localhost'); $reader = new AnnotationReader(); $reader->setDefaultAnnotationNamespace('Doctrine\ODM\MongoDB\Mapping\\'); $config->setMetadataDriverImpl(new AnnotationDriver($reader, __DIR__ . '/Documents')); $dm = DocumentManager::create($con, $config); |
FreeBSD 架設 redmine
by admin on 四月.25, 2011, under 未分類
redmine 安裝:
1.先更新本機的port tree
1 | $ portsnap fetch update |
2.安裝
1 | cd /usr/ports/www/redmine; make install clean |
FreeBSD DenyHosts 擋掉暴力破解 ssh 的使用者
by admin on 三月.05, 2011, under 未分類
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 | # cd /usr/ports/security/denyhosts; make install clean; ------------------------------------------------------------------------------- To run denyhosts from startup, add denyhosts_enable="YES" in your /etc/rc.conf. Configiration options can be found in /usr/local/etc/denyhosts.conf ------------------------------------------------------------------------------- In order to proper working of denyhosts 1. edit your /etc/hosts.allow file and add: sshd : /etc/hosts.deniedssh : deny sshd : ALL : allow 2. issue the following command if /etc/hosts.deniedssh does not exist yet touch /etc/hosts.deniedssh ------------------------------------------------------------------------------- Warning: syslogd should ideally be run with the -c option; this will ensure that denyhosts notices multiple repeated login attempts. To do this, add syslogd_flags="-c" to /etc/rc.conf ------------------------------------------------------------------------------- ===> Installing rc.d startup script(s) ===> Registering installation for denyhosts-2.6_3 ===> Cleaning for denyhosts-2.6_3 # |
VirtualBox-OSE on FrreeBSD 免x11
by admin on 十二月.29, 2010, under FreeBSD, 未分類
參考 http://d.hatena.ne.jp/wittro/20100617/1276782079
cd /usr/src make build32 install32; ldconfig -v -m -R /usr/lib32 cd /usr/ports/emulators/virtualbox-ose make install clean ============================================================================= VirtualBox was installed. You need to load the vboxdrv kernel module via /boot/loader.conf: vboxdrv_load="YES" For bridged networking please add the following line to your /etc/rc.conf: vboxnet_enable="YES" Reboot the machine to load the needed kernel modules. You also have to add all users to your vboxusers group in order to use vbox. % pw groupmod vboxusers -m jerry Running VirtualBox as non-root user may fail with a fatal error NS_ERROR_FACTORY_NOT_REGISTERED. In this case delete /tmp/.vbox-*-ipc file. Check wiki page for known issues and troubleshooting: http://wiki.freebsd.org/VirtualBox Please report any problems to emulation@. Thanks! =============================================================================
弄個shell-script 來產生 虛擬機器設定
#!/bin/csh -f
set vm=winxp
set mem=1024
set cpu=1
#HD
set size=10000
#set dvdiso=`pwd`/windows7.iso
set dvdiso=/raid5/virtualbox/windowsXPSP3r.iso
# /root/.VirtualBox/Machines/
VBoxManage createvm -name $vm -register
VBoxManage modifyvm $vm --memory $mem --cpus $cpu --vram 32
VBoxManage modifyvm $vm --acpi on --ioapic on
VBoxManage modifyvm $vm --nic1 bridged --bridgeadapter1 bge0
VBoxManage modifyvm $vm --nictype1 82540EM
VBoxManage modifyvm $vm --vrdp on --cableconnected1 on --boot1 dvd
VBoxManage createvdi --filename ${vm}.vdi --size $size --format VDI --variant Standard
VBoxManage storagectl $vm --name ide --add ide --controller PIIX4
VBoxManage storageattach $vm --storagectl ide --port 0 --device 0 --type hdd --medium ${vm}.vdi
VBoxManage storageattach $vm --storagectl ide --port 1 --device 0 --type dvddrive --medium $dvdiso
#VBoxVRDP --startvm $vm
#VBoxManage storageattach $vm --storagectl ide --port 1 --device 0 --type dvddrive --medium /usr/local/lib/virtualbox/additions/VBoxGuestAdditions.iso
#VBoxVRDP --startvm $vm執行 5900 vnc的port vnc的密碼123456
VBoxHeadless -n -m 5900 -o 123456 -s winxp -w 1024 -h 768
很方便 還可搞個私人雲端XDDD (其實只是lab)
效能上比之前用QEMU好上太多太多~~
2011-02-14補充:
在安裝virtualbox-ose的時候一定要選上WEBSERVICE選項,後面安裝的phpvirtualbox的時候需要用到。
啟動vboxwebsrv
$ vboxwebsrv
安裝phpvirtualbox
$ cd /usr/ports/www/phpvirtualbox && make install clean
$ VBoxManage setproperty websrvauthlibrary null
然後在Nginx或Apache中配置站點,目錄指向/usr/local/www/phpvirtualbox目錄
在瀏覽器中輸入http://localhost/phpvirtualbox就可以開始安裝配置Virtualbox了。
Clone VM export
1 2 3 | $ VBoxManage export winxp -o winxp.ovf (08-02 08:10) 0%...10%...20%...30%...40%...50%...60%...70%...80%...90%...100% Successfully exported 1 machine(s). |
1 | $ VBoxManage import winxp.ovf --vsys 0 --vmname winxp2 |
PHPUnit
by admin on 十二月.13, 2010, under 未分類
PHPUnit 介紹
PHPUnit 其實是個 PHP 寫成的 Framework , 主要功能就是自動對我們所寫的PHP程式做輸入輸出的檢查
一個方便的工具來幫我們自動測試 , 而 PHPUnit 就可以讓我們自行撰寫測試的條件 , 當我們所寫的測試條件隨著時間累積的越多時 , 就可以避免一定程度的錯誤發生了
安裝 PHPUnit
可以參考 : http://www.phpunit.de/manual/3.6/en/installation.html
pear channel-discover pear.phpunit.de pear channel-discover components.ez.no pear channel-discover pear.symfony-project.com pear install phpunit/PHPUnit
範例:
<?php class StackTest extends PHPUnit_Framework_TestCase { public function testPushAndPop() { $stack = array(); $this->assertEquals(0, count($stack)); array_push($stack, 'foo'); $this->assertEquals('foo', $stack[count($stack)-1]); $this->assertEquals(1, count($stack)); $this->assertEquals('foo', array_pop($stack)); $this->assertEquals(0, count($stack)); } } ?>
範例與執行:
<?php class StackTest extends PHPUnit_Framework_TestCase { public function testEmpty() { $stack = array(); $this->assertEmpty($stack); return $stack; } /** * @depends testEmpty */ public function testPush(array $stack) { array_push($stack, 'foo'); $this->assertEquals('foo', $stack[count($stack)-1]); $this->assertNotEmpty($stack); return $stack; } /** * @depends testPush */ public function testPop(array $stack) { $this->assertEquals('foo', array_pop($stack)); $this->assertEmpty($stack); } } ?> <pre lang="txt"> phpunit --verbose DependencyFailureTest PHPUnit 3.6.0 by Sebastian Bergmann. DependencyFailureTest FS Time: 0 seconds There was 1 failure: 1) testOne(DependencyFailureTest) Failed asserting that <boolean:false> is true. /home/sb/DependencyFailureTest.php:6 There was 1 skipped test: 1) testTwo(DependencyFailureTest) This test depends on "DependencyFailureTest::testOne" to pass. FAILURES! Tests: 2, Assertions: 1, Failures: 1, Skipped: 1.