dracoblue.net

Configure an Agavi Site with NGINX (using PHP-FPM)

I was used to configure my Agavi site with Lighttpd and recently switched to Nginx. The setup for Nginx was not so common to me, so I decided to write down what I had to do to configure it properly. Here is an example for dracoblue.net. Please change the parts of the script to suit your needs (the necessary parts are highlighted with "HINT:").

First of all install php5-fpm. On ubuntu I did it this way:

$ sudo apt-get install php5-fpm

Now create a new file:

$ vim /etc/nginx/sites-enabled/dracoblue.net

And add the following:

server {
    listen dracoblue.net:80;
    # HINT: Add the servername, so Agavi is able to see that it's dracoblue.net
    # Otherwise you'll get something like "localhost" here
    server_name dracoblue.net;

    location / {
        # HINT: The directory where index.php is
        root   /home/dracobluenet/tags/1.0.0/pub;
        index index.php;

        # HINT: All files except those in "static" should be served by index.php
        location ~* ^/(favicon.ico|robots.txt|static) {
            break;
        }

        # HINT: All files except those in "static" should be served by index.php
        if ($uri !~ "^/(favicon.ico|robots.txt|static|index.php)") {
            rewrite ^/([^?]*)$ /index.php?/$1 last;
        }
    }

    location ~ \.php($|/) {
        include /etc/nginx/fastcgi_params;
        fastcgi_pass 127.0.0.1:9000;
        # HINT: The directory where index.php is + $fastcgi_script_name
        fastcgi_param SCRIPT_FILENAME /home/dracobluenet/tags/1.0.0/pub$fastcgi_script_name;
        fastcgi_param PATH_INFO $fastcgi_script_name;
    }
}

As you can see, for projects I usually have only a "static" folder which is not served by agavi. This keeps the amount of work low, which nginx needs to do for each request to decide whether it should be served by php or not. I also added robots.txt and favicon.ico since you usually have them in root, too.

Restart nginx.

$ /etc/init.d/nginx restart

In agavi, articles, lighttpd, linux, nginx, php by DracoBlue @ 09 Dec 2010 | 287 Words

Agavi Seite mit NGINX einrichten (mit PHP-FPM)

Ich bin es eigentlich gewöhnt meine Agavi Seiten mit Lighttpd auszuliefern. Seit kurzem läuft vieles hinter dem Nginx. Da die Konfiguration für mich nicht so gewohnt war, möchte ich hier einfach mal veröffentlichen, wie ich Nginx mit Agavi eingerichtet hab. Am besten die Stellen anpassen wo "HINT:" steht.

Erstmal braucht man php5-fpm. Unter ubuntu ging es so:

$ sudo apt-get install php5-fpm

Nun eine Datei anlegen:

$ vim /etc/nginx/sites-enabled/dracoblue.net

Und das folgende dort rein tun:

server {
    listen dracoblue.net:80;
    # HINT: Hier auf alle Fälle server_name setzen, sonst sieht Agavi nicht, dass es sich
    # um dracoblue.net handelt und generiert die URLs mit "localhost" oder ähnlichem
    server_name dracoblue.net;

    location / {
        # HINT: Das Verzeichnis wo die index.php ist
        root   /home/dracobluenet/tags/1.0.0/pub;
        index index.php;

        # HINT: Alle Anfragen (außer an "static") sollen index.php ausgeliefert werden
        location ~* ^/(favicon.ico|robots.txt|static) {
            break;
        }

        # HINT: Alle Anfragen (außer an "static") sollen index.php ausgeliefert werden
        if ($uri !~ "^/(favicon.ico|robots.txt|static|index.php)") {
            rewrite ^/([^?]*)$ /index.php?/$1 last;
        }
    }

    location ~ \.php($|/) {
        include /etc/nginx/fastcgi_params;
        fastcgi_pass 127.0.0.1:9000;
        # HINT: Das Verzeichnis wo die index.php liegt $fastcgi_script_name
        fastcgi_param SCRIPT_FILENAME /home/dracobluenet/tags/1.0.0/pub$fastcgi_script_name;
        fastcgi_param PATH_INFO $fastcgi_script_name;
    }
}

Wie Du siehst, haben meine Projekte normalerweise lediglich den "static" Ordner, der nicht von Agavi ausgeliefert. Das sorgt dafür, dass der nginx nicht so viel ausprobieren muss um rauszufinden, ob die datei von php ausgeliefert wird oder nicht. Hier habe ich auch noch robots.txt und das favicon.ico hinzugefügt, weil man die meistens ja auch im root hat.

Nun noch Nginx neu starten:

$ /etc/init.d/nginx restart

In agavi, articles, lighttpd, linux, nginx, php by DracoBlue @ 09 Dec 2010 | 272 Words

LFE (sub-woofer) disabled in Ubuntu 10.10 Maveric Meerkat

When I updated to ubuntu 10.10, I had this mysterious problem.

The sub-woofer just worked one time right after I clicked the "5.1 System" in the ubuntu sound options. As soon as a song ended, the sub-woofer was mute again.

I expected this to be an issue of the pulseaudio integration in 10.10. The reason was way simpler!

In 10.10 by default:

enable-lfe-remixing = no

is set in

/etc/pulse/daemon.conf

Just change this to

enable-lfe-remixing = yes

and pulseaudio will mix the 2 channel sound tracks up to the 5 channels including LFE!

In articles, linux, open source, ubuntu by DracoBlue @ 05 Dec 2010 | 107 Words

Cannot connect to ICQ on Ubuntu Maveric Meerkat

Today I expirienced the issue, that

empathy (the ubuntu icq, msn, facebook, ... client) was not able to connect to ICQ anymore.

To fix that issue, just install pidgin ppa (yes, I know you want empathy, but you'll need libpurple to fix it for empathy!).

Then

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

You'll see something like:

Configuring libpurple-bin ein (1:2.7.5-1ubuntu2+pidgin1.10.10) ...
Configuring libpurple0 ein (1:2.7.5-1ubuntu2+pidgin1.10.10) ...

and everything is fine again. Just restart empathy!

Thanks to twenty-three for the hint.

In articles, linux, open source, ubuntu by DracoBlue @ 18 Nov 2010 | 96 Words

Update for Mootools Youtube Player

Today I updated the YtMooPlayer.js-component (

showcase).

A while back the youtube chromeless api of google changed, so it was manadatory to set the "version"-parameter.

The new 1.0.1 version of YtMooPlayer.js fixes this issue.

You can download the youtube mootools class at dracoblue.net or pull the source from github.

In javascript, mootools, open source by DracoBlue @ 07 Nov 2010 | 52 Words

Page 14 - Page 15 - Page 16

Give something back

Were my blog posts useful to you? If you want to give back, support one of these charities, too!

Report hate in social media Campact e.V. With our technology and your help, we protect the oceans from plastic waste. Gesellschaft fur Freiheitsrechte e. V. The civil eye in the mediterranean

Recent Dev-Articles

Read recently

Recent Files

About