From 710cc2c1dd8d1482987f1dc17d0d886e4e82a916 Mon Sep 17 00:00:00 2001 From: Michiel van Es Date: Wed, 27 Jan 2016 21:44:01 +0100 Subject: [PATCH] Nginx wrapup with htpasswd basic auth, set the nginx.conf to your likings (if you use the newer raspberry pi's you can change the default from 1 to 2 or 4 worker processes) --- ...fault-lighttpd-and-php-cgi-option.asciidoc | 33 +++++++++++++++++++ 1 file changed, 33 insertions(+) create mode 100644 Nginx-configuration-instead-of-the-default-lighttpd-and-php-cgi-option.asciidoc diff --git a/Nginx-configuration-instead-of-the-default-lighttpd-and-php-cgi-option.asciidoc b/Nginx-configuration-instead-of-the-default-lighttpd-and-php-cgi-option.asciidoc new file mode 100644 index 0000000..d9b55f7 --- /dev/null +++ b/Nginx-configuration-instead-of-the-default-lighttpd-and-php-cgi-option.asciidoc @@ -0,0 +1,33 @@ +. apt-get -y install nginx php5-fpm apache2-utils #install necessary packages +. systemctl disable lighttpd #disable lighttpd at startup +. systemctl enable php5-fpm #enable php5-fpm at startup +. systemctl enable nginx #enable nginx at startup +. edit /etc/nginx/conf.d/default to: +---- +server { + listen 80 default_server; + listen [::]:80 default_server; + root /var/www/html; + index index.html index.htm index.php; + server_name _; + autoindex off; + location / { + expires max; + return 204 'pixel'; + } + location /admin{ + root /var/www/html; + index index.php; + auth_basic "Restricted"; #For Basic Auth + auth_basic_user_file /etc/nginx/.htpasswd; #For Basic Auth + } + location ~ \.php$ { + include snippets/fastcgi-php.conf; + fastcgi_pass unix:/var/run/php5-fpm.sock; + } +} +---- +. htpasswd -c /etc/nginx/.htpasswd exampleuser #create username for authentication for the admin - we don't want other people in our network change our black and whitelist ;) +. service lighttpd stop #stop default lighttpd +. service php5-fpm start #start php5-fpm daemon +. service nginx start #start nginx webserver \ No newline at end of file