Fork me on GitHub

MacPorts, PHP 5.3 and Mysqlnd

If you have recently upgraded to php 5.3 and you have done it using
sudo port install php5 +apache2+macosx+mysqlnd+pear
you should have noticed that you cannot use mysql anymore because of an error that, I’m sure, is driving you crazy
PHP Warning: mysqli::mysqli(): [2002] No such file or directory (trying to connect via unix:///tmp/mysql.sock) in /Users/antonio/Sites/db.php on line 25

PHP Warning: mysqli::mysqli(): (HY000/2002): No such file or directory in /Users/antonio/Sites/db.php on line 25
The problem comes from php and unfortunately is only fixable changing the location of the mysql.sock from the usual macports directory /opt/local/var/run/mysql5/mysqld.sock to /tmp/mysql.sock editing the file /opt/local/etc/my.cnf

;)

the twittersphere

Sooooooo funny!

svn revert cleanup

You have reverted an svn merge and you have a lot of files not tracked (with exclamation mark, basically)?
Clean it up:
svn status | awk '$1 == "?"  {print $2}' | xargs -t -i rm -r {}
Again, knowing awk and xargs turn helpful!

Tech Talk: Linus Torvalds on git

Git explained by his the creator. I’m more convinced than ever!

the correct procedure for compiling subversion 1.6.2

Not sure if this is the complete way of doing it (I’m not telling you which .deb to install), but it worked for me:

Remove some waste from eventual previous compilations:

$ rm -rf /usr/loca/lib/libsvn*
$ rm -rf /usr/local/lib/libapr*
$ rm -rf /usr/local/lib/libexpat*
$ rm -rf /usr/local/lib/libneon*

Run autogen

$ ./autogen.sh  

Configure and install (it is important to follow the order)

$ ./configure
$ make -j external-all
$ make -j local-all
$ sudo make install

That’s it. Hope to have helped someone as usual.

my .bashrc and env on mac

If someone find it useful… I do and this post is, honestly, for my record:


bash-3.2$ env
APSX2=/opt/local/apache2/bin/apxs
MANPATH=/opt/local/share/man:/opt/local/share/man:/opt/local/share/man:/opt/local/share/man:/usr/share/man:/usr/local/share/man:/usr/X11/man
TERM_PROGRAM=iTerm.app
LC_MONETARY=en_GB.UTF-8
SHELL=/bin/bash
TERM=xterm
LC_NUMERIC=en_GB.UTF-8
COMMAND_MODE=legacy
__CF_USER_TEXT_ENCODING=0x1F5:0:0
PATH=/opt/local/apache2/bin:/opt/local/bin:/opt/local/sbin:/opt/local/apache2/bin:/opt/local/bin:/opt/local/sbin:/opt/local/apache2/bin:/opt/local/bin:/opt/local/sbin:/opt/local/apache2/bin:/opt/local/bin:/opt/local/sbin:/opt/local/apache2/bin:/opt/local/bin:/opt/local/sbin:/opt/local/bin:/opt/local/sbin:/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin:/usr/X11/bin
LC_MESSAGES=en_GB.UTF-8
LC_COLLATE=en_GB.UTF-8
PWD=/Users/zekus
EDITOR=/usr/bin/mate -w
LANG=en_GB.UTF-8
HOME=/Users/zekus
SHLVL=1
LOGNAME=zekus
LC_CTYPE=en_GB.UTF-8
DISPLAY=:0.0
SECURITYSESSIONID=613f90
LC_TIME=en_GB.UTF-8
_=/usr/bin/env


bash-3.2$ cat ~/.bashrc
export PATH=/opt/local/apache2/bin:/opt/local/bin:/opt/local/sbin:$PATH
export MANPATH=/opt/local/share/man:$MANPATH
export DISPLAY=:0.0
export EDITOR='/usr/bin/mate -w'
export APSX2='/opt/local/apache2/bin/apxs'
alias mysqld='sudo /opt/local/share/mysql5/mysql/mysql.server'
alias apachectl='sudo /opt/local/apache2/bin/apachectl'
alias mysql='mysql5'
alias rake='/opt/local/bin/rake'
alias rails='/opt/local/bin/rails'
alias ruby='/opt/local/bin/ruby'
postgresqlctl () { sudo su postgres -c "/opt/local/lib/postgresql83/bin/pg_ctl $1 -D /opt/local/var/db/postgresql83/defaultdb"; }

Note the last row in the bashrc: is a function to load the postgres server on demand!

bash: mv files with a specific date to another directory

I was searching for a bash command to move files and directories from a folder to another with modified in a specific date for ages on google until I gave up and decided to write it myself:
ls -l | awk '$6 == "2009-06-04" { print $8 }' | xargs -t -i mv {} /destination/folder
To understand what this line does, you need to know a bit about awk and xargs (try “man xargs” in your shell)

Explaination:

ls -l
: directory listing
awk ‘$6 == “2009-06-04″ { print $8 } : take the files and dir with date 2009-06-04 and print the list
xargs -t -i mv {} /destination/folder : execute the mv command. {} is the result from the previous command.

I would like to explain you more, but I’m quite lazy and I leave you with google to undestand better the commands I’ve used.

Have fun! ;)

Migrated

Me and Antonello have finally bought our server and this blog has been the first to be migrated.
Totally happy! Expect great new things :D

long time

Wow, I just noticed that my last post was 50 days old… I must have been busy, haven’t I?
So, what am I doing? The first part time website in Ruby on Rails is going to be published and I was working on that almost every evening and weekend with Antonello.
I should have written something about Rails and Ruby in here but … there is already a lot of material around the web.

Maybe I’ll post something on GIT that is a bit more obscure :)

Rails and Passenger ( aka mod_rails )

We tried to setup a rails application in a server subfolder in a way that could have been accessible through an URL like http://servername/rails,  so we followed the configuration manual for mod_rails.We found that, to make rails works in a subfolder, should have used the Apache parameter RailsBaseURI.

With a great surprise, that didn’t worked so we started trying all possible apache configuration combinations to avoid that 404 error that was becoming a nightmare.

After few hours we started doubting about our Apache knowledge and even about our capacity of reading and following a couple of stupid instructions on a website!

We gave up and we started googling around when… the solution came out from dozens of blogs, forums and newsletters:

MOD_RAILS IS NOT COMPATIBLE WITH RAILS 2.2.2 AND ITS NEW ROUTING SYSTEM

“HOLY CRAP” was our esclamation and I will not mention here all the italian’s bad words that suddenly came out from our mounth!

So, here the solution: put this line here
config.action_controller.relative_url_root = "/guestbook"
in your environment.rb

Now restart apache and enjoy!

ps. why hadn’t we changed mod_rails with mongrel or anything different? I don’t know!!!!