Skip to content

Instantly share code, notes, and snippets.

@sergeifilippov
Created February 10, 2014 03:22
Show Gist options
  • Star 30 You must be signed in to star a gist
  • Fork 8 You must be signed in to fork a gist
  • Save sergeifilippov/8909839 to your computer and use it in GitHub Desktop.
Save sergeifilippov/8909839 to your computer and use it in GitHub Desktop.
linux-dash with nginx
server {
server_name $domain_name;
root /var/www;
index index.html index.php;
access_log /var/log/nginx/access.log;
error_log /var/log/nginx/error.log;
# Cache static files for as long as possible
location ~* \.(?:xml|ogg|mp3|mp4|ogv|svg|svgz|eot|otf|woff|ttf|css|js|jpg|jpeg|gif|png|ico)$ {
try_files $uri =404;
expires max;
access_log off;
add_header Pragma public;
add_header Cache-Control "public, must-revalidate, proxy-revalidate";
}
# if hosting in a sub folder, setup a new location
# replace `/linus-dash` with the folder name eg. `/folder_name`
#location /linux-dash {
# index index.html index.php;
#}
# Pass PHP requests on to PHP-FPM using sockets
location ~ \.php(/|$) {
fastcgi_split_path_info ^(.+?\.php)(/.*)$;
fastcgi_pass unix:/run/php5-fpm.sock;
# fastcgi_pass localhost:9000; # using TCP/IP stack
if (!-f $document_root$fastcgi_script_name) {
return 404;
}
try_files $uri $uri/ /index.php?$args;
include fastcgi_params;
}
}
## Dependecies
+ nginx
+ php-fpm
+ php5-curl
1. Install `php-fpm` and configura to use either `sockets` or `TCP/IP`
2. Create a nginx configuration (`eg. domain_name.conf`) in `/etc/nginx/conf.d/`
@shahamit
Copy link

I installed php-json and php-fpm and configured it to use TCP-IP settings as specified in this tutorial - https://rtcamp.com/tutorials/php/fpm-sysctl-tweaking. The dashboard does not come up after those changes.

Nginx access logs show that the php requests return with 200.

Anything I have missed?

@4exob
Copy link

4exob commented Jul 14, 2014

dashboard empty
Archlinux x64, nginx+php-fpm


what am I doing wrong...

@poontrip
Copy link

Bump, I have the same problem as 4exob

@jkbmaj
Copy link

jkbmaj commented Sep 7, 2014

Add this line before try_files:
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;

@lengers
Copy link

lengers commented Nov 2, 2014

I have the same problem as 4exob and poontrip, but adding
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
before try_files doesn't fix it.
What else can I do to get this running?

@TMadMac
Copy link

TMadMac commented Dec 10, 2014

Here is a configuration I successfully use for a debian wheezy (not optimized at all but will run). Ask your server for port 8081.

System setup
apt-get install php5-common php5-fpm php5-curl nginx 
git clone https://github.com/afaqurk/linux-dash.git /opt
chown -R www-data:www-data /opt/linux-dash
/etc/php5/fpm/pool.d/www.conf

Ensure to have listen = /var/run/php5-fpm.sock and listen.mode = 0660

/etc/nginx/sites-available/linux-dash
upstream php5-fpm-sock {
        server unix:/var/run/php5-fpm.sock;
}

server {
        # server_name   $domain_name;
        listen  8081;

        root    /opt/linux-dash;
        index   index.html module.php;
        access_log      /var/log/nginx/linux-dash-access.log;
        error_log       /var/log/nginx/linux-dash-error.log;

        # Pass PHP requests on to PHP-FPM using sockets
        location ~ \.php(/|$) {
                try_files $uri =404;
                fastcgi_pass php5-fpm-sock;
                fastcgi_index   module.php;
                fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
                include fastcgi_params;
        }
}

All start up

ln -s /etc/nginx/sites-available/linux-dash /etc/nginx/sites-enabled/linux-dash
service nginx reload

@HaoZeke
Copy link

HaoZeke commented Feb 3, 2015

Still no data shown. All blank

@yonjah
Copy link

yonjah commented Feb 5, 2015

Here are the nginx.conf for php settings that worked for me -

location ~ \.php(/|$) { 
        fastcgi_split_path_info ^(.+?\.php)(/.*)$;
        fastcgi_pass unix:/run/php-fpm/dash.socket;
        # fastcgi_pass   localhost:9000; # using TCP/IP stack
        if (!-f $document_root$fastcgi_script_name) {
                return 404;
        }
        try_files $uri $uri/ /index.php?$args;
        fastcgi_param  SCRIPT_FILENAME  $document_root$fastcgi_script_name;
        include fastcgi_params;
}

I got a blank page until I added the line

fastcgi_param  SCRIPT_FILENAME  $document_root$fastcgi_script_name;

FPM settings /etc/php-fpm.d/dash.conf -

[dash]
listen = /run/php-fpm/dash.socket
listen.backlog = -1
listen.owner = nginx
listen.group = nginx
listen.mode=0660
access.log = /var/log/php-fpm/dash.access.log
access.format = "%t \"%m %r%Q%q\" %s %{mili}dms %{kilo}Mkb %C%%"

; Unix user/group of processes
user = nginx
group = nginx

; Choose how the process manager will control the number of child processes.
pm = dynamic
pm.max_children = 75
pm.start_servers = 10
pm.min_spare_servers = 5
pm.max_spare_servers = 20
pm.max_requests = 500

; Pass environment variables
env[HOSTNAME] = $HOSTNAME
env[PATH] = /usr/local/bin:/usr/bin:/bin
env[TMP] = /tmp
env[TMPDIR] = /tmp
env[TEMP] = /tmp

; host-specific php ini settings here
; php_admin_value[open_basedir] = /var/www/DOMAINNAME/htdocs:/tmp

I also changed php settings to display errors since I tried to figure whats wrong, you can probably don't need this but if nothing works it might be useful
in /etc/php.ini

error_reporting = E_ALL
display_errors = On
date.timezone = "Antarctica/South_Pole"

I also changed the timezone since not setting it will throw some errors that will mess up some of the widgets (but if everything else is Ok most of them will work).

If you follow this settings above you should have a few logs running (for fpm / nginx ) so if nothing works try to see if there is any useful information in the logs.

@derekslenk
Copy link

Has anyone tried to get this to work with the new setup? I can't seem to give it access to the modules directory...

@KelvinVenancio
Copy link

My config:

upstream php5-fpm-sock {
        server unix:/var/run/php5-fpm.sock;
}

server {
        server_name   dash.domain.com;
        listen  80;

        root    /usr/share/nginx/html/linux-dash;
        index   index.php index.html module.php;
        access_log      /var/log/nginx/linux-dash-access.log;
        error_log       /var/log/nginx/linux-dash-error.log;


    location ~ \.php$ {
     try_files $uri =404;
         root           /usr/share/nginx/html/linux-dash;
         fastcgi_pass   unix:/var/run/php-fpm/php-fpm.sock;
         fastcgi_index  index.php;
     fastcgi_param  SCRIPT_FILENAME $document_root$fastcgi_script_name;
         include        fastcgi_params;
    }
}

Works fine!

@Obi8
Copy link

Obi8 commented Apr 12, 2016

How can i enable

-exec
-shell_exec
-escapeshellarg

for linux-dash?

@455412013
Copy link

How can i enable

-exec
-shell_exec
-escapeshellarg

for linux-dash?

first: vim /usr/local/php/etc/php.ini
second: find this word disable_functions

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment