31. January 2013

Redmine installation on Debian with Passenger

It’s quite easy to install Redmine on Debian Testing (Wheezy) with Passenger support in Apache, but there are some gotchas.

Install Redmine and Passenger module to Apache

apt-get install redmine libapache2-mod-passenger

It will automatically turn on Passenger module in Apache.

Configure virtual host:

DocumentRoot /usr/share/redmine/public

<Directory /usr/share/redmine/public>
 AllowOverride all
 RailsBaseURI /
 #RailsEnv development
 RailsEnv production
 Options -MultiViews
 </Directory>
<IfModule mod_passenger.c>
 PassengerRuby /usr/bin/ruby1.8
 PassengerEnabled On
 PassengerLogLevel 0
 PassengerUserSwitching off
 PassengerUseGlobalQueue on
 PassengerResolveSymlinksInDocumentRoot on
 </IfModule>

Important note: Use Ruby 1.8 in case of Redmine with version =<1.4.4. Otherwise you’ll get 500 Error at some pages, like XML export:

/usr/lib/ruby/vendor_ruby/active_support/dependencies.rb:131:in `rescue in const_missing'
/usr/lib/ruby/vendor_ruby/active_support/dependencies.rb:120:in `const_missing'

If you have newer version of Redmine, then you can set PassengerRuby to new version. ;-)

31. December 2012

KVM error: internal error no HVM domain loader – solution

It’s very pleasant situation when you reboot Linux server and it starts.

It’s very unpleasant situation when this server contains many KVM virtual servers and none of them start. :-(

virsh list displays just this:

Id Name State
----------------------------------
 0 Domain-0 running

That’s nonsense. There was no such virtual with name Domain-0.

When you try to create domain you can see this fancy error message:

[root@server qemu]# virsh create ./virtual-01.xml
error: Failed to create domain from ./virtual-01.xml
error: internal error no HVM domain loader

What went wrong? How to fix it?

I spare you long story with server diagnostic.

The problem was that server started different kernel after reboot. In this case it was different kernel with Xen support. Centos kernel with Xen support does not have KVM support. That’s quite logical. It was sufficient to change default kernel in grub.conf to non-Xen version, restart machine and everything was working like a charm.

21. December 2012

Debian – mdadm upgrade – dev: unbound variable

New version of mdadm for RAID management requires newer version of bash (4.2-4).

If you have older bash then you may encounter following fancy error during upgrade of mdadm and kernel:

/usr/share/initramfs-tools/hooks/mdadm: line 187: dev: unbound variable
E: /usr/share/initramfs-tools/hooks/mdadm failed with return 1.

Solution: just upgrade bash

apt-get install bash

26. November 2012

There is more to C and C++. Slides from talk at FI MUNI 2012

This year I had opportunity to speak at two courses at FI MUNI. Check out slides :)

There is more to C (PDF)

Libraries ant tools for C++ (PDF)

Source code of examples is at GitHub: github.com/georgik/fimuni-c-cpp-examples

4. November 2012

Unable to build CouchDB-XO_Auth – solution

CouchDB-XO_Auth is using make and rebar to build extension for CouchDB.

If you’re using debian package for CouchDB, then you’ll probably see following error after typing make:

==> meck (get-deps)
==> CouchDB-XO_Auth (get-deps)
==> meck (compile)
==> CouchDB-XO_Auth (compile)
src/xo_auth_fb.erl:4: can't find include lib "couch/include/couch_db.hrl"
src/xo_auth.erl:11: can't find include lib "couch/include/couch_db.hrl"

The problem is in rebar configuration. It trying to locate CouchDB Erlang files in /usr/local/lib/couchdb/erlang/lib/.

Default location of these files for Debian is: /usr/lib/couchdb/erlang/lib/
Solution: fix path rebar.config.

It should look like this:

%%-*- mode: erlang -*-
{deps, [
 {meck, "0.7.1", {git, "https://github.com/eproxus/meck.git", {tag, "0.7.1"}}}
 ]}.
{lib_dirs,["/usr/lib/couchdb/erlang/lib/"]}.

Windows version how-to (manual steps):

git clone https://github.com/ocastalabs/CouchDB-XO_Auth.git
cd CouchDB-XO_Auth
mkdir deps
cd deps
git clone https://github.com/eproxus/meck.git
cd meck
git branch 0.7.1
cd ..
cd ..
escript rebar compile

3. November 2012

Cannot find module ‘couchapp’ – solution for Linux and Windows

It is possible to create HTML5/CouchDB application using Node.js with tool Couchapp.

You can find nice totorial at RelaxTV.

The first step: install Couchapp:

npm -g install couchapp

Now you have command couchapp and you can create boilerplate:

coachapp boiler blog

This works fine, but when you want to publish this application to CouchDB server you can see weird error:

PS C:\idea\couch\blog> couchapp push app.js http://localhost:5984/blog
module.js:340
 throw err;
 ^
Error: Cannot find module 'couchapp'
 at Function.Module._resolveFilename (module.js:338:15)
 at Function.Module._load (module.js:280:25)
 at Module.require (module.js:362:17)
 at require (module.js:378:17)
 at Object.<anonymous> (C:\idea\couch\blog\app.js:1:79)
 at Module._compile (module.js:449:26)
 at Object.Module._extensions..js (module.js:467:10)
 at Module.load (module.js:356:32)
 at Function.Module._load (module.js:312:12)
 at Module.require (module.js:362:17)

People at node.couchapp discussion suggest that you should set NODE_PATH. This path should point to the place where node stores modules. npm shows this path during installation of module.

Fix for Linux:

export NODE_PATH=/usr/local/lib/node_modules

Node is using little bit different storage on Windows, it stores data into ~\AppData\Roaming\npm.

Fix for Windows Powershell (ConEmu):

$env:node_path="$home\AppData\Roaming\npm\node_modules"

If you want to persist change for PowerShell, then you can put this line into: Documents\WindowsPowerShell\Microsoft.PowerShell_profile.ps1

17. June 2012

How to solve some problems with Drupal after upgrade to PHP 5.4

I’ve found several interesting issue after upgrading PHP 5.3 to PHP 5.4 on Drupal 6 and Drupal 7 sites.

The first biggest problem was that Drupal was displaying Access denied message on all web pages. It was not possible to login to system. Even http://localhost/?q=admin didn’t work.

I had to create temporary session. It is quite easy when using Drush:

drush user-login

Drush displayed one time session for admin. This solved the problem with admin login.

The other issue was that there was Access denied message on every page. There were also other very useful messages flooding each page:

Notice: Undefined index: access in function _menu_link_translate() …

I spent some time searching for any hint how to resolve this weird behavior. It was necessary to delete all Drupal’s caches.

Configuration -> Development -> Performance -> Delete cache

After this clean up Drupal was working correctly.

Then I checked one older Drupal 6 site and there was nice big red warning:

Warning: strtotime() [function.strtotime]: It is not safe to rely on the system’s timezone settings. You are *required* to use the date.timezone setting or the date_default_timezone_set() function. In case you used any of those methods and you are still getting this warning, you most likely misspelled the timezone identifier.

The problem was that there was no default timezone in php.ini. It was sufficient to add timezone to /etc/php5/apache2/php.ini to section

[Date]
; Defines the default timezone used by the date functions
; http://php.net/date.timezone
date.timezone = "Europe/Prague"

You can find more info about timezones at php.net/date.timezone.

After reloading Apache configuration everything was ok.

7. May 2012

Materiály z prednášky: Ať se z kódu nepráší!

Prednáška vo formáte: PDFSlideShare.

Inšpirované: Marzík remix

10. March 2012

Tomcat 7 listen on port 80 – Linux Debian

The default installation of Tomcat 7 for Linux Debian is listening on port 8080.

When you want to change the port to 80 then you have several options.

You can use iptables and redirect communication from port 8080 to port 80.

The more straight forward approach is to bind Tomcat directly to port 80. First of all change port 8080 to 80 in file /etc/tomcat7/server.xml.

You’ll see error messages in /var/log/tomcat7/catalina.out when you try to restart Tomcat:

SEVERE: Failed to initialize connector [Connector[HTTP/1.1-80]]
org.apache.catalina.LifecycleException: Failed to initialize component [Connector[HTTP/1.1-80]]
Caused by: java.net.BindException: Permission denied

The problem is that default installation of Tomcat 7 for Linux Debian allows to bind only ports higher than 1023. You need to allow binding to privileged ports.

Open file /etc/defaults/tomcat7 and change option from:

#AUTHBIND=no

to:

AUTHBIND=yes

Restart Tomcat and it will listen on port 80.

7. March 2012

Web stress test by Apache Benchmarking Tool

Sometimes you need to identify bottleneck of web application.

You can use Selenium to record and repeat the same steps over and over.

Another solution is to use Apache Benchmarking Tool.

E.g. You need to send 1000 requests in 10 concurrent threads to localhost:

ab -c 10 -n 1000 http://localhost/

For Debian users: you can find this mighty command in apache2-utils package.

Sample result:

Server Software:        Apache-Coyote/1.1
Server Hostname:        localhost
Server Port:            80

Document Path:          /
Document Length:        405 bytes

Concurrency Level:      10
Time taken for tests:   0.524 seconds
Complete requests:      1000
Failed requests:        0
Write errors:           0
Total transferred:      650000 bytes
HTML transferred:       405000 bytes
Requests per second:    1907.13 [#/sec] (mean)
Time per request:       5.243 [ms] (mean)
Time per request:       0.524 [ms] (mean, across all concurrent requests)
Transfer rate:          1210.58 [Kbytes/sec] received

Connection Times (ms)
              min  mean[+/-sd] median   max
Connect:        0    2   0.5      2       4
Processing:     0    3   0.5      3       4
Waiting:        0    2   0.7      2       4
Total:          2    5   0.3      5       8
  • Babel fish

      Translate from:

      Translate to:

  • Where’s the fish?

  • Further info

  • Badges

  • Video channel

  • Learning

    Grow your brain.
  • Tags

  • Topics

  • May 2013
    M T W T F S S
    « Feb    
     12345
    6789101112
    13141516171819
    20212223242526
    2728293031  
  • Comments