# Perl - awstats.pl config

**URL:** <https://www.ruby-forum.com/t/perl-awstats-pl-config/214298>\
**Category:** NGINX\
**Created:** [November 27, 2011, 8:00pm UTC](https://www.ruby-forum.com/t/perl-awstats-pl-config/214298 "2011-11-27T20:00:13Z")\
**Posts on this page:** 5\
**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:** [November 27, 2011, 8:00pm UTC](https://www.ruby-forum.com/t/perl-awstats-pl-config/214298/1 "2011-11-27T20:00:13Z")

</div>

Hello,

i try to implement a awstats.pl for every vhost on my nginx  
installation.

I tried it the following:

location ~ ^/awstats/ {  
gzip off;  
include /etc/nginx/fastcgi\_params;  
fastcgi\_pass unix:/var/run/fcgiwrap.socket;  
fastcgi\_param SCRIPT\_FILENAME /usr/lib/cgi-bin/awstats.pl;  
}

I think i’m to stupid for the location part, it works fine with .pl$  
but not with a path, it would be nice to could configure a “directoy”  
like /awstats/ in every vhost and then runs the awstats.pl through the  
socket (socket is working), but not the SCRIPT\_FILENAME-part.

I only found documentions with a php-application who runs the  
perl-file.

Thanks 😕

Posted at Nginx Forum:

> **[Perl - awstats.pl config](https://forum.nginx.org/read.php?2,219151,219151#msg-219151)**
>
> Hello, i try to implement a awstats.pl for every vhost on my nginx installation. I tried it the following: location ~ ^/awstats/ { gzip off; include /etc/nginx/fastcgi\_params; fastcgi\_pass unix:/var/run/fcgiwrap.socket;

---

<div class="post-metadata">

**Author:** ![Veerle](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/v/c89c15/32.png) [@Veerle](https://www.ruby-forum.com/u/Veerle)\
**Post date:** [November 27, 2011, 8:07pm UTC](https://www.ruby-forum.com/t/perl-awstats-pl-config/214298/2 "2011-11-27T20:07:42Z")

</div>

On 27 Nov 2011 18h59 WET, [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> fastcgi\_pass unix:/var/run/fcgiwrap.socket;  
> perl-file.
> 
> Thanks 😕

Try:

location = /awstats.pl {  
root /usr/lib/cgi-bin;  
gzip off;  
include /etc/nginx/fastcgi\_params;  
fastcgi\_pass unix:/var/run/fcgiwrap.socket;  
# Not needed if already in fastcgi\_params.  
fastcgi\_param SCRIPT\_FILENAME $document\_root$fastcgi\_script\_name;  
}

— appa

---

<div class="post-metadata">

**Author:** ![Veerle](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/v/c89c15/32.png) [@Veerle](https://www.ruby-forum.com/u/Veerle)\
**Post date:** [November 27, 2011, 11:26pm UTC](https://www.ruby-forum.com/t/perl-awstats-pl-config/214298/3 "2011-11-27T23:26:26Z")

</div>

Thanks, works fine this way.

One question about the root-part.

Atm i have the root part inside the server {} like:  
server {  
…  
root /xxx/xxx/xxx/  
lcoation / {}  
}

But now i need to set the root inside the location, but it seems i can’t  
override it. Do i really need to remove the root-line from the main  
server-part and add it to every location?

Thanks

Posted at Nginx Forum:

> **[Re: Perl - awstats.pl config](https://forum.nginx.org/read.php?2,219151,219160#msg-219160)**
>
> Hello, i try to implement a awstats.pl for every vhost on my nginx installation. I tried it the following: location ~ ^/awstats/ { gzip off; include /etc/nginx/fastcgi\_params; fastcgi\_pass unix:/var/run/fcgiwrap.socket;

---

<div class="post-metadata">

**Author:** ![Veerle](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/v/c89c15/32.png) [@Veerle](https://www.ruby-forum.com/u/Veerle)\
**Post date:** [November 27, 2011, 11:38pm UTC](https://www.ruby-forum.com/t/perl-awstats-pl-config/214298/4 "2011-11-27T23:38:09Z")

</div>

Hello again, just tried something like that:

location = /cgi-bin/awstats.pl {  
root /usr/lib/cgi-bin;  
gzip off;  
include /etc/nginx/fastcgi\_params;  
fastcgi\_pass unix:/var/run/fcgiwrap.socket;  
fastcgi\_param SCRIPT\_FILENAME /usr/lib/cgi-bin/awstats.pl;  
}

But i only get a 403 as error.

Error message is:  
\*415 FastCGI sent in stderr: “Cannot get script name, is DOCUMENT\_ROOT  
and SCRIPT\_NAME set and is the script executable?” while reading  
response header from upstream, client: 80.24.x.x, server: test, request:  
“GET /cgi-bin/awstats.pl HTTP/1.1”, upstream:  
“fastcgi://unix:/var/run/fcgiwrap.socket:”,

And why is the root-part needed? SCRIPT\_FILENAME is not enough?

Thanks

Posted at Nginx Forum:

> **[Re: Perl - awstats.pl config](https://forum.nginx.org/read.php?2,219151,219161#msg-219161)**
>
> Hello, i try to implement a awstats.pl for every vhost on my nginx installation. I tried it the following: location ~ ^/awstats/ { gzip off; include /etc/nginx/fastcgi\_params; fastcgi\_pass unix:/var/run/fcgiwrap.socket;

---

<div class="post-metadata">

**Author:** ![Veerle](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/v/c89c15/32.png) [@Veerle](https://www.ruby-forum.com/u/Veerle)\
**Post date:** [November 27, 2011, 11:48pm UTC](https://www.ruby-forum.com/t/perl-awstats-pl-config/214298/5 "2011-11-27T23:48:39Z")

</div>

Hi Veerle.

I don’t know if this will help you, but I also run an awstats with  
nginx, and here is how I managed to make it work.

First, I made a symlink from /var/www/stats/awstats to /usr/lib/cgi-bin

Then, here is the configuration file (it’s a virtual host) :

server {

```
 listen 80;
 listen [::]:80;

 server_name stats.yourwebsite.tld;

 access_log /var/log/nginx/stats.yourwebsite.tld.access.log 

```

combined;  
error\_log /var/log/nginx/stats.yourwebsite.tld.error.log;  
root /var/www/stats;

```
 location ^~ /awstats-icon {
         alias /usr/share/awstats/icon/;
         access_log off;
 }

 location ^~ /awstatscss {
         alias /usr/share/doc/awstats/examples/css/;
         access_log off;
 }

 location ^~ /awstatsclasses {
         alias /usr/share/doc/awstats/examples/classes/;
            access_log off;
 }

 location ~ ^/.*\.pl$ {
         gzip off;
     fastcgi_pass unix:/tmp/cgi.sock;
         fastcgi_index index.cgi;
         fastcgi_param SCRIPT_FILENAME

```

/var/www/stats$fastcgi\_script\_name;  
fastcgi\_param SCRIPT\_NAME $fastcgi\_script\_name;  
fastcgi\_param QUERY\_STRING $query\_string;  
fastcgi\_param REQUEST\_METHOD $request\_method;  
fastcgi\_param CONTENT\_TYPE $content\_type;  
fastcgi\_param CONTENT\_LENGTH $content\_length;  
fastcgi\_param GATEWAY\_INTERFACE CGI/1.1;  
fastcgi\_param SERVER\_SOFTWARE nginx;  
fastcgi\_param REQUEST\_URI $request\_uri;  
fastcgi\_param DOCUMENT\_URI $document\_uri;  
fastcgi\_param DOCUMENT\_ROOT $document\_root;  
fastcgi\_param SERVER\_PROTOCOL $server\_protocol;  
fastcgi\_param REMOTE\_ADDR $remote\_addr;  
fastcgi\_param REMOTE\_PORT $remote\_port;  
fastcgi\_param SERVER\_ADDR $server\_addr;  
fastcgi\_param SERVER\_PORT $server\_port;  
fastcgi\_param SERVER\_NAME $server\_name;  
fastcgi\_param REMOTE\_USER $remote\_user;  
}

}

Then, you will be able to access your awstats by  
[http://stats.yourwebsite.tld/awstats/awstats.pl](http://stats.yourwebsite.tld/awstats/awstats.pl)

And don’t hesitate to add authentication.

Thanks.

On 11/27/2011 11:37 PM, Veerle wrote:

> But i only get a 403 as error.  
> Thanks
> 
> Posted at Nginx Forum:  
> [http://forum.nginx.org/read.php?2,219151,219161#msg-219161](http://forum.nginx.org/read.php?2,219151,219161#msg-219161)
> 
> * * *
> 
> nginx mailing list  
> [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)  
> [mailman.nginx.org archive](http://mailman.nginx.org/mailman/listinfo/nginx)

–  
Cyril “Davromaniak” Lavier
