(11-30-2019, 04:37 PM)TookaFace Wrote: Just a little how-to for running Pi-Hole with moOde on Nginx web server.
Works for moOde 6.4 and higher
- Install Pi-Hole:
Code:curl -sSL https://install.pi-hole.net | bash
- When prompted, answer Off to that question:
Code:Do you wish to install the web server (lighttpd) and required PHP modules?
Off
- Once the installation is complete, open this file:
Code:sudo nano /etc/nginx/sites-available/default
- Delete all contents and copy that instead:
Code:server {
listen 8080 default_server;
listen [::]:8080 default_server;
root /var/www/html;
server_name _;
autoindex off;
error_page 404 /pihole/index.php;
index pihole/index.php index.php index.html index.htm;
location / {
expires max;
try_files $uri $uri/ =404;
}
location ~ \.php$ {
include fastcgi_params;
fastcgi_param SCRIPT_FILENAME $document_root/$fastcgi_script_name;
fastcgi_pass unix:/run/php/php7.3-fpm.sock;
fastcgi_param FQDN true;
# auth_basic "Restricted"; # For Basic Auth
# auth_basic_user_file /etc/nginx/.htpasswd; # For Basic Auth
}
location /*.js {
index pihole/index.js;
# auth_basic "Restricted"; # For Basic Auth
# auth_basic_user_file /etc/nginx/.htpasswd; # For Basic Auth
}
location /admin {
root /var/www/html;
index index.php index.html index.htm;
# auth_basic "Restricted"; # For Basic Auth
# auth_basic_user_file /etc/nginx/.htpasswd; # For Basic Auth
}
location ~ /\.ht {
deny all;
}
}
- Set rights for Pi-Hole folder and add pihole user to www-data group:
Code:sudo chown -R www-data:www-data /var/www/html
sudo chmod -R 755 /var/www/html
sudo usermod -aG pihole www-data
- Open this file:
Code:sudo nano -l /etc/nginx/nginx.conf
- And uncomment line 64 (include /etc/nginx/sites-enabled/*):
Code:user www-data;
worker_processes auto;
pid /run/nginx.pid;
include /etc/nginx/modules-enabled/*.conf;
events {
worker_connections 768;
# multi_accept on;
}
http {
##
# Basic Settings
##
sendfile on;
tcp_nopush on;
tcp_nodelay on;
keepalive_timeout 65;
types_hash_max_size 2048;
# server_tokens off;
# server_names_hash_bucket_size 64;
# server_name_in_redirect off;
include /etc/nginx/mime.types;
default_type application/octet-stream;
client_max_body_size 8M;
##
# SSL Settings
##
#ssl_protocols TLSv1 TLSv1.1 TLSv1.2; # Dropping SSLv3, ref: POODLE
#ssl_prefer_server_ciphers on;
##
# Logging Settings
##
access_log /var/log/nginx/access.log;
error_log /var/log/nginx/error.log;
##
# Gzip Settings
##
gzip on;
gzip_disable "msie6";
# gzip_vary on;
# gzip_proxied any;
# gzip_comp_level 6;
# gzip_buffers 16 8k;
# gzip_http_version 1.1;
# gzip_types text/plain text/css application/json application/javascript text/xml application/xml application/xml+rss text/javascript;
##
# Virtual Host Configs
##
#include /etc/nginx/conf.d/*.conf;
include /etc/nginx/sites-enabled/*;
##
# moOde UI server
##
server {
listen 80;
location / {
root /var/www;
index index.html index.php;
try_files $uri $uri/ /coverart.php;
}
location /imagesw/ {
root /var/local/www;
}
# php-fpm
location ~ \.php$ {
root /var/www;
fastcgi_pass unix:/run/php/php7.3-fpm.sock;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $request_filename;
include fastcgi_params;
}
}
}
- Restart PHP and Nginx:
Code:sudo systemctl restart php7.3-fpm.service
sudo systemctl restart nginx
- At this point, you should can access to Pi-Hole:
Code:http://pi.hole:8080/admin/
- To finish, update moOde database:
Code:sudo sqlite3 "/var/local/www/db/moode-sqlite3.db" "DROP TRIGGER IF EXISTS ro_columns"
sudo sqlite3 "/var/local/www/db/moode-sqlite3.db" "UPDATE cfg_hash SET VALUE = '$(md5sum /etc/nginx/nginx.conf | cut -d " " -f1)' WHERE PARAM = '/etc/nginx/nginx.conf'"
sudo sqlite3 "/var/local/www/db/moode-sqlite3.db" "CREATE TRIGGER ro_columns BEFORE UPDATE OF param, value, [action] ON cfg_hash FOR EACH ROW BEGIN SELECT RAISE(ABORT, 'read only'); END;"
- Reboot.
Hi TookaFace,
Is this the complete instructions? I am trying to install PiHole in Moode as well. Do I need to install the Nginx web server first? When I ran your first command line, I get the error "unable to update package cache. Please try sudo apt-get update"
I have moode 7.3 on RPi4B
Thanks.