]> git.ipfire.org Git - thirdparty/AWStats.git/commitdiff
Add example of nginx setup
authoreldy <>
Wed, 16 Feb 2011 13:00:58 +0000 (13:00 +0000)
committereldy <>
Wed, 16 Feb 2011 13:00:58 +0000 (13:00 +0000)
tools/nginx/README.txt [new file with mode: 0755]
tools/nginx/awstats-fcgi.php [new file with mode: 0755]
tools/nginx/awstats-nginx.conf [new file with mode: 0755]

diff --git a/tools/nginx/README.txt b/tools/nginx/README.txt
new file mode 100755 (executable)
index 0000000..833ae40
--- /dev/null
@@ -0,0 +1,2 @@
+This directory contains samples files to setup a NGinx server to
+use AWStats with.
\ No newline at end of file
diff --git a/tools/nginx/awstats-fcgi.php b/tools/nginx/awstats-fcgi.php
new file mode 100755 (executable)
index 0000000..f14ade3
--- /dev/null
@@ -0,0 +1,37 @@
+<?php
+$descriptorspec = array(
+       0 => array('pipe', 'r'),  // stdin is a pipe that the child will read from
+       1 => array('pipe', 'w'),  // stdout is a pipe that the child will write to
+       2 => array('pipe', 'w')   // stderr is a file to write to
+);
+
+$newenv = $_SERVER;
+$newenv['SCRIPT_FILENAME'] = $_SERVER['X_SCRIPT_FILENAME'];
+$newenv['SCRIPT_NAME'] = $_SERVER['X_SCRIPT_NAME'];
+
+if (is_executable($_SERVER['X_SCRIPT_FILENAME'])) {
+       $process = proc_open($_SERVER['X_SCRIPT_FILENAME'], $descriptorspec, $pipes, NULL, $newenv);
+
+       if (is_resource($process)) {
+               fclose($pipes[0]);
+               $head = fgets($pipes[1]);
+
+               while (strcmp($head, "\n")) {
+                       header($head);
+                       $head = fgets($pipes[1]);
+               }
+
+               fpassthru($pipes[1]);
+               fclose($pipes[1]);
+               fclose($pipes[2]);
+
+               $return_value = proc_close($process);
+       } else {
+               header('Status: 500 Internal Server Error');
+               echo('Internal Server Error');
+       }
+} else {
+       header('Status: 404 Page Not Found');
+       echo('Page Not Found');
+}
+?>
\ No newline at end of file
diff --git a/tools/nginx/awstats-nginx.conf b/tools/nginx/awstats-nginx.conf
new file mode 100755 (executable)
index 0000000..1a47b25
--- /dev/null
@@ -0,0 +1,41 @@
+server {
+       listen 127.0.0.1:80;
+       server_name localhost;
+       access_log /var/log/nginx/localhost.access_log main;
+       error_log /var/log/nginx/localhost.error_log info;
+       root /var/www/localhost/htdocs;
+       index index.html;
+
+       # Restrict access
+       #auth_basic "Restricted";
+       #auth_basic_user_file /etc/awstats/htpasswd;
+
+
+       # Static awstats files: HTML files stored in DOCUMENT_ROOT/awstats/
+       location /awstats/classes/ {
+               alias /usr/share/awstats/wwwroot/classes/;
+       }
+
+       location /awstats/css/ {
+               alias /usr/share/awstats/wwwroot/css/;
+       }
+
+       location /awstats/icon/ {
+               alias /usr/share/awstats/wwwroot/icon/;
+       }
+
+       location /awstats/js/ {
+               alias /usr/share/awstats/wwwroot/js/;
+       }
+
+
+       # Dynamic stats.
+       location ~ ^/cgi-bin/(awredir|awstats)\.pl {
+               gzip off;
+               fastcgi_pass 127.0.0.1:9000;
+               fastcgi_param SCRIPT_FILENAME /usr/share/awstats/wwwroot/cgi-bin/fcgi.php;
+               fastcgi_param X_SCRIPT_FILENAME /usr/share/awstats/wwwroot$fastcgi_script_name;
+               fastcgi_param X_SCRIPT_NAME $fastcgi_script_name;
+               include fastcgi_params;
+       }
+}