Archive for the ‘Technical’ Category

Install PHPUnit on OpenSuse12.1

December 5th, 2011 | admin

First of all,

$pear channel-discover pear.symfony-project.com
$pear channel-discover components.ez.no
$pear upgrade --force PEAR

Then,

$sudo pear install --alldeps phpunit/PHPUnit

If you can not find phpunit, remember to add phpunit channel to your pear path, like

$sudo zypper install php5-pear-channel-phpunit

It works for me via Symfony 2.

PS: If you meet

Unknown remote channel: pear.symfony-project.com
phpunit/PHPUnit requires package "channel://pear.symfony-project.com/YAML" (version >= 1.0.2)
No valid packages found

please checkout does pear.symfony-project.com stay at your pear channels.

PhpStorm does not work on OpenSuse 12.1 with Sun JDK(solution)

December 5th, 2011 | admin

After Sun JDK 1.7.0_01 configured for OpenSuse 12.1, PhpStorm does not work, I think it invokes /usr/lib/jvm/bin/java, but I can not find the folder, so I use the following solution:

$sudo ln -s /usr/lib/jdk1.7.0_01/ /usr/lib/jvm/java

Now it works.

Setup Sun JDK on OpenSuse

December 5th, 2011 | admin

Download JDK from http://java.sun.com, extra to /usr/lib/, mine is: /usr/lib/jdk1.7.0_01

Then:

$sudo /usr/sbin/update-alternatives --install /usr/bin/java java /usr/lib/jdk1.7.0_01/bin/java 3
$sudo /usr/sbin/update-alternatives --install /usr/bin/javac javac /usr/lib/jdk1.7.0_01/bin/javac 3

The last parameter is 3, it’s priority, not very important, you can find other by

$sudo /usr/sbin/update-alternatives --list java

It’s not important, do not care about it.

Now you have new JDK installed, let’s configure it:

$sudo /usr/sbin/update-alternatives --config java
$sudo /usr/sbin/update-alternatives --config javac

See the details, you can choose your new installed Sun JDK from list.

fetch remote branch via git

December 5th, 2011 | admin

We have many remote branches such as origin/dev, origin/master, origin/research and so on. How to fetch remote branch?

$git checkout -b dev origin/dev

dev is local branch name, origin/dev is remote branch name.

Build PHP 5 Development enviroment on OpenSuse 12.1

December 5th, 2011 | admin

First of all, you must have OpenSuse 12.1 installed. Then let’s start.

Install and configure MySQL

$sudo zypper install mysql mysql-client

$sudo /sbin/chkconfig --add mysql

$sudo /etc/init.d/mysql start

$sudo mysql_secure_installation

Optional, let’s create a test database

$mysql -uroot -p
$CREATE DATABASE `voicens` DEFAULT CHARACTER SET utf8 COLLATE utf8_general_ci;

Install and configure Apache2

$sudo zypper install apache2

$sudo /sbin/chkconfig --add apache2

$sudo /etc/init.d/apache2 start

Install and configure PHP5

$sudo zypper install apache2-mod_php5

$sudo /etc/init.d/apache2 restart

$sudo zypper install php5-mysql php5-bcmath php5-bz2 php5-calendar php5-ctype php5-curl php5-dom php5-ftp php5-gd php5-gettext php5-gmp php5-iconv php5-imap php5-ldap php5-mbstring php5-mcrypt php5-odbc php5-openssl php5-pcntl php5-pgsql php5-posix php5-shmop php5-snmp php5-soap php5-sockets php5-sqlite php5-sysvsem php5-tokenizer php5-wddx php5-xmlrpc php5-xsl php5-zlib php5-exif php5-fastcgi php5-pear php5-sysvmsg php5-sysvshm php5-pdo

$sudo /etc/init.d/apache2 restart

cheers.

Install build tools for Fedora

November 29th, 2011 | admin

One of my workstation installed Fedora 16 via LiveCD, I need to install gcc, make and something more. The simplest way is :

#yum groupinstall "Development Tools" "Legacy Software Development"

Upgrade to Symfony 2.0.6 for security upgrade

November 24th, 2011 | admin

It’s easy, change your deps to :


[symfony]
    git=http://github.com/symfony/symfony.git
    version=v2.0.6

[twig]
    git=http://github.com/fabpot/Twig.git
    version=v1.1.2

[monolog]
    git=http://github.com/Seldaek/monolog.git
    version=1.0.2

[doctrine-common]
    git=http://github.com/doctrine/common.git
    version=2.1.2

[doctrine-dbal]
    git=http://github.com/doctrine/dbal.git
    version=2.1.3

[doctrine]
    git=http://github.com/doctrine/doctrine2.git
    version=2.1.2

[swiftmailer]
    git=http://github.com/swiftmailer/swiftmailer.git
    version=v4.1.3

[assetic]
    git=http://github.com/kriswallsmith/assetic.git
    version=v1.0.2

[twig-extensions]
    git=http://github.com/fabpot/Twig-extensions.git

[metadata]
    git=http://github.com/schmittjoh/metadata.git
    version=1.0.0

[SensioFrameworkExtraBundle]
    git=http://github.com/sensio/SensioFrameworkExtraBundle.git
    target=/bundles/Sensio/Bundle/FrameworkExtraBundle

[JMSSecurityExtraBundle]
    git=http://github.com/schmittjoh/JMSSecurityExtraBundle.git
    target=/bundles/JMS/SecurityExtraBundle
    version=origin/1.0.x

[SensioDistributionBundle]
    git=http://github.com/sensio/SensioDistributionBundle.git
    target=/bundles/Sensio/Bundle/DistributionBundle
    version=origin/1.0

[SensioGeneratorBundle]
    git=http://github.com/sensio/SensioGeneratorBundle.git
    target=/bundles/Sensio/Bundle/GeneratorBundle

[AsseticBundle]
    git=http://github.com/symfony/AsseticBundle.git
    target=/bundles/Symfony/Bundle/AsseticBundle
    version=v1.0.1

change your deps.lock to

symfony b55a43813e8fbcf4facd19ce1da0cd7acc67ce9b
twig 396435ecd05556adb0a8bd05b14641cb4f8a8aa5
monolog b704c49a3051536f67f2d39f13568f74615b9922
doctrine-common b385ca770888248241bd3086a40d5b3bd082a706
doctrine-dbal e0b69790ab1ffd646fd70a04fdb91e5dfbb3ccf1
doctrine 144d0de0ab61dffc738d7fb590cff8d77919f553
swiftmailer daaff2b8515390fbb10882647311f476b89a67e6
assetic f829ad23d23c87480151a21faad49fefe7c09e5d
twig-extensions d5851b96f06442e74590e5540a4209e9e3946243
metadata 8717ad2a5689480765d9ffafe925cd8a2457e582
SensioFrameworkExtraBundle dcd40eb4e2fff2d82fad644bb44fc2a40ccaf381
JMSSecurityExtraBundle b8b7eb294ed83d83ca7260ac018e701f08003538
SensioDistributionBundle 20b66a408084ad8752f98e50f10533f5245310bf
SensioGeneratorBundle c6af9719ae9e81fa4e086f40697d35e7090921cc
AsseticBundle 41b5913b5086a0909af92adcb4a6005ee0051b16

Is it enouth? No, another two part need to add to your deps:

[JMSAopBundle]
    git=https://github.com/schmittjoh/JMSAopBundle.git
    target=/bundles/JMS/AopBundle

[CGLibrary]
    git=http://github.com/schmittjoh/cg-library.git
    target=cg-library

At last, do not forget:

$bin/vendors install

$php app/console cache:clear

Setup your own git server using gitolite

January 28th, 2011 | admin


If you are a developer and want to have a git server with ability to add users push/pull access you might consider something like a github. But why pay for hosting your private projects if you can use your host in the exactly same way? So let’s try to achieve this on an ubuntu server machine.
After a short search I found gitolite, it looks promising.
Let’s start.
1. Let’s install gitolite
cd $HOME
git clone git://github.com/sitaramc/gitolite gitolite-source
cd gitolite-source
sudo mkdir -p /usr/local/share/gitolite/conf /usr/local/share/gitolite/hooks
sudo src/gl-system-install /usr/local/bin /usr/local/share/gitolite/conf /usr/local/share/gitolite/hooks
2. Generate your ssh public key for YOUR machine which you are using to connect to the server. Skip this step in case you already have it. You may use this command with defaults answers and empty passphrase.
ssh-keygen -t rsa
3. Copy your LOCAL machine ssh public key to the server. This command will copy the key to your home directory on remote machine.
scp /home//.ssh/id_rsa.pub username@123.123.123.1:
4. On REMOTE machine copy the key to tmp directory like this
cp id_rsa.pub /tmp/.pub
5. Create git user which will host our repos.
sudo adduser git
6. Login into git user account using password you just gave it
su - git
7. Now run the gitolite setup. It will open config file into vi editor allowing you to edit some values before you setup. I left all the values as is and just quit the editor.
gl-setup /tmp/.pub
8. After setup is completed you have to clone the gitolite-admin repo to your local machine. It will be used for adminstration purposes. The command below depends on your server ssh config. In my case server allows only public key login for certain user. So I had to add git user to AllowUsers line in /etc/ssh/sshd_config.
git clone ssh://git@your-server.com:12345/gitolite-admin
9. At this point we can start creating repos and adding users. I won’t dive in a lot of detail here, I will just do some basic stuff.
Let’s add a repo. Open conf/gitolite.conf in the gitolite-admin dir you cloned to your local machine. You will see two default repos there, just copy one of them like this:
repo    test-repo
RW+     =   test-user
This will create a repo named test-repo and adds read-write access permissions to user identified by test-user public key.
10. Let’s add that key. Obtain it from the user you wish to give access and and rename it to test-user.pub. Put the key into keydir directory.
11. Let’s commit our changes to the server for them to take effect.
git add .
git commit -m “created test-repo, added RW+ to test-server user”
git push origin master
12. Now user can do the following in an existing git repo. 12345 is your ssh custom port.
git remote add origin ssh://git@your-gitolite-server.com:12345/test-repo
git push origin master
Now you can simply create new repos and add users to it. Please do read gitolite documentation to discover its power。