Translations of this page?:

DokuWiki with nginx on Windows

Dokuwiki has been extracted to E:\www\dokuwiki.

This is an example for dokuwiki entry in nginx.conf running on Windows:

location ~ ^/dokuwiki/.*\.php {
    root           E:/www;	         
    fastcgi_pass   127.0.0.1:9000;
    fastcgi_param  SCRIPT_FILENAME    E:/www$fastcgi_script_name;
    fastcgi_param  QUERY_STRING       $query_string;
    include        fastcgi_params;
}
# serve static files
location ~ ^/dokuwiki/lib/  {
    root         E:/www;		
    expires 30d;
}
 
location ~ ^/dokuwiki/conf/ { deny all; }
location ~ ^/dokuwiki/data/ { deny all; }
location ~ /\.ht            { deny all; }

FastCGI and nginx have been started using this batch file:

ECHO Starting PHP FastCGI...
RunHiddenConsole.exe E:\appl\php-5.2.9-2-Win32\php-cgi.exe -b 127.0.0.1:9000
ECHO Starting nginx...
cd /d D:\nginx-0.8.39 && start nginx.exe

DokuWiki with nginx on Ubuntu Linux

This configuration was tested on Ubuntu 10.04. It uses Upstart to start fastcgi. Make sure the following packages are installed:

  • nginx
  • php5-cgi

Edit /etc/nginx/nginx.conf:

user www-data www-data;
#(...)
 
http {
  #(...)
 
  server{
    #listen 80;
    index index.html index.php doku.php;
    #make sure a global root is defined here
    #(...)
 
    location ~ ^/dokuwiki/.*\.php {
      root           /usr/share/dokuwiki    #adapt if needed     
      include        fastcgi_params;
      fastcgi_pass   unix:/tmp/php-fastcgi.socket;
      fastcgi_param  SCRIPT_FILENAME $document_root$fastcgi_script_name;
    }
 
    # serve static files
    location ~ ^/dokuwiki/lib/  {
      root         /usr/share/dokuwiki/lib   #adapt if needed
      expires 30d;
    }
 
    location ~ ^/dokuwiki/conf/ { deny all; }
    location ~ ^/dokuwiki/data/ { deny all; }
    location ~ /\.ht            { deny all; }
  }
}

To launch fastcgi, we create the file php-fastcgi.conf (sudo gedit /etc/init/php-fastcgi.conf) with the following content:

description "php-fastcgi - keep up php-fastcgi"
start on runlevel [2345]
stop on runlevel [!2345]
respawn
exec /usr/bin/sudo -u www-data PHP_FCGI_CHILDREN=2 PHP_FCGI_MAX_REQUESTS=125 /usr/bin/php-cgi -q -b /tmp/php-fastcgi.socket

We can either reboot (→fastcgi and nginx should run automatically), or use the following commands for manual testing:

  • Start fastcgi: sudo /sbin/start php-fastcgi
  • Check fastcgi status: sudo /sbin/status php-fastcgi
  • Restart fastcgi: pgrep php-cgi;echo;sudo pkill php-cgi;sleep 1; pgrep php-cgi
  • Restart nginx: sudo /etc/init.d/nginx restart

Note: If you see the error “No input file specified”, this may be a permissions issue. Make sure fastcgi and nginx run as the same user (above: www-data). Make sure file permissions are OK.

install/nginx.txt · Last modified: 2011/07/18 00:04 by 46.12.39.30
 
Except where otherwise noted, content on this wiki is licensed under the following license: CC Attribution-Share Alike 3.0 Unported
Imprint Recent changes RSS feed Donate Powered by PHP Valid XHTML 1.0 Valid CSS Driven by DokuWiki
WikiForumIRCBugsGitXRefTranslate