dracoblue.net

Remote logging with rsyslog, php and agavi

When I tried to get rsyslog running with php I didn't face much problems. Anyways I want to share some things I noticed while getting it to work.

First of all ubuntu uses rsyslog already. Just a simple

# apt-get install rsyslog-mysql

and all syslog messages went directly into the database "syslog". Configure /etc/rsyslog.d/mysql.conf to insert this information into a remote machine.

Now let's get to php. You have the option to set:

error_log=syslog

This however does log all messages with

php: whatever the issue or error is

If you want to replace "php" with a custom message, you have to call

openlog('myapp', LOG_PID | LOG_ODELAY, LOG_USER);

before any error happens. Because LOG_ODELAY is given, it won't connect to syslog unless any error happens, so one should be save to put this call at the top of your dispatcher file.

The final log message will look like that (254 is the process id):

Sep 26 13:39:44 root-server myapp[254]: the issue or error

Finally I wanted to log all messages created by agavi's logging system. Since I didn't found an existing

AgaviSyslogLoggerAppender, I wrote one and put it up on a github-gist.

Have fun logging!

In Agavi, MyQuests, Ubuntu, php by DracoBlue @ 2011-09-26 | 196 Words

Nginx always overwrites the Server-Header

When I was configuring the nodejs server behind nginx, I experienced the issue that nginx always overwrote the Server header response.

This is a bit annoying, since I want to know what version of spludo runs on my site.

The solution is not to set

server_tokens off

since that would only disable the version number.

The solution is:

proxy_pass_header Server;

In NGINX, Spludo, node.JS by DracoBlue @ 2011-06-19 | 61 Words

Facebook Client for node.js 1.3.0

Today I have an update for the

Facebook Client for node.js finished.

The version 1.3.0 is a graph and rest api client for facebook. It has support for the latest stable nodejs 0.4.x.

Now it's possible to post data (for instance into your news feed):

facebook_session.graphCall(
    "/me/feed", {
        "message":"I love node.js!"
    },
    'POST'
)(function(result) {
    console.log('The new feed post id is: ' + result.id);
});

All you need to do is to specify the method parameter (defaults to GET).

Thanks to

jharlap for this addition.

Also thanks to tslater and shaisultanov. They found an issue with expires-time (which is fixed now) and requested the brand new FacebookSession#isValid method, which tells you if the session is really alive.

Source may be found at node-facebook-client@github.

The package is also available by using npm:

$ npm install facebook-client

In JavaScript, node-facebook-client, node.JS, open source by DracoBlue @ 2011-04-26 | 136 Words

Installing php 5.3.5/5.3.6 on Ubuntu Maverick/Lucid

Latest Version for PHP 5.3 on Ubuntu is just PHP 5.3.3. This is not so good, if you want to have some of the plenty bugfixes which will be shipped with a later version.

If you want to upgrade to 5.3.5 (5.3.6 support may come later), you can use this inofficial ppa by the nginx user at launchpad:

https://launchpad.net/~nginx/+archive/php5.

For ubuntu maverick just create a file:

$ gedit /etc/apt/sources.list.d/php5-ppa.list

with the contents

deb http://ppa.launchpad.net/nginx/php5/ubuntu maverick main
deb-src http://ppa.launchpad.net/nginx/php5/ubuntu maverick main

and run:

$ sudo apt-get update
$ sudo apt-get dist-upgrade

Now you have php-5.3.5 installed on your ubuntu box! Have fun.

In Linux, Ubuntu, php by DracoBlue @ 2011-04-13 | 102 Words

Custom identity file (id_rsa.pub) with git client

Whenever you want to use a custom identity file with ssh, you usually use the -i parameter.

$ ssh -i ~/.ssh/other_id_rsa [email protected]

This will validate against ~/.ssh/other_id_rsa.pub and not the default one at ~/.ssh/id_rsa.pub.

If you want to use this with the default git client, it won't work. You cannot specify the identity file when cloning/pulling from or pushing to a repository, yet.

So:

$ git remote add origin ssh://[email protected]:repository.git
$ git pull origin master

will fail, because it's using the default rsa key at ~/.ssh/id_rsa.

Instead you can use this workaround.

Adjust your ~/.ssh/config and add:

Host example
  Hostname example.com
  User myuser
  IdentityFile ~/.ssh/other_id_rsa

Now use the ssh host alias as your repository:

$ git remote add origin example:repository.git
$ pull origin master

And it should use the other_id_rsa-key!

In Linux, ssh by DracoBlue @ 2011-03-20 | 130 Words

Page 13 - Page 14 - Page 15