|
|
|
|
<!DOCTYPE html>
|
|
|
|
|
<!DOCTYPE html>
|
|
|
|
|
<html>
|
|
|
|
|
<head>
|
|
|
|
|
<meta charset="utf-8">
|
|
|
|
|
<title>Tasks of the Contingent Librarian</title>
|
|
|
|
|
<link rel="stylesheet" type="text/css" href="tasks.css">
|
|
|
|
|
<script src="tasks.js"></script>
|
|
|
|
|
</head>
|
|
|
|
|
<body>
|
|
|
|
|
|
|
|
|
|
<div class="card"><DOCUMENT_FRAGMENT><div class="mw-parser-output"><div class="toc" id="toc"><input class="toctogglecheckbox" id="toctogglecheckbox" role="button" style="display:none" type="checkbox"><div class="toctitle" dir="ltr" lang="en"><h2>Contents</h2><span class="toctogglespan"><label class="toctogglelabel" for="toctogglecheckbox"></label></span></div>
|
|
|
|
|
<ul>
|
|
|
|
|
<li class="toclevel-1 tocsection-1"><a href="#Initial_RPi_setup"><span class="tocnumber">1</span> <span class="toctext">Initial RPi setup</span></a>
|
|
|
|
|
<ul>
|
|
|
|
|
<li class="toclevel-2"><a href="#Auto-mount_an_external_drive_on_boot"><span class="tocnumber">1.1</span> <span class="toctext">Auto-mount an external drive on boot</span></a>
|
|
|
|
|
<ul>
|
|
|
|
|
<li class="toclevel-3"><a href="#Step_1_.E2.80.93_Plug_In_The_Device"><span class="tocnumber">1.1.1</span> <span class="toctext">Step 1 – Plug In The Device</span></a></li>
|
|
|
|
|
<li class="toclevel-3"><a href="#Step_2_.E2.80.93_Identify_The_Device.27s_Unique_ID"><span class="tocnumber">1.1.2</span> <span class="toctext">Step 2 – Identify The Device's Unique ID</span></a></li>
|
|
|
|
|
<li class="toclevel-3"><a href="#Step_3_.E2.80.93_Create_a_Mount_Point"><span class="tocnumber">1.1.3</span> <span class="toctext">Step 3 – Create a Mount Point</span></a></li>
|
|
|
|
|
<li class="toclevel-3"><a href="#Step_4_.E2.80.93_Manually_Mount_The_Drive"><span class="tocnumber">1.1.4</span> <span class="toctext">Step 4 – Manually Mount The Drive</span></a></li>
|
|
|
|
|
<li class="toclevel-3"><a href="#Step_5_.E2.80.93_Un-mounting_The_Drive"><span class="tocnumber">1.1.5</span> <span class="toctext">Step 5 – Un-mounting The Drive</span></a></li>
|
|
|
|
|
<li class="toclevel-3"><a href="#Step_6_.E2.80.93_Auto_Mount"><span class="tocnumber">1.1.6</span> <span class="toctext">Step 6 – Auto Mount</span></a></li>
|
|
|
|
|
<li class="toclevel-3"><a href="#An_Extra_Note_About_File_Systems"><span class="tocnumber">1.1.7</span> <span class="toctext">An Extra Note About File Systems</span></a></li>
|
|
|
|
|
<li class="toclevel-3"><a href="#Final_Thoughts"><span class="tocnumber">1.1.8</span> <span class="toctext">Final Thoughts</span></a></li>
|
|
|
|
|
</ul>
|
|
|
|
|
</li>
|
|
|
|
|
</ul>
|
|
|
|
|
</li>
|
|
|
|
|
<li class="toclevel-1 tocsection-2"><a href="#Configuring_the_web_server"><span class="tocnumber">2</span> <span class="toctext">Configuring the web server</span></a>
|
|
|
|
|
<ul>
|
|
|
|
|
<li class="toclevel-2"><a href="#Creating_a_unit_file"><span class="tocnumber">2.1</span> <span class="toctext">Creating a unit file</span></a></li>
|
|
|
|
|
<li class="toclevel-2"><a href="#Starting_the_calibre-server_service"><span class="tocnumber">2.2</span> <span class="toctext">Starting the calibre-server service</span></a></li>
|
|
|
|
|
<li class="toclevel-2"><a href="#Stopping_the_calibre-server_service"><span class="tocnumber">2.3</span> <span class="toctext">Stopping the calibre-server service</span></a></li>
|
|
|
|
|
<li class="toclevel-2"><a href="#Checking_the_status_of_the_calibre-server_service"><span class="tocnumber">2.4</span> <span class="toctext">Checking the status of the calibre-server service</span></a></li>
|
|
|
|
|
<li class="toclevel-2"><a href="#Enabling_the_calibre-server_service_to_start_at_boot"><span class="tocnumber">2.5</span> <span class="toctext">Enabling the calibre-server service to start at boot</span></a>
|
|
|
|
|
<ul>
|
|
|
|
|
<li class="toclevel-3"><a href="#Note"><span class="tocnumber">2.5.1</span> <span class="toctext">Note</span></a></li>
|
|
|
|
|
</ul>
|
|
|
|
|
</li>
|
|
|
|
|
</ul>
|
|
|
|
|
</li>
|
|
|
|
|
<li class="toclevel-1"><a href="#nginx_configuration"><span class="tocnumber">3</span> <span class="toctext">nginx configuration</span></a></li>
|
|
|
|
|
<li class="toclevel-1"><a href="#nginx_service_file"><span class="tocnumber">4</span> <span class="toctext">nginx service file</span></a>
|
|
|
|
|
<ul>
|
|
|
|
|
<li class="toclevel-2"><a href="#On_Debian.2FUbuntu.2FRHEL.2FCentOS_Linux"><span class="tocnumber">4.1</span> <span class="toctext">On Debian/Ubuntu/RHEL/CentOS Linux</span></a></li>
|
|
|
|
|
<li class="toclevel-2"><a href="#If_nginx_is_compiled_and_installed_from_the_source_code"><span class="tocnumber">4.2</span> <span class="toctext">If nginx is compiled and installed from the source code</span></a></li>
|
|
|
|
|
</ul>
|
|
|
|
|
</li>
|
|
|
|
|
</ul>
|
|
|
|
|
</div>
|
|
|
|
|
|
|
|
|
|
<h2><span class="mw-headline" id="Initial_RPi_setup">Initial RPi setup</span><span class="mw-editsection"><span class="mw-editsection-bracket">[</span><a href="/mw-mediadesign/index.php?title=User:Simon/Trim4/prototypes/bootleg_library_setup&action=edit&section=1" title="Edit section: Initial RPi setup">edit</a><span class="mw-editsection-bracket">]</span></span></h2>
|
|
|
|
|
<p>The bootleg library runs on a Raspberry Pi (RPi) single-board computer. The operating system of the RPi is stored on an SD card, that must be "flashed" with an "image" of the operating system in order to boot the computer.
|
|
|
|
|
</p><p>There are various distributions you can choose from, depending on how you want to use the computer. <a class="external text" href="https://www.raspberrypi.org/documentation/installation/installing-images/" rel="nofollow">This page from the Raspberry Pi documentation</a> gives a good guide on how to install an operating system image on an SD card using Raspberry Pi Imager, or manually. For the bootleg library, I initially installed Buster-lite, and then eventually switched to a plain-text environment because it was lighter.
|
|
|
|
|
</p><p>I used software called <a class="external text" href="https://www.balena.io/etcher/" rel="nofollow">balena etcher</a>, but you can also attempt to install a distribution using the dreaded <code>dd</code> command to convert and copy the exact image on to the SD card. <code>dd</code> is sometimes referred to as the "disk destroyer", so use with caution.
|
|
|
|
|
</p>
|
|
|
|
|
<h3><span class="mw-headline" id="Auto-mount_an_external_drive_on_boot">Auto-mount an external drive on boot</span><span class="mw-editsection"><span class="mw-editsection-bracket">[</span><a href="/mw-mediadesign/index.php?title=User:Simon/Trim4/prototypes/automount_a_drive_on_boot&action=edit&section=T-1" title="Edit section: ">edit</a><span class="mw-editsection-bracket">]</span></span></h3>
|
|
|
|
|
<h4><span id="Step_1_–_Plug_In_The_Device"></span><span class="mw-headline" id="Step_1_.E2.80.93_Plug_In_The_Device">Step 1 – Plug In The Device</span><span class="mw-editsection"><span class="mw-editsection-bracket">[</span><a href="/mw-mediadesign/index.php?title=User:Simon/Trim4/prototypes/automount_a_drive_on_boot&action=edit&section=T-2" title="Edit section: ">edit</a><span class="mw-editsection-bracket">]</span></span></h4>
|
|
|
|
|
<h4><span id="Step_2_–_Identify_The_Device's_Unique_ID"></span><span class="mw-headline" id="Step_2_.E2.80.93_Identify_The_Device.27s_Unique_ID">Step 2 – Identify The Device's Unique ID</span><span class="mw-editsection"><span class="mw-editsection-bracket">[</span><a href="/mw-mediadesign/index.php?title=User:Simon/Trim4/prototypes/automount_a_drive_on_boot&action=edit&section=T-3" title="Edit section: ">edit</a><span class="mw-editsection-bracket">]</span></span></h4>
|
|
|
|
|
<p>In order to find the unique reference (UUID) for your drive run the following command in the terminal :
|
|
|
|
|
</p><p><code>ls -l /dev/disk/by-uuid/</code>
|
|
|
|
|
</p><p>This will give you an output that should list your drive :
|
|
|
|
|
</p><p><a class="image" href="File:Bootleg_uuid.png.html"><img alt="Bootleg uuid.png" decoding="async" height="96" src="/mw-mediadesign/images/thumb/a/ae/Bootleg_uuid.png/800px-Bootleg_uuid.png" srcset="/mw-mediadesign/images/thumb/a/ae/Bootleg_uuid.png/1200px-Bootleg_uuid.png 1.5x, /mw-mediadesign/images/thumb/a/ae/Bootleg_uuid.png/1600px-Bootleg_uuid.png 2x" width="800"></a>
|
|
|
|
|
</p><p>The line will usually refer to “/sda” and in this example it is “sda1”. My ID is “989B-E900”. Note down yours.
|
|
|
|
|
You would need to repeat this step if you wanted to use a different device as the UUID would be different.
|
|
|
|
|
</p>
|
|
|
|
|
<h4><span id="Step_3_–_Create_a_Mount_Point"></span><span class="mw-headline" id="Step_3_.E2.80.93_Create_a_Mount_Point">Step 3 – Create a Mount Point</span><span class="mw-editsection"><span class="mw-editsection-bracket">[</span><a href="/mw-mediadesign/index.php?title=User:Simon/Trim4/prototypes/automount_a_drive_on_boot&action=edit&section=T-4" title="Edit section: ">edit</a><span class="mw-editsection-bracket">]</span></span></h4>
|
|
|
|
|
<p>A mount point is a directory that will point to the contents of your flash drive. Create a suitable folder :
|
|
|
|
|
</p><p><code>sudo mkdir /media/usb</code>
|
|
|
|
|
</p><p>I’m using “usb” but you can give it whatever name you like. Keep it short as it saves typing later on. Now we need to make sure the Pi user owns this folder :
|
|
|
|
|
</p><p><code>sudo chown -R pi:pi /media/usb</code>
|
|
|
|
|
</p><p>You will only need to do this step once.
|
|
|
|
|
</p>
|
|
|
|
|
<h4><span id="Step_4_–_Manually_Mount_The_Drive"></span><span class="mw-headline" id="Step_4_.E2.80.93_Manually_Mount_The_Drive">Step 4 – Manually Mount The Drive</span><span class="mw-editsection"><span class="mw-editsection-bracket">[</span><a href="/mw-mediadesign/index.php?title=User:Simon/Trim4/prototypes/automount_a_drive_on_boot&action=edit&section=T-5" title="Edit section: ">edit</a><span class="mw-editsection-bracket">]</span></span></h4>
|
|
|
|
|
<p>To manually mount the drive use the following command :
|
|
|
|
|
</p><p><code>sudo mount /dev/sda1 /media/usb -o uid=pi,gid=pi</code>
|
|
|
|
|
</p><p><br>
|
|
|
|
|
This will mount the drive so that the ordinary Pi user can write to it. Omitting the “-o uid=pi,gid=pi” would mean you could only write to it using “sudo”.
|
|
|
|
|
Now you can read, write and delete files using “/media/usb” as a destination or source without needing to use sudo.
|
|
|
|
|
</p>
|
|
|
|
|
<h4><span id="Step_5_–_Un-mounting_The_Drive"></span><span class="mw-headline" id="Step_5_.E2.80.93_Un-mounting_The_Drive">Step 5 – Un-mounting The Drive</span><span class="mw-editsection"><span class="mw-editsection-bracket">[</span><a href="/mw-mediadesign/index.php?title=User:Simon/Trim4/prototypes/automount_a_drive_on_boot&action=edit&section=T-6" title="Edit section: ">edit</a><span class="mw-editsection-bracket">]</span></span></h4>
|
|
|
|
|
<p>You don’t need to manually un-mount if you shutdown your Pi but if you need to remove the drive at any other time you should un-mount it first. Only the user that mounted the drive can un-mount it.
|
|
|
|
|
</p><p><code>umount /media/usb</code>
|
|
|
|
|
</p><p>If you used the fstab file to auto-mount it you will need to use :
|
|
|
|
|
</p><p><code>sudo umount /media/usb</code>
|
|
|
|
|
</p><p>If you are paying attention you will notice the command is “<i>u</i>mount” NOT “<i>un</i>mount”!
|
|
|
|
|
</p>
|
|
|
|
|
<h4><span id="Step_6_–_Auto_Mount"></span><span class="mw-headline" id="Step_6_.E2.80.93_Auto_Mount">Step 6 – Auto Mount</span><span class="mw-editsection"><span class="mw-editsection-bracket">[</span><a href="/mw-mediadesign/index.php?title=User:Simon/Trim4/prototypes/automount_a_drive_on_boot&action=edit&section=T-7" title="Edit section: ">edit</a><span class="mw-editsection-bracket">]</span></span></h4>
|
|
|
|
|
<p>When you restart your Pi your mounts will be lost and you will need to repeat Step 4. If you want your USB drive to be mounted when the system starts you can edit the fstab file :
|
|
|
|
|
</p><p><code>sudo nano /etc/fstab</code>
|
|
|
|
|
</p><p>Then add the following line at the end :
|
|
|
|
|
</p><p><code>UUID=989B-E900 /media/usb vfat auto,nofail,noatime,users,rw,uid=pi,gid=pi 0 0</code>
|
|
|
|
|
</p><p>The “nofail” option allows the boot process to proceed if the drive is not plugged in. The “noatime” option stops the file access time being updated every time a file is read from the USB stick. This helps improve performance.
|
|
|
|
|
This is what my fstab file looks like:
|
|
|
|
|
</p><p><a class="image" href="File:Bootleg_fstab.png.html"><img alt="Bootleg fstab.png" decoding="async" height="412" src="/mw-mediadesign/images/thumb/7/70/Bootleg_fstab.png/800px-Bootleg_fstab.png" srcset="/mw-mediadesign/images/thumb/7/70/Bootleg_fstab.png/1200px-Bootleg_fstab.png 1.5x, /mw-mediadesign/images/thumb/7/70/Bootleg_fstab.png/1600px-Bootleg_fstab.png 2x" width="800"></a>
|
|
|
|
|
</p><p>Make sure you set the correct UUID. Use CTRL-X followed by Y to save and exit the nano editor.
|
|
|
|
|
</p><p>Now reboot :
|
|
|
|
|
</p><p><code>sudo reboot</code>
|
|
|
|
|
</p><p>Your USB drive should be auto-mounted and available as “/media/usb”.
|
|
|
|
|
</p>
|
|
|
|
|
<h4><span class="mw-headline" id="An_Extra_Note_About_File_Systems">An Extra Note About File Systems</span><span class="mw-editsection"><span class="mw-editsection-bracket">[</span><a href="/mw-mediadesign/index.php?title=User:Simon/Trim4/prototypes/automount_a_drive_on_boot&action=edit&section=T-8" title="Edit section: ">edit</a><span class="mw-editsection-bracket">]</span></span></h4>
|
|
|
|
|
<p>In the examples above I specified “vfat” as the file system of the device as it was formatted as FAT32. If you need to change the file system replace references of “vfat” with “ntfs-3g”, “ext3” or “ext4”.
|
|
|
|
|
If you are using NTFS you will also need to install the following package :
|
|
|
|
|
</p><p><code>sudo apt-get install ntfs-3g</code>
|
|
|
|
|
</p>
|
|
|
|
|
<h4><span class="mw-headline" id="Final_Thoughts">Final Thoughts</span><span class="mw-editsection"><span class="mw-editsection-bracket">[</span><a href="/mw-mediadesign/index.php?title=User:Simon/Trim4/prototypes/automount_a_drive_on_boot&action=edit&section=T-9" title="Edit section: ">edit</a><span class="mw-editsection-bracket">]</span></span></h4>
|
|
|
|
|
<p>This technique suits my applications but the main disadvantage is that it is specific to a known USB device given we are using the device ID. However if you created a few mount points in advance you could manually mount a new device to a spare mount point without worrying about updating the fstab file.
|
|
|
|
|
</p>
|
|
|
|
|
<h2><span class="mw-headline" id="Configuring_the_web_server">Configuring the web server</span><span class="mw-editsection"><span class="mw-editsection-bracket">[</span><a href="/mw-mediadesign/index.php?title=User:Simon/Trim4/prototypes/bootleg_library_setup&action=edit&section=2" title="Edit section: Configuring the web server">edit</a><span class="mw-editsection-bracket">]</span></span></h2>
|
|
|
|
|
<h3><span class="mw-headline" id="Creating_a_unit_file">Creating a unit file</span><span class="mw-editsection"><span class="mw-editsection-bracket">[</span><a href="/mw-mediadesign/index.php?title=User:Simon/Trim4/prototypes/calibre_service_file&action=edit&section=T-1" title="Edit section: ">edit</a><span class="mw-editsection-bracket">]</span></span></h3>
|
|
|
|
|
<p>You can easily create a unit file for calibre to run on boot on a modern (systemd) based Linux system. This means it will also restart after a crash. Create the file <code>/etc/systemd/system/calibre-server.service</code> with the contents shown below:
|
|
|
|
|
</p>
|
|
|
|
|
<pre>[Unit]
|
|
|
|
|
Description=Calibre.
|
|
|
|
|
After=syslog.target network.target
|
|
|
|
|
|
|
|
|
|
[Service]
|
|
|
|
|
Type=simple
|
|
|
|
|
User=pi
|
|
|
|
|
Group=pi
|
|
|
|
|
WorkingDirectory=/home/pi/calibre-web
|
|
|
|
|
ExecStart=python cps.py
|
|
|
|
|
Restart=always
|
|
|
|
|
|
|
|
|
|
[Install]
|
|
|
|
|
WantedBy=multi-user.target</pre>
|
|
|
|
|
<p>The <code>User</code> and <code>Group</code> should be the same ones that own the files in the calibre library directory. It's generally not a good idea to run the server as root. Also change the path to the calibre library directory to suit your system.
|
|
|
|
|
</p>
|
|
|
|
|
<h3><span class="mw-headline" id="Starting_the_calibre-server_service">Starting the calibre-server service</span><span class="mw-editsection"><span class="mw-editsection-bracket">[</span><a href="/mw-mediadesign/index.php?title=User:Simon/Trim4/prototypes/calibre_service_file&action=edit&section=T-2" title="Edit section: ">edit</a><span class="mw-editsection-bracket">]</span></span></h3>
|
|
|
|
|
<p>Run:
|
|
|
|
|
</p><p><code>sudo systemctl start calibre-server</code>
|
|
|
|
|
</p><p>to start the server.
|
|
|
|
|
</p>
|
|
|
|
|
<h3><span class="mw-headline" id="Stopping_the_calibre-server_service">Stopping the calibre-server service</span><span class="mw-editsection"><span class="mw-editsection-bracket">[</span><a href="/mw-mediadesign/index.php?title=User:Simon/Trim4/prototypes/calibre_service_file&action=edit&section=T-3" title="Edit section: ">edit</a><span class="mw-editsection-bracket">]</span></span></h3>
|
|
|
|
|
<p>Stopping the service is as easy as running:
|
|
|
|
|
</p><p><code>sudo systemctl stop calibre-server</code>
|
|
|
|
|
</p>
|
|
|
|
|
<h3><span class="mw-headline" id="Checking_the_status_of_the_calibre-server_service">Checking the status of the calibre-server service</span><span class="mw-editsection"><span class="mw-editsection-bracket">[</span><a href="/mw-mediadesign/index.php?title=User:Simon/Trim4/prototypes/calibre_service_file&action=edit&section=T-4" title="Edit section: ">edit</a><span class="mw-editsection-bracket">]</span></span></h3>
|
|
|
|
|
<p>Check its status with:
|
|
|
|
|
</p><p><code>sudo systemctl status calibre-server</code>
|
|
|
|
|
</p>
|
|
|
|
|
<h3><span class="mw-headline" id="Enabling_the_calibre-server_service_to_start_at_boot">Enabling the calibre-server service to start at boot</span><span class="mw-editsection"><span class="mw-editsection-bracket">[</span><a href="/mw-mediadesign/index.php?title=User:Simon/Trim4/prototypes/calibre_service_file&action=edit&section=T-5" title="Edit section: ">edit</a><span class="mw-editsection-bracket">]</span></span></h3>
|
|
|
|
|
<p>To make it start at boot, run:
|
|
|
|
|
</p><p><code>sudo systemctl enable calibre-server</code>
|
|
|
|
|
</p>
|
|
|
|
|
<h5><span class="mw-headline" id="Note">Note</span><span class="mw-editsection"><span class="mw-editsection-bracket">[</span><a href="/mw-mediadesign/index.php?title=User:Simon/Trim4/prototypes/calibre_service_file&action=edit&section=T-6" title="Edit section: ">edit</a><span class="mw-editsection-bracket">]</span></span></h5>
|
|
|
|
|
<p>The calibre server does not need a running X server, but it does need the X libraries installed as some components it uses link against them.
|
|
|
|
|
</p><p>The calibre server also supports systemd socket activation, so you can use that, if needed, as well.
|
|
|
|
|
This is the configuration for calibre-web to listen on localhost:
|
|
|
|
|
</p>
|
|
|
|
|
<pre>--- a/cps/server.py
|
|
|
|
|
+++ b/cps/server.py
|
|
|
|
|
@@ -152,7 +152,7 @@ class WebServer(object):
|
|
|
|
|
http_server = HTTPServer(WSGIContainer(self.app),
|
|
|
|
|
max_buffer_size=209700000,
|
|
|
|
|
ssl_options=self.ssl_args)
|
|
|
|
|
- http_server.listen(self.listen_port, self.listen_address)
|
|
|
|
|
+ http_server.listen(self.listen_port, address="127.0.0.1")
|
|
|
|
|
self.wsgiserver = IOLoop.instance()
|
|
|
|
|
self.wsgiserver.start()
|
|
|
|
|
# wait for stop signal
|
|
|
|
|
</pre>
|
|
|
|
|
<h1><span class="mw-headline" id="nginx_configuration">nginx configuration</span><span class="mw-editsection"><span class="mw-editsection-bracket">[</span><a href="/mw-mediadesign/index.php?title=User:Simon/Trim4/prototypes/nginx_configuration&action=edit&section=T-1" title="Edit section: ">edit</a><span class="mw-editsection-bracket">]</span></span></h1>
|
|
|
|
|
<p>nginx is a web server software that the bootleg library runs on. This configuration allows maximum uploads of 100mb:
|
|
|
|
|
</p>
|
|
|
|
|
<pre>server {
|
|
|
|
|
listen 80 default_server;
|
|
|
|
|
listen [::]:80 default_server;
|
|
|
|
|
server_name _;
|
|
|
|
|
location /bootleglibrary {
|
|
|
|
|
|
|
|
|
|
auth_basic "ヽ(°〇°)ノ";
|
|
|
|
|
auth_basic_user_file /etc/nginx/htpasswd;
|
|
|
|
|
|
|
|
|
|
client_max_body_size 100M;
|
|
|
|
|
|
|
|
|
|
proxy_bind $server_addr;
|
|
|
|
|
proxy_pass http://127.0.0.1:20190;
|
|
|
|
|
proxy_set_header Host $http_host;
|
|
|
|
|
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
|
|
|
|
|
proxy_set_header X-Scheme $scheme;
|
|
|
|
|
proxy_set_header X-Script-Name /bootleglibrary;
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
</pre>
|
|
|
|
|
<h1><span class="mw-headline" id="nginx_service_file">nginx service file</span><span class="mw-editsection"><span class="mw-editsection-bracket">[</span><a href="/mw-mediadesign/index.php?title=User:Simon/Trim4/prototypes/nginx_configuration&action=edit&section=T-2" title="Edit section: ">edit</a><span class="mw-editsection-bracket">]</span></span></h1>
|
|
|
|
|
<p>To enable, start, stop, or check the status of the nginx web server, a service file is needed. To create one in a systemd Linux distribution, make this file:
|
|
|
|
|
</p><p><code>/lib/systemd/system/nginx.service</code>
|
|
|
|
|
</p><p>with the following contents:
|
|
|
|
|
</p>
|
|
|
|
|
<pre># Stop dance for nginx
|
|
|
|
|
# =======================
|
|
|
|
|
#
|
|
|
|
|
# ExecStop sends SIGSTOP (graceful stop) to the nginx process.
|
|
|
|
|
# If, after 5s (--retry QUIT/5) nginx is still running, systemd takes control
|
|
|
|
|
# and sends SIGTERM (fast shutdown) to the main process.
|
|
|
|
|
# After another 5s (TimeoutStopSec=5), and if nginx is alive, systemd sends
|
|
|
|
|
# SIGKILL to all the remaining processes in the process group (KillMode=mixed).
|
|
|
|
|
#
|
|
|
|
|
# nginx signals reference doc:
|
|
|
|
|
# http://nginx.org/en/docs/control.html
|
|
|
|
|
#
|
|
|
|
|
[Unit]
|
|
|
|
|
Description=A high performance web server and a reverse proxy server
|
|
|
|
|
Documentation=man:nginx(8)
|
|
|
|
|
After=network.target nss-lookup.target
|
|
|
|
|
|
|
|
|
|
[Service]
|
|
|
|
|
Type=forking
|
|
|
|
|
PIDFile=/run/nginx.pid
|
|
|
|
|
ExecStartPre=/usr/sbin/nginx -t -q -g 'daemon on; master_process on;'
|
|
|
|
|
ExecStart=/usr/sbin/nginx -g 'daemon on; master_process on;'
|
|
|
|
|
ExecReload=/usr/sbin/nginx -g 'daemon on; master_process on;' -s reload
|
|
|
|
|
ExecStop=-/sbin/start-stop-daemon --quiet --stop --retry QUIT/5 --pidfile /run/nginx.pid
|
|
|
|
|
TimeoutStopSec=5
|
|
|
|
|
KillMode=mixed
|
|
|
|
|
|
|
|
|
|
[Install]
|
|
|
|
|
WantedBy=multi-user.target
|
|
|
|
|
</pre>
|
|
|
|
|
<p><br>
|
|
|
|
|
</p>
|
|
|
|
|
<h2><span id="On_Debian/Ubuntu/RHEL/CentOS_Linux"></span><span class="mw-headline" id="On_Debian.2FUbuntu.2FRHEL.2FCentOS_Linux">On Debian/Ubuntu/RHEL/CentOS Linux</span><span class="mw-editsection"><span class="mw-editsection-bracket">[</span><a href="/mw-mediadesign/index.php?title=User:Simon/Trim4/prototypes/nginx_configuration&action=edit&section=T-3" title="Edit section: ">edit</a><span class="mw-editsection-bracket">]</span></span></h2>
|
|
|
|
|
<p>Use the following command:
|
|
|
|
|
<code># /etc/init.d/nginx restart</code>
|
|
|
|
|
</p><p>OR
|
|
|
|
|
</p><p><code># /etc/init.d/nginx reload</code>
|
|
|
|
|
</p><p>OR
|
|
|
|
|
</p><p><code># service nginx restart</code>
|
|
|
|
|
</p><p>OR
|
|
|
|
|
</p><p><code># service nginx reload</code>
|
|
|
|
|
</p><p>OR if you are using systemd based Linux distro:
|
|
|
|
|
</p><p><code>$ sudo systemctl restart nginx</code>
|
|
|
|
|
</p><p>OR
|
|
|
|
|
</p><p><code>$ sudo systemctl reload nginx</code>
|
|
|
|
|
</p><p>To view status:
|
|
|
|
|
</p><p><code># service nginx status</code>
|
|
|
|
|
</p><p>OR
|
|
|
|
|
</p><p><code>$ sudo systemctl status nginx</code>
|
|
|
|
|
</p><p>However, the recommend way is as follows. This should work with any Linux distributions or Unix-like operating systems:
|
|
|
|
|
</p><p><code># nginx -s reload</code>
|
|
|
|
|
</p><p>OR
|
|
|
|
|
</p><p><code># /path/to/full/nginx -s reload</code>
|
|
|
|
|
</p>
|
|
|
|
|
<h2><span class="mw-headline" id="If_nginx_is_compiled_and_installed_from_the_source_code">If nginx is compiled and installed from the source code</span><span class="mw-editsection"><span class="mw-editsection-bracket">[</span><a href="/mw-mediadesign/index.php?title=User:Simon/Trim4/prototypes/nginx_configuration&action=edit&section=T-4" title="Edit section: ">edit</a><span class="mw-editsection-bracket">]</span></span></h2>
|
|
|
|
|
<p>If nginx binary is installed at /usr/local/nginx/sbin/nginx, enter:
|
|
|
|
|
</p><p><code># /usr/local/nginx/sbin/nginx -s reload</code>
|
|
|
|
|
xvm uses these settings:
|
|
|
|
|
</p>
|
|
|
|
|
<pre>location /bootleglibrary {
|
|
|
|
|
client_max_body_size 100M;
|
|
|
|
|
proxy_pass http://10.0.0.103/bootleglibrary;
|
|
|
|
|
}
|
|
|
|
|
</pre>
|
|
|
|
|
<!--
|
|
|
|
|
NewPP limit report
|
|
|
|
|
Cached time: 20200610083234
|
|
|
|
|
Cache expiry: 86400
|
|
|
|
|
Dynamic content: false
|
|
|
|
|
CPU time usage: 0.047 seconds
|
|
|
|
|
Real time usage: 0.126 seconds
|
|
|
|
|
Preprocessor visited node count: 56/1000000
|
|
|
|
|
Preprocessor generated node count: 160/1000000
|
|
|
|
|
Post‐expand include size: 8014/2097152 bytes
|
|
|
|
|
Template argument size: 0/2097152 bytes
|
|
|
|
|
Highest expansion depth: 2/40
|
|
|
|
|
Expensive parser function count: 0/100
|
|
|
|
|
Unstrip recursion depth: 0/20
|
|
|
|
|
Unstrip post‐expand size: 2474/5000000 bytes
|
|
|
|
|
-->
|
|
|
|
|
<!--
|
|
|
|
|
Transclusion expansion time report (%,ms,calls,template)
|
|
|
|
|
100.00% 31.073 1 -total
|
|
|
|
|
28.20% 8.764 1 User:Simon/prototypes/calibre-web_configuration
|
|
|
|
|
20.01% 6.218 1 User:Simon/Trim4/prototypes/flashing_an_SD_card
|
|
|
|
|
16.94% 5.263 1 User:Simon/Trim4/prototypes/automount_a_drive_on_boot
|
|
|
|
|
13.42% 4.171 1 User:Simon/Trim4/prototypes/nginx_configuration
|
|
|
|
|
9.71% 3.017 1 User:Simon/Trim4/prototypes/calibre_service_file
|
|
|
|
|
8.45% 2.625 1 User:Simon/Trim4/prototypes/xvm_configuration
|
|
|
|
|
-->
|
|
|
|
|
|
|
|
|
|
<!-- Saved in parser cache with key wdka_mw_mediadesign-mw_:pcache:idhash:29988-0!canonical and timestamp 20200610083234 and revision id 173475
|
|
|
|
|
-->
|
|
|
|
|
</div></DOCUMENT_FRAGMENT></div>
|
|
|
|
|
|
|
|
|
|
</body>
|
|
|
|
|
</html>
|