{"id":96,"date":"2009-12-02T23:00:00","date_gmt":"2009-12-02T22:00:00","guid":{"rendered":"http:\/\/46.105.150.90\/tstnunix\/?p=96"},"modified":"2009-12-02T23:00:00","modified_gmt":"2009-12-02T22:00:00","slug":"setting-up-pluxml-with-nginx","status":"publish","type":"post","link":"https:\/\/nunix.fr\/?p=96","title":{"rendered":"Setting up PluXML with Nginx"},"content":{"rendered":"<p>Hi, today, we are going to see powerfull web servers &#8211; nginx &#8211; and portable cms &#8211; PluXML written in Php.<\/p>\n<p>\u00a0The goal is to set up the all solution under fedora 12 and make it works in local.\u00a0<\/p>\n<p>\u00a0Let&rsquo;s start with most important steps and resources that allowed me to set up everything in quiet short time :<\/p>\n<ul>\n<li><a href=\"http:\/\/wiki.pluxml.org\/?page=Installer%20Pluxml#Installer\">PluXML<\/a> : Download the latest archive and extract it wherever you want on your drive<\/li>\n<li><a href=\"http:\/\/wiki.nginx.org\/Main\">NGinx<\/a> : Downlad and build-it up, or install it through your favorite package-manager (i.e yum install nginx) <\/li>\n<li>Install Php and FastCGI in your system,for example under fedora : yum install lighttpd-fastcgi php php-gd<\/li>\n<\/ul>\n<p> <!--more--> <\/p>\n<h1>Setting up Nginx<\/h1>\n<p>\u00a0For nginx, the only thing to do is to start it :\u00a0<\/p>\n<blockquote>\n<pre>\/etc\/init.d\/nginx start <\/pre>\n<\/blockquote>\n<h1>Setting up Php and FastCGI to work with Nginx<br \/><\/h1>\n<p>\u00a0Once 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. <\/p>\n<blockquote>\n<pre># pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000<br \/>#<br \/>location ~ \\.php$ {<br \/>#\u00a0\u00a0\u00a0 root\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 html;<br \/>\u00a0\u00a0\u00a0 root <font color=\"#ff0000\">\/home\/pluxml\/pluxml;<\/font><br \/>\u00a0\u00a0\u00a0 fastcgi_pass\u00a0\u00a0 <font color=\"#ff0000\">127.0.0.1:9000;<\/font><br \/>\u00a0\u00a0\u00a0 #fastcgi_index\u00a0 index.php;<br \/>\u00a0\u00a0\u00a0 fastcgi_param\u00a0 <font color=\"#ff0000\">SCRIPT_FILENAME\u00a0 \/home\/pluxml\/pluxml$fastcgi_script_name;<\/font><br \/>\u00a0\u00a0\u00a0 include\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 fastcgi_params;<br \/>}<br \/><\/pre>\n<\/blockquote>\n<p>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. <\/p>\n<p>You may have to configure your root pattern in order to allow index.php (put it on first position) :<\/p>\n<blockquote>\n<pre>\u00a0location \/ {<br \/>  root \/home\/pluxml\/pluxml;<br \/>  index <font color=\"#ff0000\"> index.php<\/font> index.html index.htm ;<br \/>}<\/pre>\n<\/blockquote>\n<p>To test that nginx passes php requests,you can create a phpinfo file at the root define above in nginx config file.<\/p>\n<blockquote>\n<pre>$ cd \/home\/pluxml\/pluxml;<br \/>$ touch info.php<br \/>$ echo \"\" >> info.php<\/pre>\n<\/blockquote>\n<p>Finally, launchFastcgi on port 9000, and tell it to interpret request with Php : <\/p>\n<blockquote>\n<pre>sudo \/usr\/bin\/spawn-fcgi -a 127.0.0.1 -p 9000 -u nginx -g nginx \\<br \/>\t\t\t-f \/usr\/bin\/php-cgi -P \/var\/run\/fastcgi-php.pid<br \/>sudo \/etc\/init.d\/nginx start<br \/>firefox http:\/\/127.0.0.1\/info.php<\/pre>\n<\/blockquote>\n<h1>Setting up PluXML on Nginx<br \/><\/h1>\n<p>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.<\/p>\n<p>Trying to access the CMS worked partially at the beginning. I had access to main page, but I hadn&rsquo;t possiblity to\u00a0 connect as administrator. Checking the nginx logs (\/var\/log\/nginx\/{access,error}.log, I got : <\/p>\n<blockquote>\n<address>\u00a0==> error.log <==<\/address>\n<address>2009\/11\/20 23:39:43 [error] 20095#0: *14 FastCGI sent in stderr: \u00ab\u00a0PHP 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\u00a0\u00bb while reading response header from upstream, client: 127.0.0.1, server: _, request: \u00ab\u00a0GET \/core\/admin\/auth.php?p=\/core\/admin\/ HTTP\/1.1\u00a0\u00bb, upstream: \u00ab\u00a0fastcgi:\/\/127.0.0.1:9000\u00a0\u00bb, host: \u00ab\u00a0localhost\u00a0\u00bb, referrer: \u00ab\u00a0http:\/\/localhost\/core\/admin\/auth.php?p=\/core\/admin\/\u00a0\u00bb <br \/><\/address>\n<\/blockquote>\n<blockquote>\n<pre>$ ls -l \/var\/lib\/php<br \/>total 4,0K<br \/>drwxrwx---. 2 root apache 4,0K nov.  20 23:45 session<\/pre>\n<\/blockquote>\n<p>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&rsquo;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 :\u00a0 <\/p>\n<blockquote>\n<pre>\u00a0sudo usermod -a -G apache nginx<\/pre>\n<\/blockquote>\n<h1>Restarting php, and nginx<\/h1>\n<p>Sometimes, you change nginx configuration, or want to restart php, etc. <br \/>What I do is :<\/p>\n<blockquote>\n<pre># killall php-cgi<br \/># \/etc\/init.d\/nginx restart<br \/># \/usr\/bin\/spawn-fcgi -a 127.0.0.1 -p 9000 -u nginx -g nginx \\<br \/>\u00a0\u00a0 \u00a0\u00a0\u00a0 \u00a0\u00a0\u00a0 \u00a0-f \/usr\/bin\/php-cgi -P \/var\/run\/fastcgi-php.pid<\/pre>\n<\/blockquote>\n<h1>Conclusion <\/h1>\n<p>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 \ud83d\ude09 <\/p>\n<p>As PluXML is a portable CMS, you can move it and launch it wherever you want &#8211; just need a light web server configured with Php :<\/p>\n<p>\u00a0<\/p>\n<div style=\"text-align: center\"><img loading=\"lazy\" decoding=\"async\" class=\"caption size-full wp-image-95\" src=\"http:\/\/46.105.150.90\/tstnunix\/wp-content\/uploads\/2009\/12\/pluxml_picture.png\" border=\"0\" title=\"PluXML main page\" width=\"322\" height=\"150\" srcset=\"https:\/\/nunix.fr\/wp-content\/uploads\/2009\/12\/pluxml_picture.png 600w, https:\/\/nunix.fr\/wp-content\/uploads\/2009\/12\/pluxml_picture-300x140.png 300w\" sizes=\"auto, (max-width: 322px) 85vw, 322px\" \/><\/div>\n<p><\/p>\n<p>\u00a0<\/p>\n<p>Resources :<\/p>\n<ul>\n<li>http:\/\/www.howtoforge.org\/installing-nginx-with-php5-and-mysql-support-on-fedora-11 (but we wont install php5) <\/li>\n<li>http:\/\/wiki.nginx.org\/Main<\/li>\n<li>http:\/\/blog.codefront.net\/2007\/06\/11\/nginx-php-and-a-php-fastcgi-daemon-init-script\/<\/li>\n<\/ul>\n<p>Edit : To let you know how to use PluXML, I can link you to a blog entry :<\/p>\n<ul>\n<li>http:\/\/colibri.servhome.org\/pluxml-un-blogsite-sans-mysql-grace-au-xml.html<\/li>\n<\/ul>\n<p>{jcomments on}<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Hi, today, we are going to see powerfull web servers &#8211; nginx &#8211; and portable cms &#8211; PluXML written in Php. \u00a0The goal is to set up the all solution under fedora 12 and make it works in local.\u00a0 \u00a0Let&rsquo;s start with most important steps and resources that allowed me to set up everything in &hellip; <a href=\"https:\/\/nunix.fr\/?p=96\" class=\"more-link\">Continuer la lecture<span class=\"screen-reader-text\"> de &laquo;&nbsp;Setting up PluXML with Nginx&nbsp;&raquo;<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":95,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[15],"tags":[],"class_list":["post-96","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-astuces"],"_links":{"self":[{"href":"https:\/\/nunix.fr\/index.php?rest_route=\/wp\/v2\/posts\/96","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/nunix.fr\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/nunix.fr\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/nunix.fr\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/nunix.fr\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=96"}],"version-history":[{"count":0,"href":"https:\/\/nunix.fr\/index.php?rest_route=\/wp\/v2\/posts\/96\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/nunix.fr\/index.php?rest_route=\/wp\/v2\/media\/95"}],"wp:attachment":[{"href":"https:\/\/nunix.fr\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=96"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/nunix.fr\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=96"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/nunix.fr\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=96"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}