Sample Header Ad - 728x90

goaccess won't run when called from CGI script

1 vote
1 answer
767 views
I'm trying to make a CGI script (for nginx) that outputs an html page containing the usage statistics for my server. I'm using goaccess 0.7.1 and CentOS 5 x86. I've configured nginx to run my bash script (stats.sh) for requests on port 8080. The bash script looks like this: #!/bin/bash cat /var/log/nginx/mydomain.access.log | goaccess -a > stats.html echo Content-Type: text/html echo Content-Length: $(stat -c%s stats.html) echo cat stats.html When I run ./stats.sh, everything works fine. It prints a bunch of html code in the console window, and if I open stats.html, I see a bunch of html code. **THE PROBLEM IS**, when I try to access http://www.mydomain.com:8080/ , I just get a blank page. Now when I open stats.html on the server, it's completely empty. I've confirmed the following permissions: - stats.sh: -rwxr-xr-x - stats.html: -rw-rw-rw- - goaccess: -rwxr-xr-x I also know that CGI is working properly because if I modify stats.sh to only output the contents of stats.html (without writing to the file), it works fine when I hit http://www.mydomain.com:8080/ ; it just sends whatever data was in stats.html from before. So something is going wrong with calling goaccess in a CGI script. Does anyone know why? **UPDATE** I also tried this: echo "TEST" > stats.html and it works fine when I hit http://www.mydomain.com:8080/ , so something is going wrong when running goaccess from FastCGI. I also tried specifying the full path to goaccess (/usr/local/bin/goaccess): /var/log/nginx/mydomain.access.log | /usr/local/bin/goaccess -a >stats.html 2>stats.err but this also did not work.
Asked by AJ Richardson (121 rep)
Aug 8, 2014, 12:30 AM
Last activity: Sep 4, 2014, 07:18 PM