nginx für Raspberry kompilieren
Gestestet unter Debian Stretch und Debian Jessie
Der Webserver nginx ist auch in vielen Repos direkt enthalten. Wenn man jedoch die aktuelle Version mit allen plugins haben möchte, muss man selber ran. Mit dieser Setup ist auch die neue http/2 Unterstützung gewährleistet. Allerdings muss dazu ein SSL-Zertifikat vorliegen, da http/2 nur via SSL funktioniert.
Das Kompilieren auf dem Raspberry kann 20 Minuten oder länger dauern. Dank des schmalbrüstigen SoC
Diese Script erledigt viele Dinge, die man dazu benötigt:
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 | #!/usr/bin/env bashset-x# names of latest versions of each packageexportVERSION_PCRE=pcre-8.42exportVERSION_OPENSSL=openssl-1.1.0hexportVERSION_NGINX=nginx-1.13.11exportVERSION_ZLIB=zlib-1.2.11exportVERSION_MODULE_ECHO=0.60# URLs to the source directoriesexportSOURCE_OPENSSL=https://www.openssl.org/source/exportSOURCE_PCRE=ftp://ftp.csx.cam.ac.uk/pub/software/programming/pcre/exportSOURCE_NGINX=http://nginx.org/download/exportSOURCE_ZLIB=http://www.zlib.net/exportSOURCE_MODULE_ECHO=https://codeload.github.com/openresty/echo-nginx-module/tar.gz/v$VERSION_MODULE_ECHO# clean out any files from previous runs of this scriptexportBPATH=$(pwd)/build#rm -rf $BPATHmkdir-p $BPATH# ensure that we have the required software to compile our own nginxif[ ! -f ~/updatesdone];  then        sudoapt-get update        sudoapt-get -y installcurl wget build-essential        touch~/updatesdone        chmod666 ~/updatesdonefi# grab the source files[ ! -f $BPATH/$VERSION_PCRE.tar.gz ] && wget -P $BPATH $SOURCE_PCRE$VERSION_PCRE.tar.gz[ ! -f $BPATH/$VERSION_OPENSSL.tar.gz ] && wget -P $BPATH $SOURCE_OPENSSL$VERSION_OPENSSL.tar.gz --no-check-certificate[ ! -f $BPATH/$VERSION_NGINX.tar.gz ] && wget -P $BPATH $SOURCE_NGINX$VERSION_NGINX.tar.gz[ ! -f $BPATH/$VERSION_ZLIB.tar.gz ] && wget -P $BPATH $SOURCE_ZLIB$VERSION_ZLIB.tar.gz[ ! -f $BPATH/v$VERSION_MODULE_ECHO.tar.gz ] && wget -O v$VERSION_MODULE_ECHO.tar.gz -P $BPATH $SOURCE_MODULE_ECHO# expand the source filescd$BPATHtarxzf $VERSION_NGINX.tar.gztarxzf $VERSION_OPENSSL.tar.gztarxzf $VERSION_PCRE.tar.gztarxzf $VERSION_ZLIB.tar.gztarxzf $BPATH/v0.60.tar.gzcd../# rename the existing /etc/nginx directory so it's saved as a back-upmv/etc/nginx/etc/nginx-bk# build nginx, with various modules included/excludedcd$BPATH/$VERSION_NGINXmkdir-p $BPATH/nginx./configure--sbin-path=/usr/sbin/nginx\--conf-path=/etc/nginx/nginx.conf \--pid-path=/var/run/nginx.pid \--error-log-path=/var/log/nginx/error.log \--http-log-path=/var/log/nginx/access.log \--with-pcre=$BPATH/$VERSION_PCRE \--with-http_ssl_module \--with-file-aio \--with-zlib=$BPATH/$VERSION_ZLIB \--with-http_gzip_static_module \--with-http_stub_status_module \--with-http_v2_module \--with-http_sub_module \--with-select_module \--with-poll_module \--without-mail_pop3_module \--without-mail_smtp_module \--without-mail_imap_module \--with-http_dav_module \--with-openssl=$BPATH/$VERSION_OPENSSLmake&& makeinstall# rename the compiled /etc/nginx directory so its accessible as a reference to the new nginx defaults#mv /etc/nginx /etc/nginx-default# now restore the /etc/nginx-bk to /etc/nginx so the old settings are keptmv/etc/nginx-bk/etc/nginxecho"All done.";echo"This build has not edited your existing /etc/nginx directory.";echo"If things aren't working now you may need to refer to the";echo"configuration files the new nginx ships with as defaults,";echo"which are available at /etc/nginx-default"; | 
Default Konfig kopieren
in /etc/nginx-default lioegen die Standardeinstellungen, die man sich kopieren sollte.  Wenn man jedoch schon eine config hat, kann dieser Schritt übersprungen werden.
| sudo cp -r /etc/nginx-default/etc/nginx | 
Ferner hat es sich bewährt, so wie bei Apache zwei Verzeichnisse anzulegen.
- sites-available
- sites-enabled
So ist es möglich einzelne Webseiten über symbolische Links ein- und auszuschalten.
| sudo mkdir /etc/nginx/sites-available /etc/nginx/sites-enabled | 
Dann muss jedoch auch in der nginx.conf noch folgender Eintrag im http Block ergänzt werden:
| include /etc/nginx/sites-enabled/*; | 
Standardpfad zu dem HTML-Verzeichnis
In der nginx.conf ist als rootdir "html" angegeben. Das ist ein relativer Pfad, der vollständig /usr/local/nginx/html/ heisst.
Autostart über systemd
 TODO
 
        
No comments to display
No comments to display