# Awstats and NGinX

**URL:** <https://www.ruby-forum.com/t/awstats-and-nginx/215268>\
**Category:** NGINX\
**Created:** [December 28, 2011, 8:58pm UTC](https://www.ruby-forum.com/t/awstats-and-nginx/215268 "2011-12-28T20:58:53Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![dubstep](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/cdc98d/32.png) [@dubstep](https://www.ruby-forum.com/u/dubstep)\
**Post date:** [December 28, 2011, 8:58pm UTC](https://www.ruby-forum.com/t/awstats-and-nginx/215268/1 "2011-12-28T20:58:53Z")

</div>

Hi All,  
I have recently set-up a new LEMP on Ubuntu 11.10 (64-bit), it is a  
pretty simple set-up and all is running fine. That is until I try to  
get Awstats working. I have diligently followed the Awstats set up  
outlined at

> **[Expedited Security: Straightforward Cloud Services to Protect Your Sites](https://expeditedsecurity.com)**
>
> Expedited Security provides straightforward security services for Heroku, AWS and Google Cloud

However, when I enter the URL in a browser I get page not found (404  
error).  
This is the URL I am entering

[http://mydomain.com/cgi-bin/awstats.pl](http://mydomain.com/cgi-bin/awstats.pl)

I have been working at this for a few days now, but being totally new to  
Linux…I’m afraid that I don’t know enough to ask the right questions  
(or intelligent questions).

Incidently I am having the exact same 404 message when trying to enter  
the URL for phpMyAdmin…

Can someone please take the time to help me out??

Posted at Nginx Forum:

> **[Awstats and NGinX](https://forum.nginx.org/read.php?2,220628,220628#msg-220628)**
>
> Hi All, I have recently set-up a new LEMP on Ubuntu 11.10 (64-bit), it is a pretty simple set-up and all is running fine. That is until I try to get Awstats working. I have diligently followed the Awstats set up outlined at...

---

<div class="post-metadata">

**Author:** ![deneb](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/f4b2a3/32.png) [@deneb](https://www.ruby-forum.com/u/deneb)\
**Post date:** [December 28, 2011, 10:16pm UTC](https://www.ruby-forum.com/t/awstats-and-nginx/215268/2 "2011-12-28T22:16:51Z")

</div>

Hi,

On 28-12-2011 20:58, DeneB wrote:

> Hi All,  
> I have recently set-up a new LEMP on Ubuntu 11.10 (64-bit), it is a  
> pretty simple set-up and all is running fine. That is until I try to  
> get Awstats working. I have diligently followed the Awstats set up  
> outlined at

[http://blog.rubynginx.com/index.php/2010\_01\_25/setup-awstats-phpmyadmin-phppgadmin-with-nginx-on-ubuntu/](http://blog.rubynginx.com/index.php/2010_01_25/setup-awstats-phpmyadmin-phppgadmin-with-nginx-on-ubuntu/)

[snipp]

> Incidently I am having the exact same 404 message when trying to  
> enter  
> the URL for phpMyAdmin…

What’s in your nginx and php error log?  
Please can you add a nginx debug output.

> **[A debugging log](http://nginx.org/en/docs/debugging_log.html)**

BR  
Aleks

---

<div class="post-metadata">

**Author:** ![deneb](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/f4b2a3/32.png) [@deneb](https://www.ruby-forum.com/u/deneb)\
**Post date:** [December 29, 2011, 2:05am UTC](https://www.ruby-forum.com/t/awstats-and-nginx/215268/3 "2011-12-29T02:05:17Z")

</div>

Aleks Thanks for replying…

I am looking at the error log and it is blank, let me check to see the  
problem with the log.

I will get back to you on this and then try to config the debug output.

Posted at Nginx Forum:

> **[Re: Awstats and NGinX](https://forum.nginx.org/read.php?2,220628,220637#msg-220637)**
>
> Hi All, I have recently set-up a new LEMP on Ubuntu 11.10 (64-bit), it is a pretty simple set-up and all is running fine. That is until I try to get Awstats working. I have diligently followed the Awstats set up outlined at...

---

<div class="post-metadata">

**Author:** ![deneb](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/f4b2a3/32.png) [@deneb](https://www.ruby-forum.com/u/deneb)\
**Post date:** [December 29, 2011, 2:40am UTC](https://www.ruby-forum.com/t/awstats-and-nginx/215268/4 "2011-12-29T02:40:29Z")

</div>

On 29 Dez 2011 01h27 WET, [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> reading response header from upstream, client: 11.11.1.111, server:  
> [mydomain.com](http://mydomain.com), request: “GET /cgi-bin/awstats.pl HTTP/1.1”, upstream:  
> “fastcgi://127.0.0.1:49232”, host: “[mydomain.com](http://mydomain.com)”

It seems that there are a few fastcgi parameters that are undefined.

I’ve never used awstats with Nginx, but here’s a previous thread that  
might be of use to you:

[http://forum.nginx.org/read.php?2,219151,219162#msg-219162](http://forum.nginx.org/read.php?2,219151,219162#msg-219162)

— appa

---

<div class="post-metadata">

**Author:** ![deneb](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/f4b2a3/32.png) [@deneb](https://www.ruby-forum.com/u/deneb)\
**Post date:** [December 29, 2011, 2:28am UTC](https://www.ruby-forum.com/t/awstats-and-nginx/215268/5 "2011-12-29T02:28:05Z")

</div>

BINGO! Got the error.log working and I found something! (But don’t  
know how to fix it)

This is what I found…

2011/12/28 20:20:51 [error] 19200#0: \*9 FastCGI sent in stderr: “PHP  
Notice: Undefined index: X\_SCRIPT\_FILENAME in /etc/nginx/cgi-bin.php on  
line 9  
PHP Notice: Undefined index: X\_SCRIPT\_NAME in /etc/nginx/cgi-bin.php on  
line 10  
PHP Notice: Undefined index: X\_SCRIPT\_FILENAME in  
/etc/nginx/cgi-bin.php on line 12” while reading response header from  
upstream, client: 11.11.1.111, server: [mydomain.com](http://mydomain.com), request: “GET  
/cgi-bin/awstats.pl HTTP/1.1”, upstream: “fastcgi://127.0.0.1:49232”,  
host: “[mydomain.com](http://mydomain.com)”

Posted at Nginx Forum:

> **[Re: Awstats and NGinX](https://forum.nginx.org/read.php?2,220628,220638#msg-220638)**
>
> Hi All, I have recently set-up a new LEMP on Ubuntu 11.10 (64-bit), it is a pretty simple set-up and all is running fine. That is until I try to get Awstats working. I have diligently followed the Awstats set up outlined at...

---

<div class="post-metadata">

**Author:** ![deneb](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/f4b2a3/32.png) [@deneb](https://www.ruby-forum.com/u/deneb)\
**Post date:** [December 29, 2011, 3:11am UTC](https://www.ruby-forum.com/t/awstats-and-nginx/215268/6 "2011-12-29T03:11:57Z")

</div>

Finally!!! I have Awstats working!!!

The undefined fastcgi parameter is a result of using ENV in the  
cgi-bin.php So I replaced ENV with SERVER and it works!!! So with  
Ubuntu 11.10 (64-bit), Awstats, and Nginx 1.05 the cgi-bin.php looks  
like this (where it now reads $\_SERVER…it used to read $ENV):

\<?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"); } ?\>

Posted at Nginx Forum:

> **[Re: Awstats and NGinX](https://forum.nginx.org/read.php?2,220628,220641#msg-220641)**
>
> Hi All, I have recently set-up a new LEMP on Ubuntu 11.10 (64-bit), it is a pretty simple set-up and all is running fine. That is until I try to get Awstats working. I have diligently followed the Awstats set up outlined at...

---

<div class="post-metadata">

**Author:** ![deneb](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/f4b2a3/32.png) [@deneb](https://www.ruby-forum.com/u/deneb)\
**Post date:** [December 29, 2011, 3:21am UTC](https://www.ruby-forum.com/t/awstats-and-nginx/215268/7 "2011-12-29T03:21:52Z")

</div>

Antonio Thanks for your help too! Sorry I thought all the replies were  
Alek…

Thank-you all!

Posted at Nginx Forum:

> **[Re: Awstats and NGinX](https://forum.nginx.org/read.php?2,220628,220643#msg-220643)**
>
> Hi All, I have recently set-up a new LEMP on Ubuntu 11.10 (64-bit), it is a pretty simple set-up and all is running fine. That is until I try to get Awstats working. I have diligently followed the Awstats set up outlined at...

---

<div class="post-metadata">

**Author:** ![deneb](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/f4b2a3/32.png) [@deneb](https://www.ruby-forum.com/u/deneb)\
**Post date:** [December 29, 2011, 2:49am UTC](https://www.ruby-forum.com/t/awstats-and-nginx/215268/8 "2011-12-29T02:49:06Z")

</div>

Alek, Thanks for your help…I haven’t fixed the problem but your  
input has highlighted the problem. Now I understand where this is  
happening (in the fastcgi parameters) and in what file. If I can  
discover why it is undefined then it looks like I’ll have the problem  
fixed.

Another note: I think the debug output is on because when I stop nginx  
and start again…I have no errors, but before if I had an eror in my  
syntex it would tell me what and where.

I’ll read up on the link you gave me, and post my results when I get the  
problem fixed.

Thanks again for your help.

Posted at Nginx Forum:

> **[Re: Awstats and NGinX](https://forum.nginx.org/read.php?2,220628,220640#msg-220640)**
>
> Hi All, I have recently set-up a new LEMP on Ubuntu 11.10 (64-bit), it is a pretty simple set-up and all is running fine. That is until I try to get Awstats working. I have diligently followed the Awstats set up outlined at...
