Skip to content

Commit 840b637

Browse files
committed
Update the NGINX guide
- The PHP version included with Raspbian 12 is 8.2. Update version numbers accordingly - Consistently use systemctl for service management - Include fastcgi settings discussed in issue pi-hole#962 - Remove basic auth configuration since Pi-hole webpage has authentication - Remove autoindex setting as this is already the NGINX default - Remove permission steps that are already handled by the Pi-hole install Signed-off-by: Clay Oster <[email protected]>
1 parent baa9a74 commit 840b637

File tree

1 file changed

+16
-61
lines changed

1 file changed

+16
-61
lines changed

docs/guides/webserver/nginx.md

+16-61
Original file line numberDiff line numberDiff line change
@@ -1,42 +1,36 @@
11
### Notes & Warnings
22

33
- **This is an unsupported configuration created by the community**
4-
- **Replace `7.3` with the PHP version you installed, e.g. if you're using Raspbian Stretch (Debian 9) replace `7.3` with `7.0`.**
5-
- The `php7.3-sqlite3` package must be installed otherwise Networking and Querying will throw an error that it can't access the database.
4+
- **Replace `8.2` with the PHP version you installed, e.g. if you're using Raspbian Bullseye (Debian 11) replace `8.2` with `7.4`.**
5+
- The `php8.2-sqlite3` package must be installed otherwise Networking and Querying will throw an error that it can't access the database.
66

77
### Basic requirements
88

9-
1. Stop default lighttpd
9+
1. Stop and disable the default lighttpd web server
1010

1111
```bash
12-
service lighttpd stop
12+
systemctl disable --now lighttpd
1313
```
1414

15-
2. Install necessary packages
15+
2. Install the nginx package and ensure the necessary PHP packages are installed
1616

1717
```bash
18-
apt-get -y install nginx php7.3-fpm php7.3-cgi php7.3-xml php7.3-sqlite3 php7.3-intl apache2-utils
18+
apt-get -y install nginx php8.2-fpm php8.2-cgi php8.2-xml php8.2-sqlite3 php8.2-intl
1919
```
2020

21-
3. Disable lighttpd at startup
21+
3. Enable php8.2-fpm at startup and start the service
2222

2323
```bash
24-
systemctl disable lighttpd
24+
systemctl enable --now php8.2-fpm
2525
```
2626

27-
4. Enable php7.3-fpm at startup
27+
4. Enable nginx at startup and start the service
2828

2929
```bash
30-
systemctl enable php7.3-fpm
30+
systemctl enable --now nginx
3131
```
3232

33-
5. Enable nginx at startup
34-
35-
```bash
36-
systemctl enable nginx
37-
```
38-
39-
6. Edit `/etc/nginx/sites-available/default` to:
33+
5. Replace the contents of `/etc/nginx/sites-available/default` with the following configuration. If necessary, adjust the PHP version number on the `fastcgi_pass` line to match your installation:
4034

4135
```nginx
4236
server {
@@ -45,7 +39,6 @@
4539
4640
root /var/www/html;
4741
server_name _;
48-
autoindex off;
4942
5043
index pihole/index.php index.php index.html index.htm;
5144
@@ -56,66 +49,28 @@
5649
5750
location ~ \.php$ {
5851
include fastcgi_params;
52+
fastcgi_split_path_info ^(.+?\.php)(/.*)$;
53+
fastcgi_param PATH_INFO $fastcgi_path_info;
5954
fastcgi_param SCRIPT_FILENAME $document_root/$fastcgi_script_name;
60-
fastcgi_pass unix:/run/php/php7.3-fpm.sock;
55+
fastcgi_pass unix:/run/php/php8.2-fpm.sock;
6156
fastcgi_param FQDN true;
62-
auth_basic "Restricted"; # For Basic Auth
63-
auth_basic_user_file /etc/nginx/.htpasswd; # For Basic Auth
6457
}
6558
6659
location /*.js {
6760
index pihole/index.js;
68-
auth_basic "Restricted"; # For Basic Auth
69-
auth_basic_user_file /etc/nginx/.htpasswd; # For Basic Auth
7061
}
7162
7263
location /admin {
7364
root /var/www/html;
7465
index index.php index.html index.htm;
75-
auth_basic "Restricted"; # For Basic Auth
76-
auth_basic_user_file /etc/nginx/.htpasswd; # For Basic Auth
77-
}
78-
79-
location ~ /\.ht {
80-
deny all;
8166
}
8267
}
8368
```
8469

85-
7. Create a username for authentication for the admin - we don't want other people in our network change our black and whitelist ;)
86-
87-
```bash
88-
htpasswd -c /etc/nginx/.htpasswd exampleuser
89-
```
90-
91-
8. Change ownership of the html directory to nginx user
92-
93-
```bash
94-
chown -R www-data:www-data /var/www/html
95-
```
96-
97-
9. Make sure the html directory is writable
98-
99-
```bash
100-
chmod -R 755 /var/www/html
101-
```
102-
103-
10. Grant the admin panel access to the gravity database
104-
105-
```bash
106-
usermod -aG pihole www-data
107-
```
108-
109-
11. Start php7.3-fpm daemon
110-
111-
```bash
112-
service php7.3-fpm start
113-
```
114-
115-
12. Start nginx web server
70+
6. Restart the nginx web server
11671

11772
```bash
118-
service nginx start
73+
systemctl restart nginx
11974
```
12075

12176
### Optional configuration

0 commit comments

Comments
 (0)