Welcome to the Slackware Documentation Project

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revision Previous revision
Next revision
Previous revision
howtos:hardware:arm:nginx [2020/03/02 19:33 (UTC)]
exaga [GoAccess configuration] added additional sites section
howtos:hardware:arm:nginx [2020/03/05 12:03 (UTC)] (current)
exaga [Configuring nginx to run on Slackware ARM] added code 'default_server;'
Line 10: Line 10:
 ==== Notes ==== ==== Notes ====
  
-This page will hopefully allow you how run nginx on Slackware ARM successfully,​ from scratch. There'​s no reason what-so-ever that the same procedure(s) shouldn'​t work on Slackware x86_64 [or Slackware ARM 14.2], but for the purpose of testing it has been carried out under Slackware ARM -current [23-26 February 2020]. ​+This page will hopefully allow you how run nginx on Slackware ARM successfully,​ from scratch. There'​s no reason what-so-ever that the same procedure(s) shouldn'​t work on Slackware x86_64 [or Slackware ARM 14.2], but for the purpose of testing it has been carried out under Slackware ARM -current [23 February ​- 05 March 2020]. ​
  
-Slackware ARM -current was running [kernel 5.4.21] on a Raspberry Pi 4 and used to build the package, install and configure nginx. Any ARM device running Slackware may be used for this purpose. The -current (development) version was chosen as it includes the latest software, etc.+Slackware ARM -current was running [kernel 5.4.22] on a Raspberry Pi 4 and used to build the package, install and configure nginx. Any ARM device running Slackware may be used for this purpose. The -current (development) version was chosen as it includes the latest software, etc.
  
 ==== Requirements ==== ==== Requirements ====
Line 43: Line 43:
 </​code>​ </​code>​
  
-You also need to download the latest [[http://​nginx.org/​download/​|nginx mainline]] version and put it in the same directory as the SlackBuild files. At the time of writing this guide the latest version was  [[http://​nginx.org/​download/​nginx-1.17.8.tar.gz|nginx-1.17.8]] but it's best to check if an updated version exists.+You also need to download the latest [[http://​nginx.org/​download/​|nginx mainline]] version and put it in the same directory as the SlackBuild files. At the time of writing this guide the latest version was  [[http://​nginx.org/​download/​nginx-1.17.9.tar.gz|nginx-1.17.9]] but it's best to check if an updated version exists.
  
 <​code>​ <​code>​
-~# wget http://​nginx.org/​download/​nginx-1.17.8.tar.gz+~# wget http://​nginx.org/​download/​nginx-1.17.9.tar.gz
 </​code>​ </​code>​
  
Line 61: Line 61:
 </​code>​ </​code>​
  
-... and change it to the version of nginx you have downloaded. For '​nginx-1.17.8' ​+... and change it to the version of nginx you have downloaded. For '​nginx-1.17.9' ​it would be like this:
  
 <​code>​ <​code>​
-VERSION=${VERSION:​-1.17.8}+VERSION=${VERSION:​-1.17.9}
 </​code>​ </​code>​
  
Line 81: Line 81:
 <​code>​ <​code>​
 ~# time ./​nginx.SlackBuild ~# time ./​nginx.SlackBuild
 +</​code>​
 +
 +Alternatively,​ if you plan on using Maxmind'​s GeoIP database with '​nginx'​ then GeoIP support is available as an option. All that's required is the GeoIP package to have been installed first. If you wish to enable GeoIP support in '​nginx'​ then pass the GEOIP variable to the slackbuild command, like this:
 +
 +<​code>​
 +~# time GEOIP=yes ./​nginx.SlackBuild
 </​code>​ </​code>​
  
 After a few short minutes, you should see the resulting package in your '/​tmp'​ directory. [NB: if you didn't modify the '​${PKGTYPE:​-tgz}'​ variable then the file extension will be '​*.tgz'​ instead of '​*.txz'​.] Check it like this: After a few short minutes, you should see the resulting package in your '/​tmp'​ directory. [NB: if you didn't modify the '​${PKGTYPE:​-tgz}'​ variable then the file extension will be '​*.tgz'​ instead of '​*.txz'​.] Check it like this:
 +
 +<​note>​Q. Why do we use '​time'​ in combination with running the build script? \\
 +A. We like to know how long the process takes. That's all. You don't have to include it in order to be successful.</​note>​
  
 <​code>​ <​code>​
 ~# cd /tmp ~# cd /tmp
 ~# ls -lah *.txz ~# ls -lah *.txz
--rw-r--r-- 1 root root 442K Feb 26 06:01 nginx-1.17.8-arm-1_SBo.txz+-rw-r--r-- 1 root root 442K Feb 26 06:01 nginx-1.17.9-arm-1_SBo.txz
 </​code>​ </​code>​
  
Line 114: Line 123:
  
 <​code>​ <​code>​
-~# installpkg nginx-1.17.8-arm-1_SBo.txz+~# installpkg nginx-1.17.9-arm-1_SBo.txz
 </​code>​ </​code>​
  
Line 204: Line 213:
  
     server {     server {
-        listen ​      80; +        listen ​      ​80 ​default_server
-        server_name ​ localhost;+        server_name  ​127.0.0.1 ​localhost;
  
         location / {         location / {
Line 264: Line 273:
 </​code>​ </​code>​
  
 +By default '​php-fpm'​ does not log anything other than startup and shutdown [see: '/​var/​log/​php-fpm.log'​ after the daemon has been (re)started]. In order to log any relevant error messages we need to make one more change to the file. Find the '​catch_workers_output"​ section below and uncomment the setting, like this:
  
 +<​code>​
 +; Redirect worker stdout and stderr into main error log. If not set, stdout and
 +; stderr will be redirected to /dev/null according to FastCGI specs.
 +; Note: on highloaded environement,​ this can cause some delay in the page
 +; process time (several ms).
 +; Default Value: no
 +catch_workers_output = yes
 +</​code>​
  
 Save and exit the file. Save and exit the file.
Line 412: Line 430:
 </​code>​ </​code>​
  
-Bercause ​we want to use '​test.local'​ and '​extra.local'​ as domain ​names we will add the following to our '/​etc/​hosts'​ file:+Because ​we want to use '​test.local'​ and '​extra.local'​ as domain ​name [server_name] aliases ​we will add the following to our '/​etc/​hosts'​ file:
  
 <​code>​ <​code>​
Line 424: Line 442:
 </​code>​ </​code>​
  
-The above settings will take effect as soon as the file is saved. However, there'​s nothing to "see" ​yet! :-)+The above settings will take effect as soon as the file is saved. However, there'​s nothing ​there to see yet - because we haven'​t created it! :-)
  
 So, then we create and edit the '​test.local.conf'​ file: So, then we create and edit the '​test.local.conf'​ file:
Line 432: Line 450:
 </​code>​ </​code>​
  
-In this file we need to instruct '​nginx'​ which server requests it should listen for on a specific port. We also specify the path/to/the web directory files where this site will be located. So we'll enter the following text into this file:+In this file we need to instruct '​nginx'​ which server requests it should listen for on a specific port. We need to specify the path/to/the web directory files where this site will be located ​and we'll also configure the FastCGI server. So we'll enter the following text into this file:
  
 <​code>​ <​code>​
Line 441: Line 459:
     # this root path is to the webdir     # this root path is to the webdir
     root /​var/​www/​test.local;​     root /​var/​www/​test.local;​
 +    ​
 +    # index pages to load in this order
 +    index index.php index.html index.htm;
  
     #This will be needed for GoAccess ** make sure vcombined map is defined in nginx.conf     #This will be needed for GoAccess ** make sure vcombined map is defined in nginx.conf
     access_log /​var/​log/​nginx/​access.log vcombined;     access_log /​var/​log/​nginx/​access.log vcombined;
 +
 +    # pass the PHP scripts to FastCGI server listening on 127.0.0.1:​9000
 +    #
 +    location ~ \.php$ {
 +       ​root ​          /​var/​www/​test.local;​
 +       ​fastcgi_pass ​  ​127.0.0.1:​9000;​
 +       ​fastcgi_index ​ index.php;
 +       ​fastcgi_param ​ SCRIPT_FILENAME ​ $document_root$fastcgi_script_name;​
 +       ​include ​       fastcgi_params;​
 +    }
  
 } }
Line 459: Line 490:
     # this root path is to the webdir     # this root path is to the webdir
     root /​var/​www/​extra.local;​     root /​var/​www/​extra.local;​
 +
 +    # index pages to load in this order
 +    index index.php index.html index.htm;
  
     #This will be needed for GoAccess ** make sure vcombined map is defined in nginx.conf     #This will be needed for GoAccess ** make sure vcombined map is defined in nginx.conf
     access_log /​var/​log/​nginx/​access.log vcombined;     access_log /​var/​log/​nginx/​access.log vcombined;
 +
 +    # pass the PHP scripts to FastCGI server listening on 127.0.0.1:​9000
 +    #
 +    location ~ \.php$ {
 +       ​root ​          /​var/​www/​extra.local;​
 +       ​fastcgi_pass ​  ​127.0.0.1:​9000;​
 +       ​fastcgi_index ​ index.php;
 +       ​fastcgi_param ​ SCRIPT_FILENAME ​ $document_root$fastcgi_script_name;​
 +       ​include ​       fastcgi_params;​
 +    }
  
 } }
 </​code>​ </​code>​
  
-Note that port:80 is still being used in both cases as the existing '​localhost'​ site, but the server_name and root path are different to reflect that this is a seperate ​site. The server_name is how '​nginx'​ will know which site to direct you to when it is requested. You can of course use other ports. For example, if you required '​test.local'​ to be accessible on port:1080 then just specify that with a '​listen 1080;' parameter. ​+Note that port:80 is still being used in both casesas is the existing '​localhost'​ site, but the server_name and root path are different to reflect that this is a seperate ​entity. The server_name is how '​nginx'​ will know which site to direct you to when it is requested. You can of course use other ports. For example, if you required '​test.local'​ to be accessible on port:1080 then just specify that with a '​listen 1080;' parameter ​and access it as '<​nowiki>​http://​test.local:​1080</​nowiki>'​
  
 The web directories need files in them in order to display any content. So, as before, you could create a simple '​index.php'​ file and put it in the directory that relates to the new site(s). Or you could crate a simple '​index.html'​ file to identify the site. For example: The web directories need files in them in order to display any content. So, as before, you could create a simple '​index.php'​ file and put it in the directory that relates to the new site(s). Or you could crate a simple '​index.html'​ file to identify the site. For example:
Line 481: Line 525:
  
 <​code>​ <​code>​
-~# echo '<​html><​body><​h1>​TEST : It works!</​h1></​body></​html>'​ > /​var/​www/​test.local/​ +~# echo '<​html><​body><​h1>​TEST : It works!</​h1></​body></​html>'​ > /​var/​www/​test.local/​index.html 
-~# echo '<​html><​body><​h1>​EXTRA : It works!</​h1></​body></​html>'​ > /​var/​www/​test.local/​+~# echo '<​html><​body><​h1>​EXTRA : It works!</​h1></​body></​html>'​ > /​var/​www/​test.local/​index.html
 </​code>​ </​code>​
  
-When all that's complete, the final task is to test the '​nginx' ​confiruation ​and restart the daemon.+When all that's complete, the final task is to test the '​nginx' ​configuration ​and restart the daemon.
  
 <​code>​ <​code>​
Line 503: Line 547:
 </​code>​ </​code>​
  
-One thing to note is that if you use '​http://​127.0.0.1/​index.html'​ it will direct you to the '​localhost'​ site because that has been specified as the default in '/​etc/​nginx/​nginx.conf'​. In order to acess the content of any sites other than '​localhost'​ or '​127.0.0.1'​ [default] the server_name must be used. You can also access the site remotely using the IP address of your Raspberry Pi instead of a domain name. Or you could add a domain name alias to your '​hosts'​ file and use that instead. Either method works.+One thing to note is that if you use '<​nowiki>​http://​127.0.0.1/​index.html</​nowiki>​' it will direct you to the '​localhost'​ site because that has been specified as the default in '/​etc/​nginx/​nginx.conf'​. In order to acess the content of any sites other than '​localhost'​ or '​127.0.0.1'​ [default] the server_name must be used. You can also access the site remotely using the IP address ​[and port - if specified] ​of your ARM device ​instead of a domain name. Or you could add a domain name alias to your '​hosts'​ file and use that instead. Either method works.
  
  
Line 509: Line 553:
 # Software used in this guide: \\ # Software used in this guide: \\
 [[http://​slackware.uk/​slackwarearm/​slackwarearm-current/​]] ​ # Slackware ARM -current OS. \\ [[http://​slackware.uk/​slackwarearm/​slackwarearm-current/​]] ​ # Slackware ARM -current OS. \\
-[[https://​nginx.org/​download/​]] # Nginx 1.17.web server software [gzip tarball]. \\+[[https://​nginx.org/​download/​]] # Nginx 1.17.web server software [gzip tarball]. \\
 [[https://​slackbuilds.org/​slackbuilds/​14.2/​network/​nginx/​]] # SlackBuilds.org nginx package build script files. \\ [[https://​slackbuilds.org/​slackbuilds/​14.2/​network/​nginx/​]] # SlackBuilds.org nginx package build script files. \\
 [[https://​slackbuilds.org/​repository/​14.2/​system/​goaccess/​]] # SlackBuilds.org goaccess package build script files. \\ [[https://​slackbuilds.org/​repository/​14.2/​system/​goaccess/​]] # SlackBuilds.org goaccess package build script files. \\

In Other Languages
QR Code
QR Code howtos:hardware:arm:nginx (generated for current page)