<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Computers &#8211; Sandy Scott&#039;s Web Spot</title>
	<atom:link href="https://www.sandyscott.net/category/computers/feed/" rel="self" type="application/rss+xml" />
	<link>https://www.sandyscott.net</link>
	<description>My little corner of the web</description>
	<lastBuildDate>Thu, 17 Mar 2022 11:13:28 +0000</lastBuildDate>
	<language>en-GB</language>
	<sy:updatePeriod>
	hourly	</sy:updatePeriod>
	<sy:updateFrequency>
	1	</sy:updateFrequency>
	<generator>https://wordpress.org/?v=6.6.2</generator>
	<item>
		<title>KiCad Simulation &#8211; Node sequence</title>
		<link>https://www.sandyscott.net/2022/03/kicad-simulation-node-sequence/</link>
					<comments>https://www.sandyscott.net/2022/03/kicad-simulation-node-sequence/#respond</comments>
		
		<dc:creator><![CDATA[Sandy]]></dc:creator>
		<pubDate>Thu, 17 Mar 2022 11:13:26 +0000</pubDate>
				<category><![CDATA[Computers]]></category>
		<category><![CDATA[Software]]></category>
		<guid isPermaLink="false">https://www.sandyscott.net/?p=846</guid>

					<description><![CDATA[I&#8217;ve just started using KiCad, and I&#8217;m really impressed. However, setting up a simulation can be awkward, because you need to match up the pin numbers from your schematic (which defines what is connected to what) with the node numbers that you ngspice model has. Most people encounter this first...<p> <a class="continue-reading-link" href="https://www.sandyscott.net/2022/03/kicad-simulation-node-sequence/"><span>Continue reading</span><i class="crycon-right-dir"></i></a> </p>]]></description>
										<content:encoded><![CDATA[
<p>I&#8217;ve just started using KiCad, and I&#8217;m really impressed. However, setting up a simulation can be awkward, because you need to match up the pin numbers from your schematic (which defines what is connected to what) with the node numbers that you ngspice model has.</p>



<p>Most people encounter this first with transistors. eg. a typical BJT has the following pin assignments:</p>



<ol class="wp-block-list"><li>Emitter</li><li>Base</li><li>Collector</li></ol>



<figure class="wp-block-image size-full"><a href="https://www.sandyscott.net/wp-content/uploads/2022/03/image.png"><img fetchpriority="high" decoding="async" width="346" height="225" src="https://www.sandyscott.net/wp-content/uploads/2022/03/image.png" alt="" class="wp-image-847" srcset="https://www.sandyscott.net/wp-content/uploads/2022/03/image.png 346w, https://www.sandyscott.net/wp-content/uploads/2022/03/image-300x195.png 300w, https://www.sandyscott.net/wp-content/uploads/2022/03/image-150x98.png 150w" sizes="(max-width: 346px) 100vw, 346px" /></a><figcaption>This is fine &#8211; KiCad is mainly for creating PCBs, so the most important thing is that the pins on the schematic match up to the pins on the footprint on the PCB.<br></figcaption></figure>



<p>However, our simulation models have nodes, and each node will correspond to a pin on the schematic and PCB, so we need to make sure that each pin is connected to the right node.</p>



<p>From the datasheet you&#8217;ll be able to get the pin assignments &#8211; e.g. pin 2 is the Base. Where do you find the ngspice node assignments? It depends on the type of spice model you&#8217;re using. </p>



<ul class="wp-block-list"><li>Built-in .MODEL. These are used for standard components, so the behaviour of the component can be defined with just a few parameters &#8211; e.g. for a basic simulation all you need to know about a resistor is the resistance. There are 17 types of model.</li><li>Custom .SUBCKT (Sub-circuit). These can be used for components that don&#8217;t fit into the standard categories, or for a complete add-on board.</li></ul>



<p>Which one is it? In KiCad, look at the spice model editor:</p>



<figure class="wp-block-image size-full"><a href="https://www.sandyscott.net/wp-content/uploads/2022/03/image-1.png"><img decoding="async" width="348" height="116" src="https://www.sandyscott.net/wp-content/uploads/2022/03/image-1.png" alt="" class="wp-image-848" srcset="https://www.sandyscott.net/wp-content/uploads/2022/03/image-1.png 348w, https://www.sandyscott.net/wp-content/uploads/2022/03/image-1-300x100.png 300w, https://www.sandyscott.net/wp-content/uploads/2022/03/image-1-150x50.png 150w" sizes="(max-width: 348px) 100vw, 348px" /></a><figcaption>The first highlighted text shows that this is a .MODEL</figcaption></figure>



<h2 class="wp-block-heading">.MODEL</h2>



<p>To get the information you need, you&#8217;ll need to <a href="http://ngspice.sourceforge.net/docs/ngspice-html-manual/manual.xhtml#magicparlabel-952">look at the ngspice manual</a>.</p>



<p>This includes the <a href="http://ngspice.sourceforge.net/docs/ngspice-html-manual/manual.xhtml#magicparlabel-952">list of 17 standard models</a> (reproduced here):</p>



<figure class="wp-block-table"><table><tbody><tr><td>Code</td><td>Model Type</td></tr><tr><td>R</td><td>Semiconductor resistor model</td></tr><tr><td>C</td><td>Semiconductor capacitor model</td></tr><tr><td>L</td><td>Inductor model</td></tr><tr><td>SW</td><td>Voltage controlled switch</td></tr><tr><td>CSW</td><td>Current controlled switch</td></tr><tr><td>URC</td><td>Uniform distributed RC model</td></tr><tr><td>LTRA</td><td>Lossy transmission line model</td></tr><tr><td>D</td><td>Diode model</td></tr><tr><td>NPN</td><td>NPN BJT model</td></tr><tr><td>PNP</td><td>PNP BJT model</td></tr><tr><td>NJF</td><td>N-channel JFET model</td></tr><tr><td>PJF</td><td>P-channel JFET model</td></tr><tr><td>NMOS</td><td>N-channel MOSFET model</td></tr><tr><td>PMOS</td><td>P-channel MOSFET model</td></tr><tr><td>NMF</td><td>N-channel MESFET model</td></tr><tr><td>PMF</td><td>P-channel MESFET model</td></tr><tr><td>VDMOS</td><td>Power MOS model</td></tr></tbody></table></figure>



<p>Go back to KiCad Spice Model Editor</p>



<figure class="wp-block-image size-full is-style-default"><a href="https://www.sandyscott.net/wp-content/uploads/2022/03/image-1.png"><img decoding="async" width="348" height="116" src="https://www.sandyscott.net/wp-content/uploads/2022/03/image-1.png" alt="" class="wp-image-848" srcset="https://www.sandyscott.net/wp-content/uploads/2022/03/image-1.png 348w, https://www.sandyscott.net/wp-content/uploads/2022/03/image-1-300x100.png 300w, https://www.sandyscott.net/wp-content/uploads/2022/03/image-1-150x50.png 150w" sizes="(max-width: 348px) 100vw, 348px" /></a><figcaption>The second highlighted text shows that this is an NPN BJT.</figcaption></figure>



<p>So, now look at <a href="http://ngspice.sourceforge.net/docs/ngspice-html-manual/manual.xhtml#magicparlabel-8435">the section of the ngspice manual for BJTs</a>:</p>



<figure class="wp-block-image size-full"><a href="https://www.sandyscott.net/wp-content/uploads/2022/03/image-3.png"><img decoding="async" width="687" height="361" src="https://www.sandyscott.net/wp-content/uploads/2022/03/image-3.png" alt="" class="wp-image-850" srcset="https://www.sandyscott.net/wp-content/uploads/2022/03/image-3.png 687w, https://www.sandyscott.net/wp-content/uploads/2022/03/image-3-300x158.png 300w, https://www.sandyscott.net/wp-content/uploads/2022/03/image-3-150x79.png 150w" sizes="(max-width: 687px) 100vw, 687px" /></a></figure>



<p>This tells us that ngspice expects the nodes to be listed in the order <strong>collector</strong>, <strong>base</strong>, <strong>emitter</strong>.</p>



<p>We&#8217;ll use this later.</p>



<h2 class="wp-block-heading">.SUBCKT</h2>



<p>Sub-circuits can be easy to figure out, or they can be hard, depending on whether the creator of the model has made sensible choices about the node names.</p>



<p>Look at the KiCad Spice Model Editor &#8211; this example is from a manufacturer spice model of an N-channel MOSFET, that has chosen to use .SUBCKT instead of .MODEL:</p>



<figure class="wp-block-image size-full"><a href="https://www.sandyscott.net/wp-content/uploads/2022/03/image-4.png"><img loading="lazy" decoding="async" width="365" height="134" src="https://www.sandyscott.net/wp-content/uploads/2022/03/image-4.png" alt="" class="wp-image-851" srcset="https://www.sandyscott.net/wp-content/uploads/2022/03/image-4.png 365w, https://www.sandyscott.net/wp-content/uploads/2022/03/image-4-300x110.png 300w, https://www.sandyscott.net/wp-content/uploads/2022/03/image-4-150x55.png 150w" sizes="(max-width: 365px) 100vw, 365px" /></a><figcaption>The stuff immediately after the .SUBCKT is what we need &#8211; the first thing is the type of device, the next 3 items are the nodes, helpfully lablled as <strong>drain</strong>, <strong>gate </strong>and <strong>source </strong>in that order.</figcaption></figure>



<h2 class="wp-block-heading">Alternate Node Sequence</h2>



<p>Now we&#8217;re ready to fill in the Alternate Node Sequence box in KiCad:</p>



<figure class="wp-block-image size-full"><a href="https://www.sandyscott.net/wp-content/uploads/2022/03/image-5.png"><img loading="lazy" decoding="async" width="365" height="51" src="https://www.sandyscott.net/wp-content/uploads/2022/03/image-5.png" alt="" class="wp-image-852" srcset="https://www.sandyscott.net/wp-content/uploads/2022/03/image-5.png 365w, https://www.sandyscott.net/wp-content/uploads/2022/03/image-5-300x42.png 300w, https://www.sandyscott.net/wp-content/uploads/2022/03/image-5-150x21.png 150w" sizes="(max-width: 365px) 100vw, 365px" /></a></figure>



<p>In this you write a list of the <strong>pin numbers</strong>, separated by spaces, in the correct <strong>node sequence</strong>.</p>



<p>e.g. for our BJT example we know that the correct node sequence is</p>



<p><strong><em>collector, base, emmitter</em></strong></p>



<p>Recall our pin assigments:</p>



<ol class="wp-block-list"><li>Emitter</li><li>Base</li><li>Collector</li></ol>



<p>So I&#8217;ll rewrite the node sequence with the pin number in brackets:</p>



<p><strong><em>collector (3), base(2), emmitter(1)</em></strong></p>



<p>Now all we need are the pin numbers, so strip out everything else:</p>



<p><strong><em>3 2 1</em></strong></p>



<p>And put that in the Alternate Node Sequence box:</p>



<figure class="wp-block-image size-full"><a href="https://www.sandyscott.net/wp-content/uploads/2022/03/image-6.png"><img loading="lazy" decoding="async" width="242" height="37" src="https://www.sandyscott.net/wp-content/uploads/2022/03/image-6.png" alt="" class="wp-image-853" srcset="https://www.sandyscott.net/wp-content/uploads/2022/03/image-6.png 242w, https://www.sandyscott.net/wp-content/uploads/2022/03/image-6-150x23.png 150w" sizes="(max-width: 242px) 100vw, 242px" /></a><figcaption>Hit OK and we&#8217;re done!</figcaption></figure>
]]></content:encoded>
					
					<wfw:commentRss>https://www.sandyscott.net/2022/03/kicad-simulation-node-sequence/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
		<item>
		<title>Backup</title>
		<link>https://www.sandyscott.net/2022/02/backup/</link>
					<comments>https://www.sandyscott.net/2022/02/backup/#respond</comments>
		
		<dc:creator><![CDATA[Sandy]]></dc:creator>
		<pubDate>Mon, 21 Feb 2022 22:04:43 +0000</pubDate>
				<category><![CDATA[Computers]]></category>
		<category><![CDATA[Software]]></category>
		<category><![CDATA[backup]]></category>
		<category><![CDATA[Linux]]></category>
		<guid isPermaLink="false">https://www.sandyscott.net/?p=838</guid>

					<description><![CDATA[I&#8217;ve been using SpiderOak for backup, and to cut a long story short it&#8217;s becoming tiresome. In fairness, it&#8217;s not really meant for backing up servers, but there&#8217;s still a lot of things it could do better. So I&#8217;m on the hunt for an offsite backup solution for this server....<p> <a class="continue-reading-link" href="https://www.sandyscott.net/2022/02/backup/"><span>Continue reading</span><i class="crycon-right-dir"></i></a> </p>]]></description>
										<content:encoded><![CDATA[
<p>I&#8217;ve been using SpiderOak for backup, and to cut a long story short it&#8217;s becoming tiresome. In fairness, it&#8217;s not really meant for backing up servers, but there&#8217;s still a lot of things it could do better.</p>



<p>So I&#8217;m on the hunt for an offsite backup solution for this server.</p>



<p>This is Linux, so nothing is simple &#8211; the solution is divided into two pieces:</p>



<ul class="wp-block-list"><li>Remote data storage service &#8211; to actually hold the data.</li><li>Backup software &#8211; to figure out what needs to be uploaded, and keep track of versions and suchlike.</li></ul>



<p>For the remote side I&#8217;ve got three real options:</p>



<ul class="wp-block-list"><li>rsync.net &#8211; starts at $10/mo for 400 GB</li><li>Backblaze B2 &#8211; starts at $5/mo for 1TB</li><li>Wasabi &#8211; starts at $5.99/mo for 1TB</li></ul>



<p>However, although rsync.net looks pretty simple &#8211; the price isn&#8217;t competitive. Backblaze B2 and Wasabi are similar &#8211; the benefit of Wasabi is that the&#8217;s no extra charges for downloads &#8211; B2 has a 1GB daily download threshold, and you start getting charged if you go over that.</p>



<p>For the backup software. These are the options I&#8217;m looking at. Please note that tools like rsync and rclone aren&#8217;t backup tools &#8211; they&#8217;re just for syncing, so don&#8217;t manage the versions or encryption</p>



<ul class="wp-block-list"><li>duplicity</li><li>borg</li><li>restic</li><li>duplicacy</li><li>Duplicati</li></ul>



<h3 class="wp-block-heading" id="duplicacy">Duplicacy</h3>



<p>I&#8217;m going to rule this one out right away it&#8217;s not free &#8211; I&#8217;m only mentioning it because it&#8217;s often included in conversations about Linux backup software.</p>



<h3 class="wp-block-heading" id="duplicity">Duplicity</h3>



<p>Duplicity has been described as an <a href="https://www.backblaze.com/blog/backing-linux-backblaze-b2-duplicity-restic/">old-school approach by this Backblaze blog post</a>. That means it&#8217;s the model whereby you create a backup of everything &#8211; a <strong>full backup</strong>, then the next time you back up you only back up what&#8217;s changed &#8211; that&#8217;s an <strong>incremental backup</strong>. This can be space-efficient and fast and easy to understand, but the downside is to do a restore you need the last full backup, and all the incremental backups since then. This then creates headaches about deciding when to create a new full backup and how often to get rid of the old ones. Having said that it&#8217;s a respected and reliable tool which supports everything it needs to: Encryption, Compression, Backblaze B2 storage is supported, Wasabi is not.</p>



<h3 class="wp-block-heading" id="restic">Restic</h3>



<p>The same article describes Restic as the new-school tool &#8211; which supports deduplication to save space. There isn&#8217;t a version 1.0.0 yet, but it seems to be fairly popular already, and supports B2 storage &amp; Wasabi.</p>



<h3 class="wp-block-heading" id="borg">Borg</h3>



<p>Borg is also a deduplicating backup software &#8211; seems to be a bit less fashionable that restic, a bit more mature. As far as I can tell the key advantage that Borg offers is compression, but can be slower with large respositories and large files because it&#8217;s single-threaded. However it doesn&#8217;t natively support remote object storage, so needs another tool to upload the data. <a href="https://forum.rclone.org/t/borgbackup-backblaze-b2-uploading/3679/5">See this forum post</a>. It has some nice features, like the ability to mount a backup as a FUSE filesystem so you can browse it.</p>



<h3 class="wp-block-heading" id="duplicati">Duplicati</h3>



<p>Not sure which type of tool this is. It does support B2 storage, but not Wasabi. Some people have had issues with reliability with it.</p>



<h2 class="wp-block-heading" id="final-thoughts">Final Thoughts</h2>



<p>I&#8217;ve gone with restic and Backblaze B2. They can talk to each other directly, but I like the idea of having a local copy of the repo, so I&#8217;ve set restic to backup to a portable HDD, the which then is copied to Backblaze. This means I have the offsite copy in case my house burns down but can still get at the data in more mundane scenarios.</p>
]]></content:encoded>
					
					<wfw:commentRss>https://www.sandyscott.net/2022/02/backup/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
		<item>
		<title>Linux software updates &#8211; How to resolve changed configuration files.</title>
		<link>https://www.sandyscott.net/2021/04/linux-software-updates-how-to-resolve-changed-configuration-files/</link>
					<comments>https://www.sandyscott.net/2021/04/linux-software-updates-how-to-resolve-changed-configuration-files/#respond</comments>
		
		<dc:creator><![CDATA[Sandy]]></dc:creator>
		<pubDate>Fri, 02 Apr 2021 15:46:00 +0000</pubDate>
				<category><![CDATA[Computers]]></category>
		<category><![CDATA[Software]]></category>
		<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[apt]]></category>
		<category><![CDATA[Debian]]></category>
		<category><![CDATA[dpkg]]></category>
		<guid isPermaLink="false">https://www.sandyscott.net/?p=821</guid>

					<description><![CDATA[Sometimes, when you&#8217;re updating software on your Linux machine, the person maintaining the package will have also updated the default configuration file that ships with the software. This is an issue if you have customised that configuration file on your system &#8211; the system doesn&#8217;t know whether it should keep...<p> <a class="continue-reading-link" href="https://www.sandyscott.net/2021/04/linux-software-updates-how-to-resolve-changed-configuration-files/"><span>Continue reading</span><i class="crycon-right-dir"></i></a> </p>]]></description>
										<content:encoded><![CDATA[
<p>Sometimes, when you&#8217;re updating software on your Linux machine, the person maintaining the package will have also updated the default configuration file that ships with the software.</p>



<p>This is an issue if you have customised that configuration file on your system &#8211; the system doesn&#8217;t know whether it should keep your version, use the new one, or something else. So it asks you to decide what to do about it.</p>



<p>I&#8217;m using Debian, which uses the <code>dpkg </code>package management system &#8211; that name may be unfamiliar, but if you&#8217;ve used any of the Debain family (Ubuntu, Mint, MX, elementary etc.) you will have used one of the friendlier wrappers around it: <code>apt </code>or <code>apt-get</code>.</p>



<p>Today, it&#8217;s the Collabora Office configuration file that has been updated:</p>



<div class="wp-block-codemirror-blocks-code-block code-block"><pre class="CodeMirror" data-setting="{&quot;showPanel&quot;:false,&quot;languageLabel&quot;:&quot;language&quot;,&quot;fullScreenButton&quot;:true,&quot;copyButton&quot;:true,&quot;mode&quot;:&quot;htmlmixed&quot;,&quot;mime&quot;:&quot;text/html&quot;,&quot;theme&quot;:&quot;material&quot;,&quot;lineNumbers&quot;:false,&quot;styleActiveLine&quot;:false,&quot;lineWrapping&quot;:false,&quot;readOnly&quot;:true,&quot;fileName&quot;:&quot;&quot;,&quot;language&quot;:&quot;HTML&quot;,&quot;maxHeight&quot;:&quot;400px&quot;,&quot;modeName&quot;:&quot;html&quot;}">Configuration file '/etc/loolwsd/loolwsd.xml'
 ==&gt; Modified (by you or by a script) since installation.
 ==&gt; Package distributor has shipped an updated version.
   What would you like to do about it ? Your options are:
    Y or I : install the package maintainer's version
    N or O : keep your currently-installed version
      D    : show the differences between the versions
      Z    : start a shell to examine the situation
 The default action is to keep your current version.
*** loolwsd.xml (Y/I/N/O/D/Z) [default=N] ?</pre></div>



<ul class="wp-block-list"><li>The first option is self-explanatory &#8211; you&#8217;ll lose any customizations you&#8217;ve made, but that might be OK for you.</li><li>Keeping your currently-installed version is usually OK &#8211; well designed software shouldn&#8217;t break because it&#8217;s missing a line in an old configuration file.</li></ul>



<p>In either case the system will keep a copy of the one you don&#8217;t pick, so you can change your mind later. If you choose to use the package mantainer&#8217;s version, there will be a copy of your old one with <code>.dpkg-old</code> added to the filename. If you keep you own config file, the package maintainer&#8217;s version will be saved alongside it, with <code>.dpkg-dist</code> added to the filename.</p>



<ul class="wp-block-list"><li>Choosing option D can help you decide &#8211; but ultimately doesn&#8217;t resolve the situation.</li><li>Option Z is the point of today&#8217;s post &#8211; this is how you can fix the situation.</li></ul>



<p>Lets hit Z, and this is what I get:</p>



<div class="wp-block-codemirror-blocks-code-block code-block"><pre class="CodeMirror" data-setting="{&quot;showPanel&quot;:false,&quot;languageLabel&quot;:&quot;language&quot;,&quot;fullScreenButton&quot;:true,&quot;copyButton&quot;:true,&quot;mode&quot;:&quot;htmlmixed&quot;,&quot;mime&quot;:&quot;text/html&quot;,&quot;theme&quot;:&quot;material&quot;,&quot;lineNumbers&quot;:false,&quot;styleActiveLine&quot;:false,&quot;lineWrapping&quot;:false,&quot;readOnly&quot;:true,&quot;fileName&quot;:&quot;&quot;,&quot;language&quot;:&quot;HTML&quot;,&quot;maxHeight&quot;:&quot;400px&quot;,&quot;modeName&quot;:&quot;html&quot;}"> The default action is to keep your current version.
*** loolwsd.xml (Y/I/N/O/D/Z) [default=N] ? Z
Useful environment variables:
 - DPKG_SHELL_REASON
 - DPKG_CONFFILE_OLD
 - DPKG_CONFFILE_NEW
Type 'exit' when you're done.
root@waldorf:/# </pre></div>



<p>The system tells you about 3 environment variables that might be useful to help fix the situation. here I&#8217;ve use the echo command (with a $ before the environment variable name) to see what&#8217;s in them:</p>



<div class="wp-block-codemirror-blocks-code-block code-block"><pre class="CodeMirror" data-setting="{&quot;showPanel&quot;:false,&quot;languageLabel&quot;:&quot;language&quot;,&quot;fullScreenButton&quot;:true,&quot;copyButton&quot;:true,&quot;mode&quot;:&quot;htmlmixed&quot;,&quot;mime&quot;:&quot;text/html&quot;,&quot;theme&quot;:&quot;material&quot;,&quot;lineNumbers&quot;:false,&quot;styleActiveLine&quot;:false,&quot;lineWrapping&quot;:false,&quot;readOnly&quot;:true,&quot;fileName&quot;:&quot;&quot;,&quot;language&quot;:&quot;HTML&quot;,&quot;maxHeight&quot;:&quot;400px&quot;,&quot;modeName&quot;:&quot;html&quot;}">root@waldorf:/# echo $DPKG_SHELL_REASON
conffile-prompt
root@waldorf:/# echo $DPKG_CONFFILE_OLD
/etc/loolwsd/loolwsd.xml
root@waldorf:/# echo $DPKG_CONFFILE_NEW
/etc/loolwsd/loolwsd.xml.dpkg-new</pre></div>



<p>DPKG_CONFFILE_PROMPT isn&#8217;t much use to us, but the other two are. We can start a program to compare and merge the differences between the two. I&#8217;m using Neovim in diff mode &#8211; there are lots of otherways of doing this &#8211; I&#8217;d suggest you do your research and find your preferred merge tool or text editor.</p>



<div class="wp-block-codemirror-blocks-code-block code-block"><pre class="CodeMirror" data-setting="{&quot;showPanel&quot;:false,&quot;languageLabel&quot;:&quot;language&quot;,&quot;fullScreenButton&quot;:true,&quot;copyButton&quot;:true,&quot;mode&quot;:&quot;htmlmixed&quot;,&quot;mime&quot;:&quot;text/html&quot;,&quot;theme&quot;:&quot;material&quot;,&quot;lineNumbers&quot;:false,&quot;styleActiveLine&quot;:false,&quot;lineWrapping&quot;:false,&quot;readOnly&quot;:true,&quot;fileName&quot;:&quot;&quot;,&quot;language&quot;:&quot;HTML&quot;,&quot;maxHeight&quot;:&quot;400px&quot;,&quot;modeName&quot;:&quot;html&quot;}">root@waldorf:/# nvim -d $DPKG_CONFFILE_OLD $DPKG_CONFFILE_NEW</pre></div>



<p>I wont to get into the details of how to use [Neo]vim, but if you&#8217;re already a vim user and haven&#8217;t used diff mode before, these commands will get you started. <a href="https://neovim.io/doc/user/diff.html">You can find more info in the documentation.</a></p>



<figure class="wp-block-table"><table><tbody><tr><td><strong>Keystrokes</strong></td><td><strong>Command</strong></td></tr><tr><td>&lt;Ctrl-w&gt; l</td><td>Move to the right window</td></tr><tr><td>&lt;Ctrl-w&gt; h</td><td>Move to the left window</td></tr><tr><td>]c</td><td>Move to the next change</td></tr><tr><td>[c</td><td>Move to the previous change</td></tr><tr><td>:diffget</td><td>Copy the change you&#8217;re on from the other window</td></tr><tr><td>:diffput</td><td>Push the change from your current window into the other one.</td></tr></tbody></table></figure>



<dl class="wp-block-simple-definition-list-blocks-list"></dl>



<p>Note that the last two commands will make the files the same at that point</p>



<p>Modifiy one of the files (I typically modify my old file &#8211; pulling the changes from the new one that I want, and leaving the ones that I don&#8217;t), then save and exit your text editor or mergetool</p>



<p>Type exit at the prompt, then the system will ask you again what you want to do:</p>



<div class="wp-block-codemirror-blocks-code-block code-block"><pre class="CodeMirror" data-setting="{&quot;showPanel&quot;:false,&quot;languageLabel&quot;:&quot;language&quot;,&quot;fullScreenButton&quot;:true,&quot;copyButton&quot;:true,&quot;mode&quot;:&quot;shell&quot;,&quot;mime&quot;:&quot;text/x-sh&quot;,&quot;theme&quot;:&quot;material&quot;,&quot;lineNumbers&quot;:false,&quot;styleActiveLine&quot;:false,&quot;lineWrapping&quot;:false,&quot;readOnly&quot;:true,&quot;fileName&quot;:&quot;&quot;,&quot;language&quot;:&quot;Shell&quot;,&quot;maxHeight&quot;:&quot;400px&quot;,&quot;modeName&quot;:&quot;shell&quot;}">*** loolwsd.xml (Y/I/N/O/D/Z) [default=N] ?</pre></div>



<p>In this case I&#8217;ll choose N or O because I&#8217;ve made the changes I want to the original config file.</p>
]]></content:encoded>
					
					<wfw:commentRss>https://www.sandyscott.net/2021/04/linux-software-updates-how-to-resolve-changed-configuration-files/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
		<item>
		<title>Install Sage Math from source on WSL</title>
		<link>https://www.sandyscott.net/2020/12/install-sage-math-from-source-on-wsl/</link>
					<comments>https://www.sandyscott.net/2020/12/install-sage-math-from-source-on-wsl/#comments</comments>
		
		<dc:creator><![CDATA[Sandy]]></dc:creator>
		<pubDate>Wed, 02 Dec 2020 15:59:14 +0000</pubDate>
				<category><![CDATA[Computers]]></category>
		<category><![CDATA[Software]]></category>
		<category><![CDATA[Linux]]></category>
		<category><![CDATA[Sage]]></category>
		<category><![CDATA[sagemath]]></category>
		<category><![CDATA[WSL]]></category>
		<guid isPermaLink="false">https://www.sandyscott.net/?p=747</guid>

					<description><![CDATA[Here&#8217;s how I got a fully featured Sage Math install on my system. I did this because I wanted to run on windows, and still be able to install packages, which isn&#8217;t possible with the precompiled binary. Basic process: Enable hardware assisted virtualization. Set up WSL (Windows Subsystem for Linux)...<p> <a class="continue-reading-link" href="https://www.sandyscott.net/2020/12/install-sage-math-from-source-on-wsl/"><span>Continue reading</span><i class="crycon-right-dir"></i></a> </p>]]></description>
										<content:encoded><![CDATA[
<p>Here&#8217;s how I got a fully featured Sage Math install on my system. I did this because I wanted to run on windows, and still be able to install packages, which isn&#8217;t possible with the precompiled binary.</p>



<h2 class="wp-block-heading">Basic process:</h2>



<ol class="wp-block-list"><li>Enable hardware assisted virtualization.</li><li>Set up WSL (Windows Subsystem for Linux)</li><li>Install Linux into WSL</li><li>Download and compile Sage</li><li>Configure JupyterLab</li><li>Make it easy to start from windows</li></ol>



<h2 class="wp-block-heading">Enable hardware assisted virtualization</h2>



<p>WSL requires that your system supports hardware assisted virtualization (which pretty much all modern systems do), there are 3 things that you need to get it working:</p>



<ul class="wp-block-list"><li>The CPU must support it</li><li>The motherboard must support it.</li><li>You need to enable it in the EFI (or BIOS)</li></ul>



<p>This article takes you through getting everything sorted out:</p>



<p><a href="https://support.bluestacks.com/hc/en-us/articles/115003174386-How-to-enable-Virtualization-VT-on-Windows-10-for-BlueStacks-4">https://support.bluestacks.com/hc/en-us/articles/115003174386-How-to-enable-Virtualization-VT-on-Windows-10-for-BlueStacks-4</a></p>



<h2 class="wp-block-heading">Set up WSL 2</h2>



<p>Follow this guide: <a href="https://docs.microsoft.com/en-us/windows/wsl/install-win10">https://docs.microsoft.com/en-us/windows/wsl/install-win10</a></p>



<h2 class="wp-block-heading">Install and configure Linux:</h2>



<ol class="wp-block-list"><li>Go to the Microsoft store and install Ubuntu.</li></ol>



<p>Note: If you already have Ubuntu installed, I&#8217;d recommend you follow these instructions to set up a separate, clean install for sage: <a href="https://hfakhraei.github.io/Install-multiple-instance-of-same-Linux-Distribution-on-WSL">https://hfakhraei.github.io/Install-multiple-instance-of-same-Linux-Distribution-on-WSL</a></p>



<ol class="wp-block-list" start="2"><li>Start Ubuntu from the start menu. A command window should pop up.</li><li>Run these commands to update Ubuntu:</li></ol>



<div class="wp-block-codemirror-blocks-code-block code-block"><pre class="CodeMirror" data-setting="{&quot;showPanel&quot;:false,&quot;languageLabel&quot;:&quot;language&quot;,&quot;fullScreenButton&quot;:true,&quot;copyButton&quot;:true,&quot;mode&quot;:&quot;shell&quot;,&quot;mime&quot;:&quot;text/x-sh&quot;,&quot;theme&quot;:&quot;material&quot;,&quot;lineNumbers&quot;:false,&quot;styleActiveLine&quot;:false,&quot;lineWrapping&quot;:false,&quot;readOnly&quot;:true,&quot;fileName&quot;:&quot;&quot;,&quot;language&quot;:&quot;Shell&quot;,&quot;maxHeight&quot;:&quot;400px&quot;,&quot;modeName&quot;:&quot;shell&quot;}">    sudo apt update
    sudo apt upgrade</pre></div>



<ol class="wp-block-list" start="4"><li>Reboot by going (in Windows) to Services and restarting the LxssManager. You can also shut down all running WSL instances using the command <code>wsl --shutdown</code> in the Windows command prompt or Powershell.</li><li>If necessary upgrade to the latest release: <a href="https://linuxconfig.org/how-to-upgrade-ubuntu-to-20-10">https://linuxconfig.org/how-to-upgrade-ubuntu-to-20-10</a></li></ol>



<h2 class="wp-block-heading">Set up Sage</h2>



<p>These instructions are a simplified version of the official documentation: <a href="https://doc.sagemath.org/html/en/installation/source.html">https://doc.sagemath.org/html/en/installation/source.html</a></p>



<ol class="wp-block-list"><li>Start Ubuntu &#8211; All the commands in this section should be run on the Ubuntu installation.</li><li>Install the packages we need to have ready in advance:</li></ol>



<div class="wp-block-codemirror-blocks-code-block code-block"><pre class="CodeMirror" data-setting="{&quot;showPanel&quot;:false,&quot;languageLabel&quot;:&quot;language&quot;,&quot;fullScreenButton&quot;:true,&quot;copyButton&quot;:true,&quot;mode&quot;:&quot;shell&quot;,&quot;mime&quot;:&quot;text/x-sh&quot;,&quot;theme&quot;:&quot;material&quot;,&quot;lineNumbers&quot;:false,&quot;styleActiveLine&quot;:false,&quot;lineWrapping&quot;:true,&quot;readOnly&quot;:true,&quot;fileName&quot;:&quot;&quot;,&quot;language&quot;:&quot;Shell&quot;,&quot;maxHeight&quot;:&quot;400px&quot;,&quot;modeName&quot;:&quot;shell&quot;}">sudo apt install bc binutils bzip2 ca-certificates cliquer cmake coinor-cbc coinor-libcbc-dev curl default-jdk dvipng eclib-tools fflas-ffpack ffmpeg flintqs g++ gcc gfan gfortran git glpk-utils gmp-ecm imagemagick latexmk lcalc libatomic-ops-dev libavdevice-dev libboost-dev libbraiding-dev libbrial-dev libbrial-groebner-dev libbz2-dev libcdd-dev libcdd-tools libcliquer-dev libcurl4-openssl-dev libec-dev libecm-dev libffi-dev libfile-slurp-perl libflint-arb-dev libflint-dev libfreetype6-dev libgc-dev libgd-dev libgf2x-dev libgiac-dev libgivaro-dev libglpk-dev libgmp-dev libgsl-dev libiml-dev libisl-dev libjson-perl liblfunction-dev liblrcalc-dev liblzma-dev libm4rie-dev libmongodb-perl libmpc-dev libmpfi-dev libmpfr-dev libnauty-dev libncurses5-dev libntl-dev libopenblas-dev libpari-dev libpcre3-dev libperl-dev libplanarity-dev libppl-dev libpython3-dev libreadline-dev librw-dev libsqlite3-dev libssl-dev libsuitesparse-dev libsvg-perl libsymmetrica2-dev libterm-readkey-perl libterm-readline-gnu-perl libxml2-dev libxml-libxslt-perl libxml-writer-perl libz-dev libzmq3-dev libzn-poly-dev m4 make nauty ninja-build openssl palp pandoc pari-doc pari-elldata pari-galdata pari-galpol pari-gp2c pari-seadata patch perl pkg-config planarity ppl-dev python3 python3-distutils r-base-dev r-cran-lattice sqlite3 sympow tachyon tar texlive texlive-xetex xcas xz-utils yasm</pre></div>



<ol class="wp-block-list" start="3"><li>Download and extract the source tarball into a subfolder of your home directory</li></ol>



<div class="wp-block-codemirror-blocks-code-block code-block"><pre class="CodeMirror" data-setting="{&quot;showPanel&quot;:false,&quot;languageLabel&quot;:&quot;language&quot;,&quot;fullScreenButton&quot;:true,&quot;copyButton&quot;:true,&quot;mode&quot;:&quot;shell&quot;,&quot;mime&quot;:&quot;text/x-sh&quot;,&quot;theme&quot;:&quot;material&quot;,&quot;lineNumbers&quot;:false,&quot;styleActiveLine&quot;:false,&quot;lineWrapping&quot;:false,&quot;readOnly&quot;:true,&quot;fileName&quot;:&quot;&quot;,&quot;language&quot;:&quot;Shell&quot;,&quot;maxHeight&quot;:&quot;400px&quot;,&quot;modeName&quot;:&quot;shell&quot;}">cd ~
wget http://www.mirrorservice.org/sites/www.sagemath.org/src/sage-9.2.tar.gz
tar xvf sage-9.2.tar.gz</pre></div>



<ol class="wp-block-list" start="4"><li>Start building</li></ol>



<div class="wp-block-codemirror-blocks-code-block code-block"><pre class="CodeMirror" data-setting="{&quot;showPanel&quot;:false,&quot;languageLabel&quot;:&quot;language&quot;,&quot;fullScreenButton&quot;:true,&quot;copyButton&quot;:true,&quot;mode&quot;:&quot;shell&quot;,&quot;mime&quot;:&quot;text/x-sh&quot;,&quot;theme&quot;:&quot;material&quot;,&quot;lineNumbers&quot;:false,&quot;styleActiveLine&quot;:false,&quot;lineWrapping&quot;:false,&quot;readOnly&quot;:true,&quot;fileName&quot;:&quot;&quot;,&quot;language&quot;:&quot;Shell&quot;,&quot;maxHeight&quot;:&quot;400px&quot;,&quot;modeName&quot;:&quot;shell&quot;}">cd sage-9.2/
./configure
make</pre></div>



<p>This will take a long time (3 hours on my system)</p>



<ol class="wp-block-list" start="5"><li>Test sage</li></ol>



<div class="wp-block-codemirror-blocks-code-block code-block"><pre class="CodeMirror" data-setting="{&quot;showPanel&quot;:false,&quot;languageLabel&quot;:&quot;language&quot;,&quot;fullScreenButton&quot;:true,&quot;copyButton&quot;:true,&quot;mode&quot;:&quot;shell&quot;,&quot;mime&quot;:&quot;text/x-sh&quot;,&quot;theme&quot;:&quot;material&quot;,&quot;lineNumbers&quot;:false,&quot;styleActiveLine&quot;:false,&quot;lineWrapping&quot;:false,&quot;readOnly&quot;:true,&quot;fileName&quot;:&quot;&quot;,&quot;language&quot;:&quot;Shell&quot;,&quot;maxHeight&quot;:&quot;400px&quot;,&quot;modeName&quot;:&quot;shell&quot;}">./sage</pre></div>



<p>You should get a prompt that looks like this:</p>



<div class="wp-block-codemirror-blocks-code-block code-block"><pre class="CodeMirror" data-setting="{&quot;showPanel&quot;:false,&quot;languageLabel&quot;:&quot;language&quot;,&quot;fullScreenButton&quot;:true,&quot;copyButton&quot;:true,&quot;mode&quot;:&quot;shell&quot;,&quot;mime&quot;:&quot;text/x-sh&quot;,&quot;theme&quot;:&quot;material&quot;,&quot;lineNumbers&quot;:false,&quot;styleActiveLine&quot;:false,&quot;lineWrapping&quot;:false,&quot;readOnly&quot;:true,&quot;fileName&quot;:&quot;&quot;,&quot;language&quot;:&quot;Shell&quot;,&quot;maxHeight&quot;:&quot;400px&quot;,&quot;modeName&quot;:&quot;shell&quot;}">┌────────────────────────────────────────────────────────────────────┐
│ SageMath version 9.2, Release Date: 2020-10-24                     │
│ Using Python 3.8.6. Type &quot;help()&quot; for help.                        │
└────────────────────────────────────────────────────────────────────┘
sage:</pre></div>



<ol class="wp-block-list" start="6"><li>Type <code>exit </code>and press enter to leave.</li></ol>



<ol class="wp-block-list" start="7"><li>Make the command available from anywhere on this ubuntu system &#8211; edit ~/.bashrc and add this line:</li></ol>



<div class="wp-block-codemirror-blocks-code-block code-block"><pre class="CodeMirror" data-setting="{&quot;showPanel&quot;:false,&quot;languageLabel&quot;:&quot;language&quot;,&quot;fullScreenButton&quot;:true,&quot;copyButton&quot;:true,&quot;mode&quot;:&quot;shell&quot;,&quot;mime&quot;:&quot;text/x-sh&quot;,&quot;theme&quot;:&quot;material&quot;,&quot;lineNumbers&quot;:false,&quot;styleActiveLine&quot;:false,&quot;lineWrapping&quot;:false,&quot;readOnly&quot;:true,&quot;fileName&quot;:&quot;&quot;,&quot;language&quot;:&quot;Shell&quot;,&quot;maxHeight&quot;:&quot;400px&quot;,&quot;modeName&quot;:&quot;shell&quot;}">alias sage=~/sage-9.2/sage</pre></div>



<ol class="wp-block-list" start="8"><li>Close ubuntu then reopen it.</li><li>Try typing <code>sage</code> and verify that it starts.</li></ol>



<h2 class="wp-block-heading">JupyterLab</h2>



<ol class="wp-block-list"><li>Install Jupyter Lab and it&#8217;s extras:</li></ol>



<div class="wp-block-codemirror-blocks-code-block code-block"><pre class="CodeMirror" data-setting="{&quot;showPanel&quot;:false,&quot;languageLabel&quot;:&quot;language&quot;,&quot;fullScreenButton&quot;:true,&quot;copyButton&quot;:true,&quot;mode&quot;:&quot;shell&quot;,&quot;mime&quot;:&quot;text/x-sh&quot;,&quot;theme&quot;:&quot;material&quot;,&quot;lineNumbers&quot;:false,&quot;styleActiveLine&quot;:false,&quot;lineWrapping&quot;:false,&quot;readOnly&quot;:true,&quot;fileName&quot;:&quot;&quot;,&quot;language&quot;:&quot;Shell&quot;,&quot;maxHeight&quot;:&quot;400px&quot;,&quot;modeName&quot;:&quot;shell&quot;}">sage -i jupyterlab_widgets</pre></div>



<p>This also involves compliation from source, so will take a while.</p>



<ol class="wp-block-list" start="2"><li>When it&#8217;s done, try starting the jupyterlab notebook like this:</li></ol>



<div class="wp-block-codemirror-blocks-code-block code-block"><pre class="CodeMirror" data-setting="{&quot;showPanel&quot;:false,&quot;languageLabel&quot;:&quot;language&quot;,&quot;fullScreenButton&quot;:true,&quot;copyButton&quot;:true,&quot;mode&quot;:&quot;shell&quot;,&quot;mime&quot;:&quot;text/x-sh&quot;,&quot;theme&quot;:&quot;material&quot;,&quot;lineNumbers&quot;:false,&quot;styleActiveLine&quot;:false,&quot;lineWrapping&quot;:false,&quot;readOnly&quot;:true,&quot;fileName&quot;:&quot;&quot;,&quot;language&quot;:&quot;Shell&quot;,&quot;maxHeight&quot;:&quot;400px&quot;,&quot;modeName&quot;:&quot;shell&quot;}">sage --notebook jupyterlab</pre></div>



<p>You might notice a problem &#8211; the list of files only includes those on your linux machine &#8211; you probably want the ones on your windows computer. You can do this by navigating to where the windows files are mounted in linux.</p>



<ol class="wp-block-list" start="3"><li>Try it (fill in your windows username instead of the square brackets):</li></ol>



<div class="wp-block-codemirror-blocks-code-block code-block"><pre class="CodeMirror" data-setting="{&quot;showPanel&quot;:false,&quot;languageLabel&quot;:&quot;language&quot;,&quot;fullScreenButton&quot;:true,&quot;copyButton&quot;:true,&quot;mode&quot;:&quot;shell&quot;,&quot;mime&quot;:&quot;text/x-sh&quot;,&quot;theme&quot;:&quot;material&quot;,&quot;lineNumbers&quot;:false,&quot;styleActiveLine&quot;:false,&quot;lineWrapping&quot;:false,&quot;readOnly&quot;:true,&quot;fileName&quot;:&quot;&quot;,&quot;language&quot;:&quot;Shell&quot;,&quot;maxHeight&quot;:&quot;400px&quot;,&quot;modeName&quot;:&quot;shell&quot;}">cd /mnt/c/Documents\ and\ Settings\[your windows username]
sage --notebook jupyterlab</pre></div>



<p>The list of files should now be the ones in that folder on your windows machine.</p>



<ol class="wp-block-list" start="4"><li>Lets wrap this all in a script for convenience &#8211; Create a file called ~/<code>sage_nb.sh</code> and put these lines into it:</li></ol>



<div class="wp-block-codemirror-blocks-code-block code-block"><pre class="CodeMirror" data-setting="{&quot;showPanel&quot;:false,&quot;languageLabel&quot;:&quot;language&quot;,&quot;fullScreenButton&quot;:true,&quot;copyButton&quot;:true,&quot;mode&quot;:&quot;shell&quot;,&quot;mime&quot;:&quot;text/x-sh&quot;,&quot;theme&quot;:&quot;material&quot;,&quot;lineNumbers&quot;:false,&quot;styleActiveLine&quot;:false,&quot;lineWrapping&quot;:false,&quot;readOnly&quot;:true,&quot;fileName&quot;:&quot;&quot;,&quot;language&quot;:&quot;Shell&quot;,&quot;maxHeight&quot;:&quot;400px&quot;,&quot;modeName&quot;:&quot;shell&quot;}">#!/bin/bash
cd /mnt/c/Documents\ and\ Settings/[your windows username]
/home/[your linux username]/sage-9.2/sage --notebook jupyterlab</pre></div>



<ol class="wp-block-list" start="5"><li>We need to make it executable &#8211; ie. so linux will run this file like it would run a program:</li></ol>



<div class="wp-block-codemirror-blocks-code-block code-block"><pre class="CodeMirror" data-setting="{&quot;showPanel&quot;:false,&quot;languageLabel&quot;:&quot;language&quot;,&quot;fullScreenButton&quot;:true,&quot;copyButton&quot;:true,&quot;mode&quot;:&quot;shell&quot;,&quot;mime&quot;:&quot;text/x-sh&quot;,&quot;theme&quot;:&quot;material&quot;,&quot;lineNumbers&quot;:false,&quot;styleActiveLine&quot;:false,&quot;lineWrapping&quot;:false,&quot;readOnly&quot;:true,&quot;fileName&quot;:&quot;&quot;,&quot;language&quot;:&quot;Shell&quot;,&quot;maxHeight&quot;:&quot;400px&quot;,&quot;modeName&quot;:&quot;shell&quot;}">chmod ug+x sage_nb.sh</pre></div>



<ol class="wp-block-list" start="6"><li>Now go back to your home directory and try it again:</li></ol>



<div class="wp-block-codemirror-blocks-code-block code-block"><pre class="CodeMirror" data-setting="{&quot;showPanel&quot;:false,&quot;languageLabel&quot;:&quot;language&quot;,&quot;fullScreenButton&quot;:true,&quot;copyButton&quot;:true,&quot;mode&quot;:&quot;shell&quot;,&quot;mime&quot;:&quot;text/x-sh&quot;,&quot;theme&quot;:&quot;material&quot;,&quot;lineNumbers&quot;:false,&quot;styleActiveLine&quot;:false,&quot;lineWrapping&quot;:false,&quot;readOnly&quot;:true,&quot;fileName&quot;:&quot;&quot;,&quot;language&quot;:&quot;Shell&quot;,&quot;maxHeight&quot;:&quot;400px&quot;,&quot;modeName&quot;:&quot;shell&quot;}">cd ~
./sage_nb.sh</pre></div>



<p>The JupyterLab server should start, showing your windows files in the browser.</p>



<h2 class="wp-block-heading">Create windows shortcut</h2>



<p>This is a final nicety that lets you start the JupyterLab server in one click:</p>



<ol class="wp-block-list"><li>Open Windows explorer, and type %APPDATA%\Microsoft\Windows\Start Menu\Programs</li><li>Make a copy of any of the program icons &#8211; we&#8217;ll customise it to do what we want</li><li>Right-click, and choose properties.</li><li>On the General tab:<ul><li>Change the name to whatever you want.</li></ul></li><li>On the Shortcut tab:<ul><li>Change Target to: <code>ubuntu.exe run ~/sage_nb.sh</code></li><li>Change Start in to: <code>%USERPROFILE%</code></li><li>Change Run to: Minimised</li><li>Change the icon if you want &#8211; there are plenty of pieces of software that can create a <code>.ico</code> icon file one from an image file.</li></ul></li><li>Now hit the start button or key and type the name you gave it. it should appear in the list, and should load the server and fire up your browser when you click on it.</li></ol>



<dl class="wp-block-simple-definition-list-blocks-list"></dl>



<h2 class="wp-block-heading">Software versions:</h2>



<p>This is what I used when I wrote this post &#8211; you might get different results if your versions are significantly different.</p>



<ul class="wp-block-list"><li>Windows 10 Pro Version 2004 (OS Build 19041.264)</li><li>Ubuntu 20.10 (Originally installed 20.04 as 20.10 was not available in the Windows Store)</li><li>Sage 9.2</li></ul>
]]></content:encoded>
					
					<wfw:commentRss>https://www.sandyscott.net/2020/12/install-sage-math-from-source-on-wsl/feed/</wfw:commentRss>
			<slash:comments>7</slash:comments>
		
		
			</item>
		<item>
		<title>Server Setup 0: Contents</title>
		<link>https://www.sandyscott.net/2020/06/server-setup-0-contents/</link>
					<comments>https://www.sandyscott.net/2020/06/server-setup-0-contents/#respond</comments>
		
		<dc:creator><![CDATA[Sandy]]></dc:creator>
		<pubDate>Thu, 04 Jun 2020 08:29:10 +0000</pubDate>
				<category><![CDATA[Computers]]></category>
		<category><![CDATA[Apache]]></category>
		<category><![CDATA[Collabora]]></category>
		<category><![CDATA[Debian]]></category>
		<category><![CDATA[Linux]]></category>
		<category><![CDATA[Nextcloud]]></category>
		<category><![CDATA[WordPress]]></category>
		<guid isPermaLink="false">https://www.sandyscott.net/?p=666</guid>

					<description><![CDATA[Hello and welcome to my series of posts on setting up a server to run Debian Linux, hosting a WordPress and a Nextcloud installation The idea is to take you through all the steps needed to get up and running, some basic familiarity with computers and Linux is assumed, but...<p> <a class="continue-reading-link" href="https://www.sandyscott.net/2020/06/server-setup-0-contents/"><span>Continue reading</span><i class="crycon-right-dir"></i></a> </p>]]></description>
										<content:encoded><![CDATA[
<p>Hello and welcome to my series of posts on setting up a server to run Debian Linux, hosting a WordPress and a Nextcloud installation</p>



<p>The idea is to take you through all the steps needed to get up and running, some basic familiarity with computers and Linux is assumed, but not a lot.</p>



<ul class="wp-block-list"><li><a href="https://www.sandyscott.net/2020/05/18/server-setup-1-os-installation/" data-type="350">Server Setup 1: OS installation</a><br>This goes through a few pre-requisites, and then launches into the installation.</li><li><a href="https://www.sandyscott.net/2020/05/18/server-setup-2-initial-tweaks/" data-type="419">Server Setup 2: Initial tweaks</a><br>These first few steps will make your life easier when administering this server.</li><li><a href="https://www.sandyscott.net/2020/05/19/server-setup-3-install-webserver/" data-type="475">Server Setup 3: Install Webserver</a><br>We&#8217;ll install and test the webserver software &#8211; Apache.</li><li><a href="https://www.sandyscott.net/2020/05/20/server-setup-4-going-public/" data-type="508">Server Setup 4: Going Public</a><br>Configure the server, DNS and your router to allow public access to a placeholder website.</li><li><a href="https://www.sandyscott.net/2020/05/21/server-setup-5-https/" data-type="519">Server Setup 5: HTTPS</a><br>Enable secure connections to your new website with Lets Encrypt and certbot.</li><li><a href="https://www.sandyscott.net/2020/05/21/server-setup-4-wordpress-pre-requisites/" data-type="484">Server Setup 6: WordPress Pre-requisites</a><br>Get ourselves ready to install WordPress &#8211; we need PHP and a database.</li><li><a href="https://www.sandyscott.net/2020/05/21/server-setup-7-install-wordpress/" data-type="539">Server Setup 7: Install WordPress</a><br>Get WordPress installed so you have a functional website!</li><li><a href="https://www.sandyscott.net/2020/05/21/server-setup-8-wordpress-tweaks/" data-type="562">Server Setup 8: WordPress tweaks</a><br>A few tweaks to optimise WordPress.</li><li><a href="https://www.sandyscott.net/2020/05/21/server-setup-9-nextcloud-prep/" data-type="564">Server Setup 9: Nextcloud Prep</a><br>Preparatory work before the Nextcloud installation.</li><li><a href="https://www.sandyscott.net/2020/05/21/server-setup-10-nextcloud-installation/" data-type="575">Server Setup 10: Nextcloud Installation</a><br>Get the database and files system configured, then install Nextcloud</li><li><a href="https://www.sandyscott.net/2020/05/22/server-setup-11-config-improvements/" data-type="582">Server Setup 11: Config Improvements</a><br>Some little tweaks to improve the security of our server</li><li><a href="https://www.sandyscott.net/2020/05/24/server-setup-12-collabora/" data-type="612">Server Setup 12: Collabora</a><br>Install and configure Collabora Online Development Edition</li><li><a href="https://www.sandyscott.net/2020/05/25/server-setup-13-security-improvements/" data-type="621">Server Setup 13: Security Improvements</a><br>Move the WordPress configuration out of the web root</li><li><a href="https://www.sandyscott.net/2020/06/01/server-setup-14-backups/" data-type="516">Server Setup 14: Backups</a><br>This shows how to collect together all the data you need to completely back up your server.</li><li><a href="https://www.sandyscott.net/2020/06/01/server-setup-15-optional-extras/" data-type="602">Server Setup 15: Optional Extras</a><br>Further optional tweaks to make your installation better.</li></ul>



<p></p>
]]></content:encoded>
					
					<wfw:commentRss>https://www.sandyscott.net/2020/06/server-setup-0-contents/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
		<item>
		<title>Server Setup 15: Optional Extras</title>
		<link>https://www.sandyscott.net/2020/06/server-setup-15-optional-extras/</link>
					<comments>https://www.sandyscott.net/2020/06/server-setup-15-optional-extras/#respond</comments>
		
		<dc:creator><![CDATA[Sandy]]></dc:creator>
		<pubDate>Mon, 01 Jun 2020 17:56:43 +0000</pubDate>
				<category><![CDATA[Computers]]></category>
		<category><![CDATA[Debian]]></category>
		<category><![CDATA[Linux]]></category>
		<category><![CDATA[Nextcloud]]></category>
		<category><![CDATA[tmux]]></category>
		<category><![CDATA[WordPress]]></category>
		<guid isPermaLink="false">https://www.sandyscott.net/?p=602</guid>

					<description><![CDATA[Now you&#8217;re up and running with what should be a stable and secure installation of WordPress and Nextcloud with Collabora. There are plenty more tweaks you can work on yourself: Server Administration Advanced HTTPS &#8211; you can check your config with https://www.ssllabs.com/ssltest/. You have choices about how you want to...<p> <a class="continue-reading-link" href="https://www.sandyscott.net/2020/06/server-setup-15-optional-extras/"><span>Continue reading</span><i class="crycon-right-dir"></i></a> </p>]]></description>
										<content:encoded><![CDATA[
<p><em>If this is your first time looking at a post from this series, have a look at this summary: <a href="https://www.sandyscott.net/2020/06/04/server-setup-0-contents/" data-type="666">Server Setup 0: Contents</a></em></p>



<p>Now you&#8217;re up and running with what should be a stable and secure installation of WordPress and Nextcloud with Collabora.</p>



<p>There are plenty more tweaks you can work on yourself:</p>



<h2 class="wp-block-heading">Server Administration</h2>



<ul class="wp-block-list"><li>Advanced HTTPS &#8211; you can check your config with <a href="https://www.ssllabs.com/ssltest/">https://www.ssllabs.com/ssltest/</a>. You have choices about how you want to set up your system &#8211; more secure or more compatible with older clients. <a href="https://ssl-config.mozilla.org/#server=apache">This tool from Mozilla</a>  provides recommendations for the the Apache configuration you need.</li><li>Email configuration &#8211; This allows either system to send emails. Best way to do it us an existing email service, and let your server connect to that. s-nail and exim can both do this.</li><li>You can keep you system automatically up to date with the <code>unattened-upgrades</code> package &#8211; this keeps your system up to date. If email is configure it&#8217;ll send you an summary of what it&#8217;s updated.</li></ul>



<h2 class="wp-block-heading">WordPress:</h2>



<p>WordPress relies on htaccess for a few things, mainly nicely writing urls for permalinks. However, .htaccess files have a problem &#8211; they&#8217;re checked every time someone visits your site. You can reconfigure apache to load the data from the .htaccess file once, instead of on every request.</p>



<p>Be careful, there may be multiple .htaccess files, and some plugins install their own, so use these commands to find them all:</p>



<div class="wp-block-codemirror-blocks-code-block code-block"><pre class="CodeMirror" data-setting="{&quot;showPanel&quot;:false,&quot;languageLabel&quot;:&quot;language&quot;,&quot;fullScreenButton&quot;:true,&quot;copyButton&quot;:true,&quot;mode&quot;:&quot;shell&quot;,&quot;mime&quot;:&quot;text/x-sh&quot;,&quot;theme&quot;:&quot;material&quot;,&quot;lineNumbers&quot;:false,&quot;styleActiveLine&quot;:false,&quot;lineWrapping&quot;:false,&quot;readOnly&quot;:true,&quot;fileName&quot;:&quot;&quot;,&quot;language&quot;:&quot;Shell&quot;,&quot;maxHeight&quot;:&quot;400px&quot;,&quot;modeName&quot;:&quot;shell&quot;}">cd /var/www/wordpress
find | grep htaccess</pre></div>



<h2 class="wp-block-heading">Nextcloud</h2>



<p>A few ideas:</p>



<ul class="wp-block-list"><li>Work your way through the list in administration section &#8211; the links to the documentation will help a lot.</li><li>Background jobs: Try setting up a systemd timer or traditional crontab. Have a look in <strong>Basic Settings</strong> in the <strong>Settings</strong> menu for an Administrator. </li><li>Scan you installation for security issues <a href="https://scan.nextcloud.com/">https://scan.nextcloud.com/</a></li><li>Include .htaccess instead of loading it every time, like for WordPress.</li></ul>



<h2 class="wp-block-heading">User friendliness</h2>



<p>These are a few niceties you might try to help with general use:</p>



<ul class="wp-block-list"><li>Set up passwordless login: <a href="https://linuxize.com/post/how-to-setup-passwordless-ssh-login/">https://linuxize.com/post/how-to-setup-passwordless-ssh-login/</a></li><li>Use <a href="https://github.com/tmux/tmux/wiki">tmux </a>to keep you shell sessions alive.</li></ul>
]]></content:encoded>
					
					<wfw:commentRss>https://www.sandyscott.net/2020/06/server-setup-15-optional-extras/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
		<item>
		<title>Server Setup 14: Backups</title>
		<link>https://www.sandyscott.net/2020/06/server-setup-14-backups/</link>
					<comments>https://www.sandyscott.net/2020/06/server-setup-14-backups/#respond</comments>
		
		<dc:creator><![CDATA[Sandy]]></dc:creator>
		<pubDate>Mon, 01 Jun 2020 17:43:04 +0000</pubDate>
				<category><![CDATA[Computers]]></category>
		<category><![CDATA[backup]]></category>
		<category><![CDATA[Debian]]></category>
		<category><![CDATA[Linux]]></category>
		<category><![CDATA[mysqldump]]></category>
		<category><![CDATA[rsync]]></category>
		<category><![CDATA[scripting]]></category>
		<category><![CDATA[shell]]></category>
		<category><![CDATA[SpiderOak]]></category>
		<guid isPermaLink="false">https://www.sandyscott.net/?p=516</guid>

					<description><![CDATA[There&#8217;s lots of ways you could lose your website &#8211; a hard drive can fail, the server could be damaged by a lightning strike, or even stolen in a burglary. To get back up and running you&#8217;ll need to fix or replace the hardware, but this post is meant to...<p> <a class="continue-reading-link" href="https://www.sandyscott.net/2020/06/server-setup-14-backups/"><span>Continue reading</span><i class="crycon-right-dir"></i></a> </p>]]></description>
										<content:encoded><![CDATA[
<p><em>If this is your first time looking at a post from this series, have a look at this summary: <a href="https://www.sandyscott.net/2020/06/04/server-setup-0-contents/" data-type="666">Server Setup 0: Contents</a></em></p>



<p>There&#8217;s lots of ways you could lose your website &#8211; a hard drive can fail, the server could be damaged by a lightning strike, or even stolen in a burglary. To get back up and running you&#8217;ll need to fix or replace the hardware, but this post is meant to make sure you have the data you need restore all the applications too.</p>



<h2 class="wp-block-heading">Backup Options</h2>



<p>There are a few ways to approach backups, but the key things are:</p>



<ul class="wp-block-list"><li>What to back up</li><li>Where to back up</li></ul>



<p>I&#8217;ll be focussing on <strong>What</strong>, but will mention a few of your options for <strong>Where</strong> at the end.</p>



<h2 class="wp-block-heading">What to back up</h2>



<h3 class="wp-block-heading">Whole system</h3>



<p>The first thing I should mention is that you might have the option of backing up the whole system in one go. Many systems administrators don&#8217;t install their servers directly onto a computer, they use Virtualisation, which means first you install a special kind of operating system called a hypervisor, whose only job is to create and run virtual machines (VM) &#8211; a computer within the computer. You can then install the OS you really want for your server into one of these virtual machines.</p>



<p>It has many advantages, but I&#8217;ve brought it up now because many hypervisors have the option to create snapshots. This is a complete picture of the installation, so if you need to restore your system, it&#8217;s just a case of loading the most recent snapshot and you&#8217;re back up and running.</p>



<p>However a big disadvantage of this system is performance, especially on older computers with limited resources, which is why I haven&#8217;t done it in this tutorial. Virtualisation is a huge topic, so if it sounds interesting, then go read up on it.</p>



<p>There are also utilites that can clone your entire hard drive, so restoring your system should be a case of of putting that cloned hard drive into new server and starting it up. This approach has it&#8217;s disadvantages too &#8211; the backup will be as big as your hard drive, so your backup location needs a lot of storage space. It also works best if the system is off while the cloning occurs, so you&#8217;ll need to plan some regular downtime to use this backup strategy.</p>



<h3 class="wp-block-heading">Specific Items</h3>



<p>An advantage of backing up specific items is knowledge &#8211; you know what you&#8217;ve got. The tools for managing those pieces are often more common and more widely compatible than those for managing whole system backups.</p>



<p>Our strategy has two steps:</p>



<p></p>



<ul class="wp-block-list"><li>Create and populate a staging directory to hold all of the data we want to back up.</li><li>Actually do the backup to get the data off the server to somewhere else. (Backups stored on the same computer, especially on the same HDD, are a waste of time)</li></ul>



<p>Create the backup staging area:</p>



<div class="wp-block-codemirror-blocks-code-block code-block"><pre class="CodeMirror" data-setting="{&quot;showPanel&quot;:false,&quot;languageLabel&quot;:&quot;language&quot;,&quot;fullScreenButton&quot;:true,&quot;copyButton&quot;:true,&quot;mode&quot;:&quot;shell&quot;,&quot;mime&quot;:&quot;text/x-sh&quot;,&quot;theme&quot;:&quot;material&quot;,&quot;lineNumbers&quot;:false,&quot;styleActiveLine&quot;:false,&quot;lineWrapping&quot;:false,&quot;readOnly&quot;:true,&quot;fileName&quot;:&quot;sudo Shell&quot;,&quot;language&quot;:&quot;Shell&quot;,&quot;maxHeight&quot;:&quot;400px&quot;,&quot;modeName&quot;:&quot;shell&quot;}">sudo mkdir /var/backup_staging
sudo chmod -R go-rwx /var/backup_staging
sudo mkdir /var/backup_staging/scripts</pre></div>



<p>We&#8217;ll write a <strong>Shell</strong> script. You might not realise it, but the shell is the program you&#8217;re interracting with when you are entering commands. This means our script can use the same commands.</p>



<div class="wp-block-codemirror-blocks-code-block code-block"><pre class="CodeMirror" data-setting="{&quot;showPanel&quot;:false,&quot;languageLabel&quot;:&quot;language&quot;,&quot;fullScreenButton&quot;:true,&quot;copyButton&quot;:true,&quot;mode&quot;:&quot;shell&quot;,&quot;mime&quot;:&quot;text/x-sh&quot;,&quot;theme&quot;:&quot;material&quot;,&quot;lineNumbers&quot;:false,&quot;styleActiveLine&quot;:false,&quot;lineWrapping&quot;:false,&quot;readOnly&quot;:true,&quot;fileName&quot;:&quot;&quot;,&quot;language&quot;:&quot;Shell&quot;,&quot;maxHeight&quot;:&quot;400px&quot;,&quot;modeName&quot;:&quot;shell&quot;}">sudoedit /var/backup_staging/scripts/backup.sh</pre></div>



<p>Enter the following as the first lists of this file:</p>



<p></p>



<pre class="wp-block-code"><code>#!/bin/sh
# Backup scripts</code></pre>



<p>Like a lot of files we&#8217;ve worked on, the # at the beginning of a line means a comment, so wouldn&#8217;t normally matter. However, in this case, the first line is important to tell the system how to run this file. The second line is a real comment &#8211; a title for our script.</p>



<h3 class="wp-block-heading">General</h3>



<p>You probably what to back up these areas:</p>



<ul class="wp-block-list"><li>We&#8217;ve done a lot of work configuring Apache &#8211; we should definitely save those modifed configuration files: <code>/etc/apache2</code></li><li>Getting new SSL certificates isn&#8217;t too hard, but it doesn&#8217;t hurt to have them if speed things along : <code>/etc/letsencrypt</code></li><li>If you&#8217;re doing other things with this server you might have saved files your home directory: <code>/home/[your username].</code></li></ul>



<p>Create backup directories for these:</p>



<div class="wp-block-codemirror-blocks-code-block code-block"><pre class="CodeMirror" data-setting="{&quot;showPanel&quot;:false,&quot;languageLabel&quot;:&quot;language&quot;,&quot;fullScreenButton&quot;:true,&quot;copyButton&quot;:true,&quot;mode&quot;:&quot;shell&quot;,&quot;mime&quot;:&quot;text/x-sh&quot;,&quot;theme&quot;:&quot;material&quot;,&quot;lineNumbers&quot;:false,&quot;styleActiveLine&quot;:false,&quot;lineWrapping&quot;:false,&quot;readOnly&quot;:true,&quot;fileName&quot;:&quot;&quot;,&quot;language&quot;:&quot;Shell&quot;,&quot;maxHeight&quot;:&quot;400px&quot;,&quot;modeName&quot;:&quot;shell&quot;}">sudo mkdir --parents /var/backup_staging/etc/apache2
sudo mkdir /var/backup_staging/etc/letsencrypt
sudo mkdir --parents /var/backup_staging/home/[your username]</pre></div>



<p>The idea is we&#8217;ll mirror the structure of the filesystem, which means you won&#8217;t get any clashes if you add to this in future. Add these lines our script <code>/var/backup_staging/scripts/backup.sh</code></p>



<pre class="wp-block-code"><code>rsync -Aax --delete /etc/apache2/ /var/backup_staging/etc/apache2/
rsync -Aax --delete /etc/letsencrypt/ /var/backup_staging/etc/letsencrypt
rsync -Aax --delete /home/&#91;your username]/ /var/backup_staging/home/&#91;your username]/</code></pre>



<p>Each of these lines runs the <code>rsync</code> program, which basically copies one folder into another. The options we&#8217;ve selected mean that the backup should be an exact mirror of the original, but it&#8217;ll only move or update the files that have changed. rsync can do a lot more than this, including transferring files to another computer, but you can research that on your own.</p>



<p></p>



<h3 class="wp-block-heading">WordPress</h3>



<p>There are two main pieces to the backup, files and the database.</p>



<h4 class="wp-block-heading">Files</h4>



<ul class="wp-block-list"><li>WordPress uploads folder. Any images you upload to your site are saved in here, and that&#8217;s the only copy. Find it at <code>/var/www/wordpress/wp-content/uploads</code>.</li><li>At the time of writing the entire size of my wordpress folder is only 114 megabytes, including the uploads folder mentioned above. You might as well back up the whole thing. <code>/var/www/wordpress</code>.</li><li>We moved the wordpress configuration into a file outsite the web root, so make sure that&#8217;s backed up: <code>/var/www_config</code>.</li></ul>



<p>Create directories for these:</p>



<div class="wp-block-codemirror-blocks-code-block code-block"><pre class="CodeMirror" data-setting="{&quot;showPanel&quot;:false,&quot;languageLabel&quot;:&quot;language&quot;,&quot;fullScreenButton&quot;:true,&quot;copyButton&quot;:true,&quot;mode&quot;:&quot;shell&quot;,&quot;mime&quot;:&quot;text/x-sh&quot;,&quot;theme&quot;:&quot;material&quot;,&quot;lineNumbers&quot;:false,&quot;styleActiveLine&quot;:false,&quot;lineWrapping&quot;:false,&quot;readOnly&quot;:true,&quot;fileName&quot;:&quot;&quot;,&quot;language&quot;:&quot;Shell&quot;,&quot;maxHeight&quot;:&quot;400px&quot;,&quot;modeName&quot;:&quot;shell&quot;}">sudo mkdir --parents /var/backup_staging/www/wordpres
sudo mkdir /var/backup_staging/www_config</pre></div>



<p>Add add these lines to the script to copy them into the backup staging location.</p>



<pre class="wp-block-code"><code>rsync -Aax --delete /var/www/wordpress /var/backup_staging/var/www/wordpress
rsync -Aax --delete /var/www_config/ /var/backup_staging/var/www_config/
</code></pre>



<p></p>



<h4 class="wp-block-heading">Database</h4>



<p>The database is a critical component of both WordPress and Nextcloud, so we need to back this up, but it takes a little planning.</p>



<p>We&#8217;re going to use mysqldump, which logs into your database server, and saves the whole database (or even multiple databases) in a sql file. The idea is you can just execute this sql file on a database server and the database will be recreated.</p>



<p>The command history is considered insecure, so we don&#8217;t want to put our database password in on the command line. The database credentials go in a separate file:</p>



<div class="wp-block-codemirror-blocks-code-block code-block"><pre class="CodeMirror" data-setting="{&quot;showPanel&quot;:false,&quot;languageLabel&quot;:&quot;language&quot;,&quot;fullScreenButton&quot;:true,&quot;copyButton&quot;:true,&quot;mode&quot;:&quot;shell&quot;,&quot;mime&quot;:&quot;text/x-sh&quot;,&quot;theme&quot;:&quot;material&quot;,&quot;lineNumbers&quot;:false,&quot;styleActiveLine&quot;:false,&quot;lineWrapping&quot;:false,&quot;readOnly&quot;:true,&quot;fileName&quot;:&quot;&quot;,&quot;language&quot;:&quot;Shell&quot;,&quot;maxHeight&quot;:&quot;400px&quot;,&quot;modeName&quot;:&quot;shell&quot;}">sudoedit /var/backup_staging/scripts/wordpress.cnf</pre></div>



<p>Add this to wordpress.cnf, filling in your database username and password, (with single quote round it in case of special characters)</p>



<pre class="wp-block-code"><code>&#91;mysqldump]
user=wp_usr
password='wordpress_database_password'</code></pre>



<p>And now add this line to your backup script:</p>



<pre class="wp-block-code"><code>mysqldump --defaults-file=/var/backup_temp/scripts/wordpress.cnf --skip-dump-date --add-drop-table sswp > /var/backup_temp/sswp-current.sql
</code></pre>



<p>Explanation:</p>



<ul class="wp-block-list"><li><code>mysqldump </code>is the utility that spits out a sql that&#8217;s a backup of a database.<ul><li><code>--defaults-file</code> tells mysqldump to read the username and password the file we specified</li><li><code>--skip-dump-date</code> means the sql won&#8217;t include the date the dump was done, so if the database hasn&#8217;t changed between dumps, the sql file will be identical</li><li>&#8211;add-drop-table means the recovery can be more reliable, if riskier for the data you have on the system you&#8217;re installing the recovered data on.</li><li>&gt; means the data is written the file specified.</li></ul></li></ul>



<h3 class="wp-block-heading">Nextcloud</h3>



<p>Nextcloud also has files and data that we want to back up. There&#8217;s a greater chance of inconsistencies between the files and database, and it&#8217;s down to you how much care you take over this.</p>



<h4 class="wp-block-heading">Maintenance Mode</h4>



<p>Like we did for WordPress, create a file containing the Nextcloud database login details. I&#8217;d call it <code>/var/backup_staging/scripts/nextcloud.cnf</code>. Use the same format, just with the Nextcloud database details instead of the WordPress ones.</p>



<p>First, we&#8217;ll put Nextcloud into maintenance mode, add this line to your script:</p>



<pre class="wp-block-code"><code>sudo -u www-data php /var/www/nextcloud/occ maintenance:mode --on</code></pre>



<p>This runs the occ script, which performs various utility tasks on a Nextcloud installation.</p>



<h4 class="wp-block-heading">Database</h4>



<p>Now we can safely dump the database contents. Add this line to the backup script:.</p>



<pre class="wp-block-code"><code>mysqldump --defaults-file=/var/backup_staging/scripts/nextcloud.cnf --single-transaction --skip-dump-date --add-drop-table nextcloud > /var/backup_staging/nextcloud.sql
</code></pre>



<h4 class="wp-block-heading">Files</h4>



<p>We have a choice here:</p>



<ol class="wp-block-list"><li>Minimum Downtime. Copy the enitire Nextcloud Data folder into the staging folder, then turn off maintenance mode. The downside of this you need twice as much storage space.</li><li>Minimum Storage: Back up the Nextcloud data folder in place, then turn off maintenance mode. Your site will be down for as long as it takes the backup to complete.</li></ol>



<p>Pick an option, and add the relevant lines to the end of your backup script</p>



<p>Option 1:</p>



<pre class="wp-block-code"><code>rsync -Aax --delete /var/www/wordpress /var/backup_staging/var/www/wordpress
rsync -Aax --delete /var/nc_data/ /var/backup_staging/var/nc_data/
sudo -u www-data php /var/www/nextcloud/occ maintenance:mode --off
# # # # # # # # # # # # # # # # # #
# Placeholder for backup commands
# Back up /var/backup_staging only
# # # # # # # # # # # # # # # # # #</code></pre>



<p>Option 2:</p>



<pre class="wp-block-code"><code>rsync -Aax --delete /var/www/wordpress /var/backup_staging/var/www/wordpress
# # # # # #
# Placeholder for backup commands
# Back up /var/backup_staging and /var/nc_data
# # # # # #
sudo -u www-data php /var/www/nextcloud/occ maintenance:mode --off</code></pre>



<h2 class="wp-block-heading">Where to back up</h2>



<p>All we&#8217;ve done so far is to stage all the useful data from our websites in a single folder.</p>



<p>We need to get it off your server to different location, preferably serveral locations. A common rule about backups is the 3-2-1 rule:</p>



<ul class="wp-block-list"><li>3 copies of your data</li><li>2 of those copies on different of media</li><li>1 copy is offsite.</li></ul>



<p>The &#8220;2 different media&#8221; rule protects against hard drive failure, and the offsite rule can protect against a whole host of ways to lose your data: physical theft, fire, lightning damage and more.</p>



<p>So how can you do this?</p>



<ul class="wp-block-list"><li>A few portable HDDs can be a simple option &#8211; you&#8217;ll need to remember to plug them in, you may need to configure your backup script to mount it. Keep one at your mum&#8217;s house and swap it out every week or so.</li><li>Another server. If you (or a friend) have another server with plenty of space, you could back up to that. <code>rsync </code>doesn&#8217;t just copy folders on one computer &#8211; it&#8217;s really meant for transfering files to a remote computer over SSH. A sample command might look like this:</li></ul>



<div class="wp-block-codemirror-blocks-code-block code-block"><pre class="CodeMirror" data-setting="{&quot;showPanel&quot;:false,&quot;languageLabel&quot;:&quot;language&quot;,&quot;fullScreenButton&quot;:true,&quot;copyButton&quot;:true,&quot;mode&quot;:&quot;shell&quot;,&quot;mime&quot;:&quot;text/x-sh&quot;,&quot;theme&quot;:&quot;material&quot;,&quot;lineNumbers&quot;:false,&quot;styleActiveLine&quot;:false,&quot;lineWrapping&quot;:false,&quot;readOnly&quot;:true,&quot;fileName&quot;:&quot;&quot;,&quot;language&quot;:&quot;Shell&quot;,&quot;maxHeight&quot;:&quot;400px&quot;,&quot;modeName&quot;:&quot;shell&quot;}">rsync -az /var/backup_staging/ username@remoteserver:/var/remote_backups</pre></div>



<ul class="wp-block-list"><li>For either of these options, consider using software that encrypts the data. <a href="http://duplicity.nongnu.org/">Duplicity</a> works a bit like rsync, but allows for encryption and incremental backups.</li><li>Use a backup service. These companies usually have their own software and servers. Look for encryption and trustworthiness (I would <strong>never</strong> use a free service for something like backup). It&#8217;s also essential that they offer a Linux client with a command line interface so we can add it to our script. I use <a href="https://spideroak.com/">SpiderOak </a> &#8211; there are plenty other others out there, do your research!</li></ul>



<p>Once you&#8217;ve picked your method, replace the placeholder in our backup script with whatever commands you need to make that run.</p>



<h2 class="wp-block-heading">Run it regularly</h2>



<p>Our backup script is great and all, but unless you run it regularly, it&#8217;s pretty pointless. We&#8217;ll use <code>cron </code>to run this script every night (or whenever you want).</p>



<p>Edit the system crontab:</p>



<div class="wp-block-codemirror-blocks-code-block code-block"><pre class="CodeMirror" data-setting="{&quot;showPanel&quot;:false,&quot;languageLabel&quot;:&quot;language&quot;,&quot;fullScreenButton&quot;:true,&quot;copyButton&quot;:true,&quot;mode&quot;:&quot;shell&quot;,&quot;mime&quot;:&quot;text/x-sh&quot;,&quot;theme&quot;:&quot;material&quot;,&quot;lineNumbers&quot;:false,&quot;styleActiveLine&quot;:false,&quot;lineWrapping&quot;:false,&quot;readOnly&quot;:true,&quot;fileName&quot;:&quot;&quot;,&quot;language&quot;:&quot;Shell&quot;,&quot;maxHeight&quot;:&quot;400px&quot;,&quot;modeName&quot;:&quot;shell&quot;}">sudo crontab -e</pre></div>



<p>Add this line to the bottom, then save and exit the file.</p>



<pre class="wp-block-code"><code>  5 2   *   *   *  /bin/sh /var/backup_staging/scripts/backup.sh</code></pre>



<p>The lines at the top of the crontab script tell you how to use it. The 5 and 2 means the command will run at 5 minutes past 2am (02:05 24 hour clock), and the stars means it won&#8217;t consider the other options (day of week, day or month or month) are ignored. <code>/bin/sh</code> is the program that will run our script.</p>



<h2 class="wp-block-heading">Test!</h2>



<p>This is critical &#8211; after you&#8217;ve done your first backup, take a good look at:</p>



<ul class="wp-block-list"><li>Is everything you expected there?</li><li>Nothing is corrupted</li></ul>



<p>IT professionals regularly do &#8220;recovery drills&#8221;. i.e. practice what they&#8217;d do to get IT systems up and running after a distaster, which helps find problems with the backups. Have a go at using your backups to rebuild you site, maybe in a VM on your client computer.</p>



<p>Good luck!</p>
]]></content:encoded>
					
					<wfw:commentRss>https://www.sandyscott.net/2020/06/server-setup-14-backups/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
		<item>
		<title>Server Setup 13: Security Improvements</title>
		<link>https://www.sandyscott.net/2020/05/server-setup-13-security-improvements/</link>
					<comments>https://www.sandyscott.net/2020/05/server-setup-13-security-improvements/#respond</comments>
		
		<dc:creator><![CDATA[Sandy]]></dc:creator>
		<pubDate>Mon, 25 May 2020 11:20:15 +0000</pubDate>
				<category><![CDATA[Computers]]></category>
		<category><![CDATA[Apache]]></category>
		<category><![CDATA[Debian]]></category>
		<category><![CDATA[Linux]]></category>
		<category><![CDATA[WordPress]]></category>
		<guid isPermaLink="false">https://www.sandyscott.net/?p=621</guid>

					<description><![CDATA[One recommendation that many security experts make is that the WordPress configuration files should be outside the web root. Lets make this change. WordPress Create a new folder called /var/www_config. Put a new folder in here, wordpress Copy the WordPress configuration file across, and set it&#8217;s permissions so no-one apart...<p> <a class="continue-reading-link" href="https://www.sandyscott.net/2020/05/server-setup-13-security-improvements/"><span>Continue reading</span><i class="crycon-right-dir"></i></a> </p>]]></description>
										<content:encoded><![CDATA[
<p><em>If this is your first time looking at a post from this series, have a look at this summary: <a href="https://www.sandyscott.net/2020/06/04/server-setup-0-contents/" data-type="666">Server Setup 0: Contents</a></em></p>



<p>One recommendation that many security experts make is that the WordPress configuration files should be outside the web root. Lets make this change.</p>



<h2 class="wp-block-heading">WordPress</h2>



<p>Create a new folder called <code>/var/www_config</code>. Put a new folder in here, <code>wordpress</code></p>



<div class="wp-block-codemirror-blocks-code-block code-block"><pre class="CodeMirror" data-setting="{&quot;showPanel&quot;:false,&quot;languageLabel&quot;:&quot;language&quot;,&quot;fullScreenButton&quot;:true,&quot;copyButton&quot;:true,&quot;mode&quot;:&quot;shell&quot;,&quot;mime&quot;:&quot;text/x-sh&quot;,&quot;theme&quot;:&quot;material&quot;,&quot;lineNumbers&quot;:false,&quot;styleActiveLine&quot;:false,&quot;lineWrapping&quot;:false,&quot;readOnly&quot;:true,&quot;fileName&quot;:&quot;&quot;,&quot;language&quot;:&quot;Shell&quot;,&quot;maxHeight&quot;:&quot;400px&quot;,&quot;modeName&quot;:&quot;shell&quot;}">cd /var
sudo mkdir www_config
cd www_config
sudo mkdir wordpress</pre></div>



<p>Copy the WordPress configuration file across, and set it&#8217;s permissions so no-one apart from www-data (and root, of course) can read it:</p>



<div class="wp-block-codemirror-blocks-code-block code-block"><pre class="CodeMirror" data-setting="{&quot;showPanel&quot;:false,&quot;languageLabel&quot;:&quot;language&quot;,&quot;fullScreenButton&quot;:true,&quot;copyButton&quot;:true,&quot;mode&quot;:&quot;shell&quot;,&quot;mime&quot;:&quot;text/x-sh&quot;,&quot;theme&quot;:&quot;material&quot;,&quot;lineNumbers&quot;:false,&quot;styleActiveLine&quot;:false,&quot;lineWrapping&quot;:false,&quot;readOnly&quot;:true,&quot;fileName&quot;:&quot;&quot;,&quot;language&quot;:&quot;Shell&quot;,&quot;maxHeight&quot;:&quot;400px&quot;,&quot;modeName&quot;:&quot;shell&quot;}">sudo cp -a /var/www/wordpress/wp-config.php /var/www_config/wordpress/
sudo chown -R www-data:www-data /var/www_config
sudo chmod -R u=rX,go= /var/www_config</pre></div>



<p>Now we need to tell Apache that the when PHP scripts on the wordpress site run, they can only access the folders we want them to:</p>



<ul class="wp-block-list"><li>/var/www/wordpress : our wordpress installation</li><li>/var/www_config/wordpress : our wordpress config</li><li>/tmp : WordPress needs this for handling plugin upgrades etc.</li></ul>



<p>Modify the wordpress Apache site configuration file and add this line inside the VirtualHost section:</p>



<p><code>php_admin_value open_basedir "/var/www/wordpress/:/var/www_config/wordpress/:/tmp/"</code></p>



<p>Now reload Apache.</p>



<p>Finally, WordPress still needs to be able to find this file, so replace the contents of the original wp_config.php with this:</p>



<pre class="wp-block-code"><code>&lt;?php

/** Absolute path to the WordPress directory. */
if ( !defined('ABSPATH') )
    define('ABSPATH', dirname(__FILE__) . '/');

/** Location of your WordPress configuration. */
require_once('/var/www_config/wordpress/wp-config.php');</code></pre>



<p>It&#8217;ll take effect the moment you save it, so now visit your site from the client, and hopefully nothing has broken!</p>



<h2 class="wp-block-heading">Nextcloud</h2>



<p>For some reason this isn&#8217;t as widely recommended by Nextcloud users. I&#8217;ll investigate and update this post with my suggestion.</p>



<p>For now, just make sure only www-data can read and write the config file:</p>



<div class="wp-block-codemirror-blocks-code-block code-block"><pre class="CodeMirror" data-setting="{&quot;showPanel&quot;:false,&quot;languageLabel&quot;:&quot;language&quot;,&quot;fullScreenButton&quot;:true,&quot;copyButton&quot;:true,&quot;mode&quot;:&quot;shell&quot;,&quot;mime&quot;:&quot;text/x-sh&quot;,&quot;theme&quot;:&quot;material&quot;,&quot;lineNumbers&quot;:false,&quot;styleActiveLine&quot;:false,&quot;lineWrapping&quot;:false,&quot;readOnly&quot;:true,&quot;fileName&quot;:&quot;sudo cp -a /var/www/wordpress/wp-config.php /var/www_config/wordpress/Shell&quot;,&quot;language&quot;:&quot;Shell&quot;,&quot;maxHeight&quot;:&quot;400px&quot;,&quot;modeName&quot;:&quot;shell&quot;}">sudo chown -R www-data:www-data /var/www/nextcloud/config/
sudo chmod -R u=rX,go= /var/www/nextcloud/config/</pre></div>



<p></p>
]]></content:encoded>
					
					<wfw:commentRss>https://www.sandyscott.net/2020/05/server-setup-13-security-improvements/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
		<item>
		<title>Server Setup 12: Collabora</title>
		<link>https://www.sandyscott.net/2020/05/server-setup-12-collabora/</link>
					<comments>https://www.sandyscott.net/2020/05/server-setup-12-collabora/#respond</comments>
		
		<dc:creator><![CDATA[Sandy]]></dc:creator>
		<pubDate>Sun, 24 May 2020 18:37:57 +0000</pubDate>
				<category><![CDATA[Computers]]></category>
		<category><![CDATA[Apache]]></category>
		<category><![CDATA[Collabora]]></category>
		<category><![CDATA[Debian]]></category>
		<category><![CDATA[Linux]]></category>
		<category><![CDATA[Nextcloud]]></category>
		<guid isPermaLink="false">https://www.sandyscott.net/?p=612</guid>

					<description><![CDATA[The final of the 3 big pieces &#8211; this provides document editing capability in Nextcloud. Install Collabora There are a couple of ways to install Collabora, and the recommended way is to use a Docker image. That isn&#8217;t ideal for us because the Docker version will use more resources which...<p> <a class="continue-reading-link" href="https://www.sandyscott.net/2020/05/server-setup-12-collabora/"><span>Continue reading</span><i class="crycon-right-dir"></i></a> </p>]]></description>
										<content:encoded><![CDATA[
<p><em>If this is your first time looking at a post from this series, have a look at this summary: <a href="https://www.sandyscott.net/2020/06/04/server-setup-0-contents/" data-type="666">Server Setup 0: Contents</a></em></p>



<p>The final of the 3 big pieces &#8211; this provides document editing capability in Nextcloud.</p>



<h2 class="wp-block-heading">Install Collabora</h2>



<p>There are a couple of ways to install Collabora, and the recommended way is to use a Docker image. That isn&#8217;t ideal for us because the Docker version will use more resources which we can&#8217;t afford if you&#8217;re running this on something old. Instead, Collabora provide respositories, so these commands will:</p>



<ol class="wp-block-list"><li>Install a little tool me we need</li><li>Get the security keys so the repository is safe to use</li><li>Add the repository to our <code>/etc/apt/sources.list</code>.</li><li>Install Collabora</li></ol>



<div class="wp-block-codemirror-blocks-code-block code-block"><pre class="CodeMirror" data-setting="{&quot;showPanel&quot;:false,&quot;languageLabel&quot;:&quot;language&quot;,&quot;fullScreenButton&quot;:true,&quot;copyButton&quot;:true,&quot;mode&quot;:&quot;shell&quot;,&quot;mime&quot;:&quot;text/x-sh&quot;,&quot;theme&quot;:&quot;material&quot;,&quot;lineNumbers&quot;:false,&quot;styleActiveLine&quot;:false,&quot;lineWrapping&quot;:false,&quot;readOnly&quot;:true,&quot;fileName&quot;:&quot;&quot;,&quot;language&quot;:&quot;Shell&quot;,&quot;maxHeight&quot;:&quot;400px&quot;,&quot;modeName&quot;:&quot;shell&quot;}">sudo apt install gnupg
sudo apt-key adv --keyserver keyserver.ubuntu.com --recv-keys 0C54D189F4BA284D
sudo echo 'deb https://www.collaboraoffice.com/repos/CollaboraOnline/CODE-debian10 ./' | sudo tee -a /etc/apt/sources.list
sudo apt update &amp;&amp; sudo apt install loolwsd code-brand</pre></div>



<h2 class="wp-block-heading">Configure Collabora</h2>



<p>Modify <code>/etc/loolwsd/loolwsd.xml</code></p>



<div class="wp-block-codemirror-blocks-code-block code-block"><pre class="CodeMirror" data-setting="{&quot;showPanel&quot;:false,&quot;languageLabel&quot;:&quot;language&quot;,&quot;fullScreenButton&quot;:true,&quot;copyButton&quot;:true,&quot;mode&quot;:&quot;shell&quot;,&quot;mime&quot;:&quot;text/x-sh&quot;,&quot;theme&quot;:&quot;material&quot;,&quot;lineNumbers&quot;:false,&quot;styleActiveLine&quot;:false,&quot;lineWrapping&quot;:false,&quot;readOnly&quot;:true,&quot;fileName&quot;:&quot;&quot;,&quot;language&quot;:&quot;Shell&quot;,&quot;maxHeight&quot;:&quot;400px&quot;,&quot;modeName&quot;:&quot;shell&quot;}">sudoedit /etc/loolwsd/loolwsd.xml</pre></div>



<p>We&#8217;ll disable SSL in collabora itself, because Apache will handle that. Find <code>&lt;ssl desc="SSL settings"&gt;</code>. Look at the line below. Change the second-to last word to <code>false</code>. It should now be this:</p>



<div class="wp-block-codemirror-blocks-code-block code-block"><pre class="CodeMirror" data-setting="{&quot;showPanel&quot;:false,&quot;languageLabel&quot;:&quot;language&quot;,&quot;fullScreenButton&quot;:true,&quot;copyButton&quot;:true,&quot;mode&quot;:&quot;xml&quot;,&quot;mime&quot;:&quot;application/xml&quot;,&quot;theme&quot;:&quot;material&quot;,&quot;lineNumbers&quot;:false,&quot;styleActiveLine&quot;:false,&quot;lineWrapping&quot;:false,&quot;readOnly&quot;:true,&quot;fileName&quot;:&quot;&quot;,&quot;language&quot;:&quot;XML&quot;,&quot;maxHeight&quot;:&quot;400px&quot;,&quot;modeName&quot;:&quot;xml&quot;}">&lt;enable type=&quot;bool&quot; desc=&quot;Controls whether SSL encryption between browser and loolwsd is enabled (do not disable for production deployment). If default is false, must first be compiled with SSL support to enable.&quot; default=&quot;true&quot;&gt;false&lt;/enable&gt;</pre></div>



<p>In the line below that, the second-to last word should be <code>true</code>.</p>



<div class="wp-block-codemirror-blocks-code-block code-block"><pre class="CodeMirror" data-setting="{&quot;showPanel&quot;:false,&quot;languageLabel&quot;:&quot;language&quot;,&quot;fullScreenButton&quot;:true,&quot;copyButton&quot;:true,&quot;mode&quot;:&quot;xml&quot;,&quot;mime&quot;:&quot;application/xml&quot;,&quot;theme&quot;:&quot;material&quot;,&quot;lineNumbers&quot;:false,&quot;styleActiveLine&quot;:false,&quot;lineWrapping&quot;:false,&quot;readOnly&quot;:true,&quot;fileName&quot;:&quot;&quot;,&quot;language&quot;:&quot;XML&quot;,&quot;maxHeight&quot;:&quot;400px&quot;,&quot;modeName&quot;:&quot;xml&quot;}">&lt;termination desc=&quot;Connection via proxy where loolwsd acts as working via https, but actually uses http.&quot; type=&quot;bool&quot; default=&quot;true&quot;&gt;true&lt;/termination&gt;</pre></div>



<p>Now find <code>&lt;wopi desc="Allow/de.....</code> Add a line below it, swapping in your <strong>Nextcloud</strong> domain name, with the dots <code>"."</code> escaped with backslashes <code>"\."</code>.</p>



<div class="wp-block-codemirror-blocks-code-block code-block"><pre class="CodeMirror" data-setting="{&quot;showPanel&quot;:false,&quot;languageLabel&quot;:&quot;language&quot;,&quot;fullScreenButton&quot;:true,&quot;copyButton&quot;:true,&quot;mode&quot;:&quot;shell&quot;,&quot;mime&quot;:&quot;text/x-sh&quot;,&quot;theme&quot;:&quot;material&quot;,&quot;lineNumbers&quot;:false,&quot;styleActiveLine&quot;:false,&quot;lineWrapping&quot;:false,&quot;readOnly&quot;:true,&quot;fileName&quot;:&quot;&quot;,&quot;language&quot;:&quot;Shell&quot;,&quot;maxHeight&quot;:&quot;400px&quot;,&quot;modeName&quot;:&quot;shell&quot;}">&lt;host desc=&quot;Regex pattern of hostname to allow or deny.&quot; allow=&quot;true&quot;&gt;nextcloud\.example\.org&lt;/host&gt;</pre></div>



<p>Save and close the file, then restart Collabora</p>



<div class="wp-block-codemirror-blocks-code-block code-block"><pre class="CodeMirror" data-setting="{&quot;showPanel&quot;:false,&quot;languageLabel&quot;:&quot;language&quot;,&quot;fullScreenButton&quot;:true,&quot;copyButton&quot;:true,&quot;mode&quot;:&quot;shell&quot;,&quot;mime&quot;:&quot;text/x-sh&quot;,&quot;theme&quot;:&quot;material&quot;,&quot;lineNumbers&quot;:false,&quot;styleActiveLine&quot;:false,&quot;lineWrapping&quot;:false,&quot;readOnly&quot;:true,&quot;fileName&quot;:&quot;&lt;code&gt;sudo systemctl restart loolwsd&lt;/code&gt;Shell&quot;,&quot;language&quot;:&quot;Shell&quot;,&quot;maxHeight&quot;:&quot;400px&quot;,&quot;modeName&quot;:&quot;shell&quot;}">sudo systemctl restart loolwsd</pre></div>



<h2 class="wp-block-heading">Test</h2>



<p>There isn&#8217;t a whole lot of testing we can do on Collabora as an intermediate step, but this will at least confirm the server is running. This command asks Collabora for a file saying what it&#8217;s capable of:</p>



<div class="wp-block-codemirror-blocks-code-block code-block"><pre class="CodeMirror" data-setting="{&quot;showPanel&quot;:false,&quot;languageLabel&quot;:&quot;language&quot;,&quot;fullScreenButton&quot;:true,&quot;copyButton&quot;:true,&quot;mode&quot;:&quot;shell&quot;,&quot;mime&quot;:&quot;text/x-sh&quot;,&quot;theme&quot;:&quot;material&quot;,&quot;lineNumbers&quot;:false,&quot;styleActiveLine&quot;:false,&quot;lineWrapping&quot;:false,&quot;readOnly&quot;:true,&quot;fileName&quot;:&quot;&quot;,&quot;language&quot;:&quot;Shell&quot;,&quot;maxHeight&quot;:&quot;400px&quot;,&quot;modeName&quot;:&quot;shell&quot;}">cd ~
wget http://localhost:9980/hosting/capabilities</pre></div>



<p>If it seems to run OK, you should now have a file called <code>capabilites </code>in your home (~) directory. Lets look at what&#8217;s inside:</p>



<div class="wp-block-codemirror-blocks-code-block code-block"><pre class="CodeMirror" data-setting="{&quot;showPanel&quot;:false,&quot;languageLabel&quot;:&quot;language&quot;,&quot;fullScreenButton&quot;:true,&quot;copyButton&quot;:true,&quot;mode&quot;:&quot;shell&quot;,&quot;mime&quot;:&quot;text/x-sh&quot;,&quot;theme&quot;:&quot;material&quot;,&quot;lineNumbers&quot;:false,&quot;styleActiveLine&quot;:false,&quot;lineWrapping&quot;:false,&quot;readOnly&quot;:true,&quot;fileName&quot;:&quot;cShell&quot;,&quot;language&quot;:&quot;Shell&quot;,&quot;maxHeight&quot;:&quot;400px&quot;,&quot;modeName&quot;:&quot;shell&quot;}">cat ~/capabilities</pre></div>



<pre class="wp-block-code"><code>{"convert-to":{"available":true},"hasMobileSupport":true,"hasTemplateSaveAs":false,"hasTemplateSource":true,"productName":"Collabora Online Development Edition"}</code></pre>



<p>Looking good!</p>



<h2 class="wp-block-heading">Configure Apache</h2>



<p>In this situation, all Apache has to do is act as a proxy between Collabora and the internet &#8211; we can&#8217;t connect it directly because otherwise the other sites (WordPress and Nextcloud) wouldn&#8217;t work.</p>



<p>Enable these 3 modules:</p>



<div class="wp-block-codemirror-blocks-code-block code-block"><pre class="CodeMirror" data-setting="{&quot;showPanel&quot;:false,&quot;languageLabel&quot;:&quot;language&quot;,&quot;fullScreenButton&quot;:true,&quot;copyButton&quot;:true,&quot;mode&quot;:&quot;shell&quot;,&quot;mime&quot;:&quot;text/x-sh&quot;,&quot;theme&quot;:&quot;material&quot;,&quot;lineNumbers&quot;:false,&quot;styleActiveLine&quot;:false,&quot;lineWrapping&quot;:false,&quot;readOnly&quot;:true,&quot;fileName&quot;:&quot;&quot;,&quot;language&quot;:&quot;Shell&quot;,&quot;maxHeight&quot;:&quot;400px&quot;,&quot;modeName&quot;:&quot;shell&quot;}">sudo a2enmod proxy proxy_http proxy_wstunnel</pre></div>



<p>Edit the main Collabora SSL Apache configuration file:</p>



<div class="wp-block-codemirror-blocks-code-block code-block"><pre class="CodeMirror" data-setting="{&quot;showPanel&quot;:false,&quot;languageLabel&quot;:&quot;language&quot;,&quot;fullScreenButton&quot;:true,&quot;copyButton&quot;:true,&quot;mode&quot;:&quot;shell&quot;,&quot;mime&quot;:&quot;text/x-sh&quot;,&quot;theme&quot;:&quot;material&quot;,&quot;lineNumbers&quot;:false,&quot;styleActiveLine&quot;:false,&quot;lineWrapping&quot;:false,&quot;readOnly&quot;:true,&quot;fileName&quot;:&quot;&quot;,&quot;language&quot;:&quot;Shell&quot;,&quot;maxHeight&quot;:&quot;400px&quot;,&quot;modeName&quot;:&quot;shell&quot;}">sudoedit /etc/apache2/sites-available/collabora-le-ssl.conf</pre></div>



<p>Change it to this:</p>



<pre class="wp-block-code"><code>&lt;VirtualHost *:443&gt;
    ServerName collabora.example.org
    ErrorLog ${APACHE_LOG_DIR}/collabora_error.log
    CustomLog ${APACHE_LOG_DIR}/collabora_access.log combined

    SSLCertificateFile /etc/letsencrypt/live/collabora.example.org/fullchain.pem
    SSLCertificateKeyFile /etc/letsencrypt/live/collabora.example.org/privkey.pem
    Include /etc/letsencrypt/options-ssl-apache.conf
	# Encoded slashes need to be allowed
	AllowEncodedSlashes NoDecode

	# Container uses a unique non-signed certificate
	SSLProxyEngine On
	SSLProxyVerify None
	SSLProxyCheckPeerCN Off
	SSLProxyCheckPeerName Off

	# keep the host
	ProxyPreserveHost On

	# static html, js, images, etc. served from loolwsd
	# loleaflet is the client part of Collabora Online
	ProxyPass           /loleaflet http://127.0.0.1:9980/loleaflet retry=0
	ProxyPassReverse    /loleaflet http://127.0.0.1:9980/loleaflet

	# WOPI discovery URL
	ProxyPass           /hosting/discovery http://127.0.0.1:9980/hosting/discovery retry=0
	ProxyPassReverse    /hosting/discovery http://127.0.0.1:9980/hosting/discovery

	# Capabilities
	ProxyPass           /hosting/capabilities http://127.0.0.1:9980/hosting/capabilities retry=0
	ProxyPassReverse    /hosting/capabilities http://127.0.0.1:9980/hosting/capabilities

&lt;/VirtualHost&gt;</code></pre>



<p>Basically, the bits we&#8217;ve added are a two-way connector between Apache and Collabora, and it needs slightly different things for all of the different features.</p>



<p>Reload Apache.</p>



<p>Configure Nextcloud</p>



<ol class="wp-block-list"><li>Log into Nextcloud with your admin account.</li><li>Click on the circle with your initial in the top right corner, choose Apps.</li><li>Click on <strong>Office &amp; text</strong> from the menu on the left.</li><li>Find Collabora Online and click <strong>Download and enable</strong><br></li></ol>



<figure class="wp-block-image size-large"><a href="https://www.sandyscott.net/wp-content/uploads/2020/05/image-44.png"><img loading="lazy" decoding="async" width="358" height="297" src="https://www.sandyscott.net/wp-content/uploads/2020/05/image-44.png" alt="" class="wp-image-616" srcset="https://www.sandyscott.net/wp-content/uploads/2020/05/image-44.png 358w, https://www.sandyscott.net/wp-content/uploads/2020/05/image-44-300x249.png 300w, https://www.sandyscott.net/wp-content/uploads/2020/05/image-44-150x124.png 150w" sizes="(max-width: 358px) 100vw, 358px" /></a></figure>



<ol class="wp-block-list" start="5"><li>Click on the circle with your initial in the top right corner, choose Settings.</li><li>Click on Collabora Online near the bottom of the menu on the left.</li><li>Choose <strong>Use your own server</strong></li><li>Enter your Collabora domain name with the https:// and then hit save.</li></ol>



<figure class="wp-block-image size-medium"><a href="https://www.sandyscott.net/wp-content/uploads/2020/05/image-45.png"><img loading="lazy" decoding="async" width="300" height="171" src="https://www.sandyscott.net/wp-content/uploads/2020/05/image-45-300x171.png" alt="" class="wp-image-617" srcset="https://www.sandyscott.net/wp-content/uploads/2020/05/image-45-300x171.png 300w, https://www.sandyscott.net/wp-content/uploads/2020/05/image-45-150x85.png 150w, https://www.sandyscott.net/wp-content/uploads/2020/05/image-45.png 750w" sizes="(max-width: 300px) 100vw, 300px" /></a></figure>



<p>Now go back to the files section and give it a try!</p>



<ul class="wp-block-list"><li>You should have the option to create a <strong>New Document</strong>, <strong>New Spreadsheet</strong> or <strong>New Presentation</strong> from the &#8220;+&#8221; icon.</li></ul>



<figure class="wp-block-image size-medium"><a href="https://www.sandyscott.net/wp-content/uploads/2020/05/image-46.png"><img loading="lazy" decoding="async" width="209" height="300" src="https://www.sandyscott.net/wp-content/uploads/2020/05/image-46-209x300.png" alt="" class="wp-image-618" srcset="https://www.sandyscott.net/wp-content/uploads/2020/05/image-46-209x300.png 209w, https://www.sandyscott.net/wp-content/uploads/2020/05/image-46-104x150.png 104w, https://www.sandyscott.net/wp-content/uploads/2020/05/image-46.png 236w" sizes="(max-width: 209px) 100vw, 209px" /></a></figure>



<ul class="wp-block-list"><li>Or if you have any files on Open Document (.odt, .ods, .odp) or Open Office XML (.docx, .xlsx, .pptx) formats you can try opening them. They should open for editing in Collabora:</li></ul>



<figure class="wp-block-image size-large is-resized"><a href="https://www.sandyscott.net/wp-content/uploads/2020/05/image-47.png"><img loading="lazy" decoding="async" src="https://www.sandyscott.net/wp-content/uploads/2020/05/image-47.png" alt="" class="wp-image-619" width="299" height="195" srcset="https://www.sandyscott.net/wp-content/uploads/2020/05/image-47.png 598w, https://www.sandyscott.net/wp-content/uploads/2020/05/image-47-300x196.png 300w, https://www.sandyscott.net/wp-content/uploads/2020/05/image-47-150x98.png 150w" sizes="(max-width: 299px) 100vw, 299px" /></a></figure>
]]></content:encoded>
					
					<wfw:commentRss>https://www.sandyscott.net/2020/05/server-setup-12-collabora/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
		<item>
		<title>Server Setup 11: Config Improvements</title>
		<link>https://www.sandyscott.net/2020/05/server-setup-11-config-improvements/</link>
					<comments>https://www.sandyscott.net/2020/05/server-setup-11-config-improvements/#respond</comments>
		
		<dc:creator><![CDATA[Sandy]]></dc:creator>
		<pubDate>Fri, 22 May 2020 17:08:31 +0000</pubDate>
				<category><![CDATA[Computers]]></category>
		<category><![CDATA[Apache]]></category>
		<category><![CDATA[Debian]]></category>
		<category><![CDATA[Linux]]></category>
		<category><![CDATA[Nextcloud]]></category>
		<guid isPermaLink="false">https://www.sandyscott.net/?p=582</guid>

					<description><![CDATA[Before enabling public access to Nextcloud, lets take a moment to improve things a little. Apache Config First up, let&#8217;s force the use of the HTTPS and make sure we haven&#8217;t left any security holes by stripping back the HTTP config file to it&#8217;s bare bones. The default Apache configuration...<p> <a class="continue-reading-link" href="https://www.sandyscott.net/2020/05/server-setup-11-config-improvements/"><span>Continue reading</span><i class="crycon-right-dir"></i></a> </p>]]></description>
										<content:encoded><![CDATA[
<p><em>If this is your first time looking at a post from this series, have a look at this summary: <a href="https://www.sandyscott.net/2020/06/04/server-setup-0-contents/" data-type="666">Server Setup 0: Contents</a></em></p>



<p>Before enabling public access to Nextcloud, lets take a moment to improve things a little.</p>



<h2 class="wp-block-heading">Apache Config</h2>



<p>First up, let&#8217;s force the use of the HTTPS and make sure we haven&#8217;t left any security holes by stripping back the HTTP config file to it&#8217;s bare bones.</p>



<div class="wp-block-codemirror-blocks-code-block code-block"><pre class="CodeMirror" data-setting="{&quot;showPanel&quot;:false,&quot;languageLabel&quot;:&quot;language&quot;,&quot;fullScreenButton&quot;:true,&quot;copyButton&quot;:true,&quot;mode&quot;:&quot;shell&quot;,&quot;mime&quot;:&quot;text/x-sh&quot;,&quot;theme&quot;:&quot;material&quot;,&quot;lineNumbers&quot;:false,&quot;styleActiveLine&quot;:false,&quot;lineWrapping&quot;:false,&quot;readOnly&quot;:true,&quot;fileName&quot;:&quot;sudoedit /etc/apache2/sites-available/nextcloud.confShell&quot;,&quot;language&quot;:&quot;Shell&quot;,&quot;maxHeight&quot;:&quot;400px&quot;,&quot;modeName&quot;:&quot;shell&quot;}">sudoedit /etc/apache2/sites-available/nextcloud.conf</pre></div>



<pre class="wp-block-code"><code>&lt;VirtualHost *:80>
	ServerName nextcloud.example.org
	Redirect permanent / https://nextcloud.example.org/
&lt;/VirtualHost></code></pre>



<p>The default Apache configuration gives access to a little too much &#8211; we can lock that down, and just open up the bits we want later with the site-specific configuration files.</p>



<div class="wp-block-codemirror-blocks-code-block code-block"><pre class="CodeMirror" data-setting="{&quot;showPanel&quot;:false,&quot;languageLabel&quot;:&quot;language&quot;,&quot;fullScreenButton&quot;:true,&quot;copyButton&quot;:true,&quot;mode&quot;:&quot;shell&quot;,&quot;mime&quot;:&quot;text/x-sh&quot;,&quot;theme&quot;:&quot;material&quot;,&quot;lineNumbers&quot;:false,&quot;styleActiveLine&quot;:false,&quot;lineWrapping&quot;:false,&quot;readOnly&quot;:true,&quot;fileName&quot;:&quot;&quot;,&quot;language&quot;:&quot;Shell&quot;,&quot;maxHeight&quot;:&quot;400px&quot;,&quot;modeName&quot;:&quot;shell&quot;}">sudoedit /etc/apache2/apache2.conf</pre></div>



<p>Look for this section and put a <code>#</code> at the beginning of every line so they&#8217;re ignored.</p>



<pre class="wp-block-code"><code>&lt;Directory /usr/share>
	AllowOverride None
	Require all granted
&lt;/Directory>

&lt;Directory /var/www/>
	Options Indexes FollowSymLinks
	AllowOverride None
	Require all granted
&lt;/Directory></code></pre>



<p>Now we have to give access back just where want it:</p>



<div class="wp-block-codemirror-blocks-code-block code-block"><pre class="CodeMirror" data-setting="{&quot;showPanel&quot;:false,&quot;languageLabel&quot;:&quot;language&quot;,&quot;fullScreenButton&quot;:true,&quot;copyButton&quot;:true,&quot;mode&quot;:&quot;shell&quot;,&quot;mime&quot;:&quot;text/x-sh&quot;,&quot;theme&quot;:&quot;material&quot;,&quot;lineNumbers&quot;:false,&quot;styleActiveLine&quot;:false,&quot;lineWrapping&quot;:false,&quot;readOnly&quot;:true,&quot;fileName&quot;:&quot;&quot;,&quot;language&quot;:&quot;Shell&quot;,&quot;maxHeight&quot;:&quot;400px&quot;,&quot;modeName&quot;:&quot;shell&quot;}">sudoedit /etc/apache2/sites-available/nextcloud-le-ssl.conf</pre></div>



<p>Before the <code>ErrorLog </code>line, add this:</p>



<pre class="wp-block-code"><code>&lt;Directory /var/www/nextcloud>
    Require all granted
&lt;/Directory></code></pre>



<p>Then do the same for the WordPress config:</p>



<div class="wp-block-codemirror-blocks-code-block code-block"><pre class="CodeMirror" data-setting="{&quot;showPanel&quot;:false,&quot;languageLabel&quot;:&quot;language&quot;,&quot;fullScreenButton&quot;:true,&quot;copyButton&quot;:true,&quot;mode&quot;:&quot;shell&quot;,&quot;mime&quot;:&quot;text/x-sh&quot;,&quot;theme&quot;:&quot;material&quot;,&quot;lineNumbers&quot;:false,&quot;styleActiveLine&quot;:false,&quot;lineWrapping&quot;:false,&quot;readOnly&quot;:true,&quot;fileName&quot;:&quot;&quot;,&quot;language&quot;:&quot;Shell&quot;,&quot;maxHeight&quot;:&quot;400px&quot;,&quot;modeName&quot;:&quot;shell&quot;}">sudoedit /etc/apache2/sites-available/wordpress-le-ssl.conf	</pre></div>



<p>Before the <code>ErrorLog </code>line, add this:</p>



<pre class="wp-block-code"><code>&lt;Directory /var/www/wordpress>
    Require all granted
&lt;/Directory></code></pre>



<p>Restart Apache (you should know how to do that by now &#8211; look back through the previous posts until you find it.)</p>



<h2 class="wp-block-heading">Nextcloud Administration Warnings</h2>



<p>Log into your nextcloud administrator account, click on the circle with your initial in the top right corner, choose setttings. On the page that pops up, pick Overview from the menu on the right.</p>



<p>The system will think for a moment, then show a list of warnings:</p>



<figure class="wp-block-image size-medium"><a href="https://www.sandyscott.net/wp-content/uploads/2020/05/image-43.png"><img loading="lazy" decoding="async" width="300" height="279" src="https://www.sandyscott.net/wp-content/uploads/2020/05/image-43-300x279.png" alt="" class="wp-image-599" srcset="https://www.sandyscott.net/wp-content/uploads/2020/05/image-43-300x279.png 300w, https://www.sandyscott.net/wp-content/uploads/2020/05/image-43-1024x954.png 1024w, https://www.sandyscott.net/wp-content/uploads/2020/05/image-43-768x715.png 768w, https://www.sandyscott.net/wp-content/uploads/2020/05/image-43-150x140.png 150w, https://www.sandyscott.net/wp-content/uploads/2020/05/image-43.png 1035w" sizes="(max-width: 300px) 100vw, 300px" /></a></figure>



<p>If your list is the same as mine, I&#8217;ll show you how to fix the first 2, but you can work through the others on your own if you like.</p>



<h2 class="wp-block-heading">PHP Memory Limit</h2>



<p><strong><em>&#8220;The PHP memory limit is below the recommended value of 512MB.&#8221;</em></strong></p>



<p>It isn&#8217;t essential to fix this, and if you&#8217;re running nextcloud on an old, lower powered machine I wouldn&#8217;t recommend it, because that&#8217;s the limit per script, and a script fires up every time someone access your site, so with a few users doing heavy things, you&#8217;ll have a problem.</p>



<p>If you do want to do it, edit the PHP configuration file:</p>



<div class="wp-block-codemirror-blocks-code-block code-block"><pre class="CodeMirror" data-setting="{&quot;showPanel&quot;:false,&quot;languageLabel&quot;:&quot;language&quot;,&quot;fullScreenButton&quot;:true,&quot;copyButton&quot;:true,&quot;mode&quot;:&quot;shell&quot;,&quot;mime&quot;:&quot;text/x-sh&quot;,&quot;theme&quot;:&quot;material&quot;,&quot;lineNumbers&quot;:false,&quot;styleActiveLine&quot;:false,&quot;lineWrapping&quot;:false,&quot;readOnly&quot;:true,&quot;fileName&quot;:&quot;&quot;,&quot;language&quot;:&quot;Shell&quot;,&quot;maxHeight&quot;:&quot;400px&quot;,&quot;modeName&quot;:&quot;shell&quot;}">sudoedit /etc/php/7.3/apache2/php.ini</pre></div>



<p>Find this line and change the number to what you want:</p>



<pre class="wp-block-code"><code>memory_limit = 512M</code></pre>



<p>Then restart Apache</p>



<h2 class="wp-block-heading">Enable HSTS</h2>



<p><strong><em>&#8220;The &#8220;Strict-Transport-Security&#8221; HTTP header is not set to at least &#8220;15552000&#8221; seconds. For enhanced security, it is recommended to enable HSTS as described in the <a href="https://docs.nextcloud.com/server/18/go.php?to=admin-security">security tips <img src="https://s.w.org/images/core/emoji/15.0.3/72x72/2197.png" alt="↗" class="wp-smiley" style="height: 1em; max-height: 1em;" /></a>.&#8221;</em></strong></p>



<p>You can follow that link in the tip to find out the details of how we fix this, but these are the steps:</p>



<p>Enable the Apache headers module:</p>



<div class="wp-block-codemirror-blocks-code-block code-block"><pre class="CodeMirror" data-setting="{&quot;showPanel&quot;:false,&quot;languageLabel&quot;:&quot;language&quot;,&quot;fullScreenButton&quot;:true,&quot;copyButton&quot;:true,&quot;mode&quot;:&quot;shell&quot;,&quot;mime&quot;:&quot;text/x-sh&quot;,&quot;theme&quot;:&quot;material&quot;,&quot;lineNumbers&quot;:false,&quot;styleActiveLine&quot;:false,&quot;lineWrapping&quot;:false,&quot;readOnly&quot;:true,&quot;fileName&quot;:&quot;&quot;,&quot;language&quot;:&quot;Shell&quot;,&quot;maxHeight&quot;:&quot;400px&quot;,&quot;modeName&quot;:&quot;shell&quot;}">sudo a2enmod headers</pre></div>



<p>Modify the Nextcloud apache configuration:</p>



<div class="wp-block-codemirror-blocks-code-block code-block"><pre class="CodeMirror" data-setting="{&quot;showPanel&quot;:false,&quot;languageLabel&quot;:&quot;language&quot;,&quot;fullScreenButton&quot;:true,&quot;copyButton&quot;:true,&quot;mode&quot;:&quot;shell&quot;,&quot;mime&quot;:&quot;text/x-sh&quot;,&quot;theme&quot;:&quot;material&quot;,&quot;lineNumbers&quot;:false,&quot;styleActiveLine&quot;:false,&quot;lineWrapping&quot;:false,&quot;readOnly&quot;:true,&quot;fileName&quot;:&quot;&quot;,&quot;language&quot;:&quot;Shell&quot;,&quot;maxHeight&quot;:&quot;400px&quot;,&quot;modeName&quot;:&quot;shell&quot;}">sudoedit /etc/apache2/sites-available/nextcloud-le-ssl.conf</pre></div>



<p>Add this after the ServerName line:</p>



<pre class="wp-block-code"><code>Header always set Strict-Transport-Security "max-age=15552000; includeSubDomains"</code></pre>



<p>And reload Apache</p>



<h2 class="wp-block-heading">Re-enable public access</h2>



<p>Now we&#8217;ve dealt with a few potential security issues, you can enable access to Nextcloud from outside you network.</p>



<div class="wp-block-codemirror-blocks-code-block code-block"><pre class="CodeMirror" data-setting="{&quot;showPanel&quot;:false,&quot;languageLabel&quot;:&quot;language&quot;,&quot;fullScreenButton&quot;:true,&quot;copyButton&quot;:true,&quot;mode&quot;:&quot;shell&quot;,&quot;mime&quot;:&quot;text/x-sh&quot;,&quot;theme&quot;:&quot;material&quot;,&quot;lineNumbers&quot;:false,&quot;styleActiveLine&quot;:false,&quot;lineWrapping&quot;:false,&quot;readOnly&quot;:true,&quot;fileName&quot;:&quot;sudShell&quot;,&quot;language&quot;:&quot;Shell&quot;,&quot;maxHeight&quot;:&quot;400px&quot;,&quot;modeName&quot;:&quot;shell&quot;}">sudoedit /etc/apache2/sites-available/nextcloud-le-ssl.conf</pre></div>



<p>Either delete, or comment out these 3 lines. You can make a line into a comment by putting a # at the beginning of the line. That means it will be ignored.</p>



<pre class="wp-block-code"><code>&lt;Location />
    Require ip xxx.xxx.xxx.0/24
&lt;/Location></code></pre>



<p>Reload apache and you&#8217;re done!</p>
]]></content:encoded>
					
					<wfw:commentRss>https://www.sandyscott.net/2020/05/server-setup-11-config-improvements/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
	</channel>
</rss>
