Thursday, June 30, 2011

Installing Subversion from source and mod_dav_svn in Apache

Installing Subversion from  source was one of the most frustrating thing I have done because of its dependencies so I'll summarize here a short process to do it.

1.) Download and extract Subversion from here
shell> cd /usr/local/src
shell> wget
shell> sudo tar xzvf subversion-1.6.17.tar.gz

2.) Install the dependicies and development packages (they need to be the development '-dev'). Below are the libs that it took me awhile to find:
shell> sudo apt-get install libxml-dev
shell> sudo apt-get install libssl-dev
shell> sudo apt-get install zlib1g-dev

3.) Install Subversion. I will assume that you already installed Apache, mod_ssl and signed your certificates if not refer to this other blog post of mine in installing apache:
shell> cd /usr/local/src/subversion-1.6.17.tar.gz
shell> sudo ./configure --prefix=/usr/local/lib/subversion --with-apxs=/usr/local/apache2/bin/apxs --with-ssl

NOTES: Some installation that I read from other websites suggests you to include neon, apr, apr-utils like this for example:
shell> sudo ./configure --prefix=/usr/local/lib/subversion --with-apxs=/usr/local/apache2/bin/apxs --with-apr=PATH-TO-APR --with-apr-util=PATH-TO-UTIL --with-neon=PATH-TO-NEON --with-openssl=PATH-TO-OPENSSSL --with-ssl

You dont have to do the above! Infact when I did that build, that's when my headache started because of the dependencies. You also do not need to install the individual packages that are required namely apr, apr-utils, and neon. The install script will automatically search for the libraries included with the tar package you downloaded.

Then after configure finishes:
shell> sudo make
shell> sudo make install

This will install the and in the modules directory of your Apache installation.

EXTRAS: Some stuffs that I discovered along the way (just sharing :P ):

- This will return the list of files that are using this library that you installed through apt-get. In other words, the installed file locations:
shell> sudo dpkg -L libssl-dev

- Will look at your apt-get history and return which packages you have installed in the past
shell> grep -nwH install /var/log/dpkg.log ;: look at installs
shell> grep -nwH removes /var/log/dpkg.log ;: look at removes

- Download the source from the package distribution then install it yourself from source instead.
shell> sudo apt-get source libapache2-svn ;: will download and extract the source files
shell> sudo apt-get build-dep libapache2-svn ;: this will install all the dependencies
shell> cd subversion-1.6.12dfsg
shell> sudo ./configure --prefix=PATH --with-apxs=PATH-TO-APXS-FILE

Thats it!

Thursday, June 23, 2011

Notes on Setting up Subversion in Ubuntu

Quick walkthrough on setting up subversion in your own server. I will use WebDAV in order to communicate with Apache and quick setup of Samba in case you want to look at your repository in Windows.

1.) Install subversion
shell> sudo apt-get install subversion

2.) Add a subversion group:
shell> sudo groupadd subversion

3.)  Add your username and www-data to the group subversion:
shell> sudo gpasswd -a username subversion
shell> sudo gpasswd -a www-data subversion

4.) Create your repository. I chose mine to be created in /usr/local
shell> cd /usr/local
shell> mkdir svn/myproject ;: this is the name of my repository
shell> chown -R www-data:subversion svn/myproject
shell> chmod -R g+rws svn/myproject
shell> cd svn
shell> svnadmin create myproject ;: for organizational purposes, svn dir will hold different projects

5.) Import our project. I choose to create a trunk here.
The project here is empty or nonexisting yet. Also, you need to go out outside the /usr/local/svn directory
shell> cd /home/projects
shell> mkdir -p myproject/trunk
shell> svn import myproject file:///usr/local/svn/myproject -m "Initial import"

This will create project "myproject" in /svn/myproject thus creating you a directory structure in svn repo like /svn/myproject/trunk

5b.) If you need to import an existing project with existing files inside it do:
shell> cd /home/superman/www/myproject ;: assume this is my project location
shell> svn import . file:///usr/local/svn/myproject/trunk -m "Initial import of project Superproject"

Notice that I created a trunk directory via import command

6.) Lets install the WebDAV SVN module in apache.
shell> sudo apt-get  libapache2-svn
shell> sudo vim /etc/apache2/mods-available/dav_svn.conf

7.) Add this:
  <Location /svn/myproject>
     DAV svn
     SVNPath /usr/local/svn/myproject
     AuthType Basic
     AuthName "SVN Repo"
     AuthUserFile /etc/subversion/passwd
        Require valid-user

8.) Now lets create the passwd file
shell> sudo htpasswd -c /etc/subversion/passwd username ;: -c to create the file
shell> sudo htpasswd /etc/subversion/passwd batman ;: add another user. no -c this time
shell> sudo apache2ctl restart

9.) NOTES: If you happen to have permissions problem like if you are using tortoise and trying to commit but wont let you do it do:
shell> sudo gpassswd -a www-data subversion :; make apache part of the group
shell> cd /usr/local/svn/myproject :; make sure myproject is owned by www-data
shell> sudo chown -R www-data:subversion . :; we did this earlier but just making sure

10.) OPTIONAL. If you have samba installed and want to add /usr/local/svn
shell>sudo vim /etc/samba/smb.conf
Then add this:
   path = /usr/local/svn
   writeable = yes
   browseable = yes
   valid users = username
   guest ok = no

11.) Checking out your project
shell> cd /home/superman/projects/www
shell> mkdir myproject
shell> svn checkout file:///usr/local/svn/myproject/trunk myproject

12.) When checking out in Windows using Tortoise SVN use:
http://[ip of svn server]/svn/myproject/trunk 

The above link is the one to use also for viewing your SVN tree structure via a web browser and will only work if you install the WebDAV module in Apache.

Monday, June 13, 2011

My Thoughts on taking the (ZCE) Zend Certified Engineer PHP 5.3 Exam

I currently took the Zend Certified Engineer exam for PHP 5.3 a few hours ago... and passed it!

I am pretty happy about the result as I have been studying for this certification for 2 weeks and did a 2 day all-day review 2 days before taking it so all we be fresh.

About the exam, there is a non-disclosure that I am not suppose to share anything about the exam but I can give you an idea about it in general.

The exam was pretty challenging. I actually thought im going to fail it at the end! I think in order to pass, you really need to be familiar with PHP and be coding with it for some years, have pretty good analytical skills and good attention to detail.

Here are some good tips that I can think of while I was studying for it:
1. You need to know the PHP functions, array, strings and so on that you will see in the study guide and! I would suggest that while you are reviewing that you try each function once by actually writing it in PHP and running it! You'll get familiar easier that way...for me that is.
2. Review SPL, XML (SimpleXML and DOM as you will see in the study guide) and the new additions in PHP 5.3 like namespaces and static bindings! I would suggest writing some sample scripts again to familiarize. Know its quirks! When I was reviewing I try to find out what coding styles will work and what will not and why/how does it generate that, whats valid and whats not.
3. Do some practice test, actually a lot of practice test! You can try purchasing exam vouchers in
4. Read the official study guide from Zend. I went to every link reference that was suggested there and read what I think was important. I also made sure that I know and can answer correctly all of the test questions in that study guide. If you are unfamiliar of something, go to and review it!

So in summary...
Does it make you a good coder... No, everyone of us codes differently and have our own styles and by passing the ZCE doesn't really certify that you write clean, understandable and conforming codes. Wish it does though.
Does it certify that you know the PHP Language ... Yes, unless you are a pretty darn good guesser, the questions require that you are really familiar with the language and its "quirks".
Does it prove that you have good analytical skills... Somewhat, you need to have good analytical problem solving skills which requires you to analyze the given codes as stated in the study guide (Emphasis Analysis vs Memorization).
Is it worth it... For me, yes, because the feeling of satisfaction that you achieved something feels good :)

Wednesday, June 8, 2011

PHP Install Problems with SNMP - Error: Sanity check failed

In my post here:

I mentioned that I keep getting error problems installing SNMP (--with-snmp) in PHP version 5.3.6:
error: SNMP sanity check failed.
and in config.log:
configure:88255: checking for init_snmp in -lsnmp
ld: fatal: library -lsnmp: not found
ld: fatal: library -lsnmp: not found

I finally figured out the problem which is a package that I cannot find before.
Basically this is the required package according to

So all I have to do is:
$> sudo apt-get install libsnmp
$> sudo apt-get install libsnmp-dev

The libsnmp-dev is the one I was missing!
Here again is my build:

./configure \
--prefix=/usr/local/lib/php5.3.6 \
--with-apxs2=/usr/bin/apxs2 \
--with-mysql=/usr/local/mysql \
--with-mysqli=/usr/local/mysql/bin/mysql_config \
--with-pear=/usr/local/lib/php5.3.6/lib/php \
--with-tidy \
--with-curl \
--with-curlwrappers \
--with-openssl-dir \
--with-xpm-dir \
--with-pdo-mysql \
--with-xsl \
--with-ldap \
--with-xmlrpc \
--with-iconv-dir \
--with-bz2 \
--with-mcrypt \
--with-jpeg-dir \
--with-png-dir \
--with-zlib-dir \
--with-freetype-dir \
--with-gd \
--with-snmp \
--enable-mbstring \
--enable-zip \
--enable-exif \

Monday, June 6, 2011

Walkthrough on how to use Zend_Controller_Router_Route_Chain

I was a little confused at first look of what Zend_Controller_Router_Route_Chain does so here's my 2 cents on explaining this feature.

I use Zend_Config_Xml so I will write my example as XML.

Say we have a URL like this:
that we want to route and we wanted to use the as our base url.

Here is what we would do to implement router chaining on the above URL.


Assuming we are only going to use controller Automobile.

Route name "Automobile-Make" correspond to URL:

Route name "Automobile-Make-Model" corresponds to URL:

Route name "Automobile-Make-Model-Year" corresponds to URL:

You get the groove? Also notice the route tags inside the chains, it is only specific to specific URI for example: "make-:make" instead of rewriting the whole "route" to "automobile/make-:make" which is being appended. Also note that route "Automobile" will not exist here.

Another neat thing is you can create other routes on the same chain level so if you want to do something like: you declare a route the same as on the route "Model" level as you will see below.







Friday, June 3, 2011

TIP: Useful Linux Network Monitoring Commands

Ports that are t=tcp u=udp l=listening p=program n=numeric
$> netstat -tulpn

Proto Recv-Q Send-Q Local Address           Foreign Address         State       PID/Program name
tcp        0      0   *               LISTEN      2005/smbd
tcp        0      0    *               LISTEN      2442/apache2
tcp        0      0    *               LISTEN      2323/vsftpd

List of open files and program that opens them. This one looks at specific malicious port 667:
$> sudo lsof -i tcp:667

darkstat 1629 nobody    8u  IPv4   6054      0t0  TCP *:667 (LISTEN)

Thursday, June 2, 2011

TIP: Target MySql Users to Specific Hosts and Database

It is a good practice when creating MySql users to bind the target user to a specific host.

mysql> CREATE USER 'John'@'';
mysql> SELECT User, Host, Password FROM mysql.user; /* Show the list of users to verifiy */

Then you can create a database and target the user to that database in the above case, user "John".

mysql> GRANT SELECT , INSERT , UPDATE , DELETE ON new . * TO 'John'@'';

Now user John can only access the database from host and only have access to database "new".

Accessing Remote Resources or LAN via PPTP VPN in Ubuntu

I have a problem where I can establish a connection to my VPN server but cant access remote resources or my LAN except for the VPN server.

To solve this issue assuming you can already connect to your VPN:

$> cat /proc/sys/net/ipv4/ip_forward
If the commmand returns 0 then:

$> sudo bash -c "echo 1 > /proc/sys/net/ipv4/ip_forward"
$> cat /proc/sys/net/ipv4/ip_forward
Should return 1 now.

* To make it permanent edit:
/etc/sysctl.conf and uncomment the line: net.ipv4.ip_forward=1

Props to:
for the fix but that alone didn't do for me, I need to configure the IP routing for PPTP.

Continuing...You need to configure your PPTP settings:
$> sudo vim /etc/pptpd.conf

Edit from the recommended:


My LAN's subnet mask is from The PPTP local server's ( subnet will be and the remote IPs will start from which is also according to my configurations. I do not know how to change the subnet for the VPN so it would be nice to learn that. I tried prepending the subnet as a CIDR notation like but doesnt seem to work.

In any case, by changing from to (notice the "1") the local LAN being requested from the client VPN should forward now. I chose a high number 100 to avoid collision with my LAN so just be aware of that if you have tons of computer connecting to your network!

This may not work for others but it worked for me so just my 1 cent.