Setting up PluXML with Nginx

pluxml_picture

Hi, today, we are going to see powerfull web servers – nginx – and portable cms – PluXML written in Php.

 The goal is to set up the all solution under fedora 12 and make it works in local. 

 Let’s start with most important steps and resources that allowed me to set up everything in quiet short time :

  • PluXML : Download the latest archive and extract it wherever you want on your drive
  • NGinx : Downlad and build-it up, or install it through your favorite package-manager (i.e yum install nginx)
  • Install Php and FastCGI in your system,for example under fedora : yum install lighttpd-fastcgi php php-gd


Setting up Nginx

 For nginx, the only thing to do is to start it : 

/etc/init.d/nginx start 

Setting up Php and FastCGI to work with Nginx

 Once you installed php and fast-cgi, you can configure nginx to use fast-cgi. I show below modifications I performed on /etc/nginx/nginx.conf.

# pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000
#
location ~ \.php$ {
#    root           html;
    root /home/pluxml/pluxml;
    fastcgi_pass   127.0.0.1:9000;
    #fastcgi_index  index.php;
    fastcgi_param  SCRIPT_FILENAME  /home/pluxml/pluxml$fastcgi_script_name;
    include        fastcgi_params;
}

This section makes nginx catch each url finishing by .php and pass it through localhost on port 9000. Fastcgi catch the request and executes it.

You may have to configure your root pattern in order to allow index.php (put it on first position) :

 location / {
root /home/pluxml/pluxml;
index index.php index.html index.htm ;
}

To test that nginx passes php requests,you can create a phpinfo file at the root define above in nginx config file.

$ cd /home/pluxml/pluxml;
$ touch info.php
$ echo "" >> info.php

Finally, launchFastcgi on port 9000, and tell it to interpret request with Php :

sudo /usr/bin/spawn-fcgi -a 127.0.0.1 -p 9000 -u nginx -g nginx \
-f /usr/bin/php-cgi -P /var/run/fastcgi-php.pid
sudo /etc/init.d/nginx start
firefox http://127.0.0.1/info.php

Setting up PluXML on Nginx

In fact, setting up PluXML has already been done on previous sections. I bound root path to /home/pluxml/pluxml where stands the portableCMS PluXML.

Trying to access the CMS worked partially at the beginning. I had access to main page, but I hadn’t possiblity to  connect as administrator. Checking the nginx logs (/var/log/nginx/{access,error}.log, I got :

 ==> error.log <==
2009/11/20 23:39:43 [error] 20095#0: *14 FastCGI sent in stderr: « PHP Warning: session_start(): open(/var/lib/php/session/sess_ltpcad68h2k2qis4eujs29hrh1, O_RDWR) failed: Permission denied (13) in /home/gabriel/Bureau/downloads/pluxml/core/admin/prepend.php on line 42 » while reading response header from upstream, client: 127.0.0.1, server: _, request: « GET /core/admin/auth.php?p=/core/admin/ HTTP/1.1 », upstream: « fastcgi://127.0.0.1:9000 », host: « localhost », referrer: « http://localhost/core/admin/auth.php?p=/core/admin/ »
$ ls -l /var/lib/php
total 4,0K
drwxrwx---. 2 root apache 4,0K nov. 20 23:45 session

To put it on a nutshell, there was rights problems. I checked /var/lib/php, and problem was php folders belongs to root and to apache’s group when I installed it (I assume most of the time php is configured with apache). To not break this default behavior; I added the user nginx to group apache : 

 sudo usermod -a -G apache nginx

Restarting php, and nginx

Sometimes, you change nginx configuration, or want to restart php, etc.
What I do is :

# killall php-cgi
# /etc/init.d/nginx restart
# /usr/bin/spawn-fcgi -a 127.0.0.1 -p 9000 -u nginx -g nginx \
            -f /usr/bin/php-cgi -P /var/run/fastcgi-php.pid

Conclusion

I hope I introduced you basically steps to set up fast-cgi and php. Nginx was just to show how to configure it and highlight the syntax 😉

As PluXML is a portable CMS, you can move it and launch it wherever you want – just need a light web server configured with Php :

 

 

Resources :

  • http://www.howtoforge.org/installing-nginx-with-php5-and-mysql-support-on-fedora-11 (but we wont install php5)
  • http://wiki.nginx.org/Main
  • http://blog.codefront.net/2007/06/11/nginx-php-and-a-php-fastcgi-daemon-init-script/

Edit : To let you know how to use PluXML, I can link you to a blog entry :

  • http://colibri.servhome.org/pluxml-un-blogsite-sans-mysql-grace-au-xml.html

{jcomments on}

Laisser un commentaire

Votre adresse de messagerie ne sera pas publiée. Les champs obligatoires sont indiqués avec *