Přidat komentář

Where can I find actual version of NGINX for Raspberry Pi and how to install it?

At https://packages.raspberry-hosting.com/ we have provided for download the latest version of the nginx for Raspberry Pi. There is also a init script. Packages will be updated regularly.

Installation:

1. Update/upgrade

root@raspberrypi:~# apt-get update && apt-get -y upgrade

2. Install additional packages:

root@raspberrypi:~# apt-get install libpq5 libxslt1.1 aspell mcrypt libltdl7 libgmp10 curl libicu48 libgomp1 libpng12-0 libjpeg8 libfontconfig1 libgd2-xpm

2. Add BEST-HOSTING repository with all packages: (Read more: FREE Raspbian repository )

root@haproxy01:~# apt-key adv --recv-keys --keyserver keyserver.ubuntu.com 0x908332071dd2e32e
root@haproxy01:~# cat > /etc/apt/sources.list.d/best-hosting.list
deb http://deb.best-hosting.cz/debian/ raspberry main
root@haproxy01:~# apt-get update
root@haproxy01:~# apt-cache search bh-

3. Install the NGINX

stable version:
root@raspberrypi:~# wget https://packages.raspberry-hosting.com/nginx-raspberry-pi/nginx_1.6.2-1_armhf.deb
mainline version:
root@raspberrypi:~# wget https://packages.raspberry-hosting.com/nginx-raspberry-pi/nginx_1.7.7-1_armhf.deb
install:
root@raspberrypi:~# dpkg -i ./nginx_1.6.2-1_armhf.deb

stable version:
root@raspberrypi:~# apt-get install bh-nginx-stable
or mainline version:
root@raspberrypi:~# apt-get install bh-nginx-mline

4. Download nginx init script in /etc/init.d/ and add it permissions to execute:

It's not necessary

root@raspberrypi:~# wget https://packages.raspberry-hosting.com/nginx-raspberry-pi/etc/init.d/nginx -O /etc/init.d/nginx
root@raspberrypi:~# chmod +x /etc/init.d/nginx

5. Allowing execution nginx even after reboot:

It's not necessary

root@raspberrypi:~# update-rc.d nginx defaults

6. Create the following folders:

It's not necessary

root@raspberrypi:~# mkdir /etc/nginx/cache
root@raspberrypi:~# mkdir /etc/nginx/conf.d
root@raspberrypi:~# mkdir /etc/nginx/sites-available
root@raspberrypi:~# mkdir /etc/nginx/sites-enabled

7. Basic settings /etc/nginx/nginx.conf :

user  www-data;
worker_processes  1;
error_log   /var/log/nginx/error.log error;
 
events {
    worker_connections  1024;
}
 
http {
     include /etc/nginx/mime.types;
     default_type application/octet-stream;
     log_format main
         '$remote_addr - $remote_user [$time_local] '
         '"$request" $status $bytes_sent '
         '"$http_referer" "$http_user_agent" '
         '"$gzip_ratio"';
 
     access_log  /var/log/nginx/access.log  main;
 
#     geoip_country /usr/local/share/GeoIP/GeoIP.dat;
#     geoip_city /usr/local/share/GeoIP/GeoLiteCity.dat;
#     upload_progress uploads 1m;
#     upload_progress proxied 1m;
 
     open_file_cache          max=5000  inactive=20s;
     open_file_cache_valid    30s;
     open_file_cache_min_uses 2;
     open_file_cache_errors   on;
 
     set_real_ip_from 0.0.0.0/32;
     real_ip_header X-Forwarded-For;
     add_header X-XSS-Protection '1; mode=block';
     add_header X-Content-Options nosniff;
 
     gzip on;
     gzip_static on;
     gzip_disable "msie6";
     gzip_http_version 1.1;
     gzip_vary on;
     gzip_comp_level 4;
     gzip_proxied any;
     gzip_types text/plain text/css application/json application/x-javascript text/xml application/xml application/xml+rss text/javascript application/javascript text/x-js;
     gzip_buffers 16 8k;
 
     client_max_body_size 30M;
     sendfile on;
     tcp_nopush on;
     tcp_nodelay on;
     keepalive_timeout 60;
     types_hash_max_size 2048;
     server_tokens off;
     ignore_invalid_headers on;
 
     fastcgi_buffer_size 128k;
     fastcgi_buffers 256 16k;
     fastcgi_busy_buffers_size 256k;
     fastcgi_temp_file_write_size 256k;
     fastcgi_read_timeout 240;
     fastcgi_cache_path /etc/nginx/cache/ levels=1:2 keys_zone=microcache:10m max_size=1000m inactive=60m;
     fastcgi_cache microcache;
     fastcgi_cache_key $scheme$request_method$host$request_uri;
     fastcgi_cache_valid 10m;
     fastcgi_cache_lock off;
     fastcgi_cache_use_stale updating;
 
     index index.php index.html index.htm;
     include fastcgi_params;
#     limit_req_zone $binary_remote_addr zone=one:10m rate=50r/s;
     include /etc/nginx/sites-enabled/*.conf;
}

8. Basic settings for /var/www/ :

server   {
    listen      80;
    server_name  your-domain-name-here.com;
    root   /var/www;
 
      location = /favicon.ico {
                log_not_found off;
                access_log off;
       }
 
       location = /robots.txt {
                allow all;
                log_not_found off;
                access_log off;
       }
 
        location ~ \..*/.*\.php$ {
                return 403;
        }
 
        location ~ (^|/)\. {
                return 403;
        }
 
        location / {
                try_files $uri $uri/ /index.php?$args;
        }
 
        location ~ \.php$ {
                # SECURITY : Zero day Exploit Protection
                try_files $uri =404;
                # NOTE: You should have "cgi.fix_pathinfo = 0;" in php.ini
                fastcgi_split_path_info ^(.+\.php)(/.+)$;
                fastcgi_pass unix:/var/run/your-domain-name-here.com.sock;
        }
 
}

9. Nginx and fastcgi_params files for download is here:

root@raspberrypi:~#  wget https://packages.raspberry-hosting.com/nginx-raspberry-pi/etc/nginx/fastcgi_params -O /etc/nginx/fastcgi_params
root@raspberrypi:~#  wget https://packages.raspberry-hosting.com/nginx-raspberry-pi/etc/nginx/nginx.conf -O /etc/nginx/nginx.conf

root@raspberrypi:~#  wget http://deb.best-hosting.cz/_scripts_/nginx/fastcgi_params -O /etc/nginx/fastcgi_params
root@raspberrypi:~#  wget http://deb.best-hosting.cz/_scripts_/nginx/nginx.conf -O /etc/nginx/nginx.conf

10. Install PHP-FPM and configure it how you need:

root@raspberrypi:~# apt-get install php5-fpm
root@raspberrypi:~# nano /etc/php5/fpm/php-fpm.conf
root@raspberrypi:~# nano /etc/php5/fpm/pool.d/www.conf (or your-domain-name-here.com.conf) simply as you need

11. Restart NGINX & PHP-FPM:

root@raspberrypi:~# /etc/init.d/php-fpm restart && /etc/init.d/nginx restart

Enjoy!

In case of an update package, be very careful and keep a back-up of all configuration files from /etc/nginx/ !