Nov
12
2008

Just put up a new website for a friend of mine who has just started a new classic car business Gasoline Alley. He already has a nice collection of mercs like this excellent 450 slc.

Mercedes-Benz 450SLC

This is a ruby on rails based site which uses attachment_fu and rmagick to manage and re-size the images uploaded onto the site. The site design is basic but the underlying code allows the end user to manage most is the content themselves and the rails framework made it possible to develop a flexible dynamic site within an extremely limited budget, more design and content will be added as time and money allow.

Nov
07
2008

I have a number of rails applications that allow the user to create and edit dynamic content i.e. a shop/store front. I am using bazzar and Capistrano for source control and deployment which works fine except that out of the box this was overwriting the end user uploads etc on the site each time the code was updated.

The first and obvious thing I did was remove these directories and files from bazaar:

bzr -rm ./public/uploads –keep

and then add an entry to the bzr ignore file

bzr ignore ./public/uploads

commit the changes and deploy the app

bzr push …

cap deploy

Hmm everything in the uploads directory has gone, not really the desired result. This content needs to be moved to the shared directory (or other convenient place) and linking with the current live site. So after creating the directory within the webroot/shared directory and moving the content into it, I need to create a symbolic link from the live site to the content. This link will need to be recreated each time I update the application so I need to add it to my Capistrano recipe:

task :after_deploy do
# recreate the link to the upload dir
run “ln -s /var/www/example.com/shared/uploads /var/www/example.com/current/public/uploads”
#put someother tasks we need to do here
passenger:restart
end

This looks fine but when I run it the site deploys ok but no link is created because :after_deploy isn’t being called. On close inspection of the Capistrano output:

*** [err :: dev-01.local] sudo: /var/www/example.com/current/script/process/reaper: command not found

although the file is actually present. The file permissions are wrong and it won’t execute (solution to this towards the end of this article) and then :after_deploy is not called. So I had to add an additional task to the recipe:

task :after_update_code  do
run “chmod +x #{release_path}/script/process/reaper”
run “chmod +x #{release_path}/script/process/spawner”
end

retest it and finally it all works!

Nov
02
2008

I was trying to install the rmagick gem and got the following error:

dev-01:~$ sudo gem install rmagick
Building native extensions.  This could take a while…
ERROR:  Error installing rmagick:
ERROR: Failed to build gem native extension.

/usr/bin/ruby1.8 extconf.rb install rmagick
checking for Ruby version >= 1.8.2… yes
checking for cc… yes
checking for …

etc.

This happens when the necessary libries are missing, I had installed the imagemagick package but this doesn’t include the dev libraries so I need to do :

dev-01:~$ sudo apt-get install libmagick++9-dev

after it completes, try again:

dev-01:~$ sudo gem install rmagick
Building native extensions.  This could take a while…
Successfully installed rmagick-2.7.1
1 gem installed

Which is what I wanted.

Oct
30
2008

When you try and install the native mysql gem you get:

>sudo gem install mysql

Building native extensions.  This could take a while…

ERROR:  Error installing mysql:

ERROR: Failed to build gem native extension.

checking for mysql_query() in -lmysqlclient… no

/usr/bin/ruby1.8 extconf.rb install mysql

blah..blah…and it fails.

Most likely you installed the mysql server package but you also need to install the mysql client development libraries (check the name of the latest package):

sudo apt-get install libmysqlclient15-dev

Now try again:

>sudo gem install mysql

Successfully installed mysql-2.7
1 gem installed

Building native extensions.  This could take a while…

That’s better.

Nov
12
2007

Just uploaded a new PHP script to our web server and got this:

Parse error: syntax error, unexpected T_STRING, expecting T_OLD_FUNCTION or T_FUNCTION or T_VAR or ‘}’ in /usr/local/psa/home/vhosts/xxx/httpdocs/xxx on line 37

The new file is PHP5, the web server is running PHP4.xx.

read more…

Older Posts »