729468a640882f6647dfca3212b8192ffad00fb3
[feisty_meow.git] / production / sites / cakelampvm.com / docs / manual / cakelampvm_guide_v003.html
1 <!DOCTYPE html>
2 <html>
3   <head>
4     <meta http-equiv="content-type" content="text/html; charset=windows-1252">
5     <title>Cake LAMP VM Documentation</title>
6   </head>
7   <body>
8     <h1 style="text-align: center;">The cakelampvm VM:<br>
9       Configuration and Usage</h1>
10     <div style="text-align: center;"><span style="font-weight: bold;">By Chris
11         Koeritz</span><span style="font-family: Comic Sans MS;"></span><span style="font-family: Comic Sans MS;"></span><br>
12       <span style="font-family: Comic Sans MS;">feisty meow® concerns ltd</span>.</div>
13     <h3 style="   text-align: center;">VM Vintage: cakelampvm v003 &nbsp; &nbsp;
14       &nbsp;
15       Docs Updated: 2018-05-21</h3>
16     <p>The cakelampvm project provides a Virtualbox VM that acts as an "internet
17       in a bottle", serving up your web sites securely and only to your local
18       host.&nbsp; The virtual machine provides DNS services (<a target="_blank"
19         title="dns server" href="http://www.bind9.net/">bind9</a>), a Web server
20       (<a target="_blank" title="patchy" href="https://httpd.apache.org/">Apache2</a>),
21       a full <a target="_blank" title="ubuntu means compassion and humanity" href="https://www.ubuntu.com/">Ubuntu</a>
22       <a target="_blank" title="it's pronounced leenoox" href="https://www.linuxfoundation.org/">Linux</a>
23       desktop environment, the <a target="_blank" title="flux is change" href="http://fluxbox.org/">Fluxbox</a>
24       <a target="_blank" title="x11 -- best windowing system" href="https://www.x.org/">X
25         window manager</a>, and a suite of tools called the <a target="_blank"
26         title="feisty meow® concerns ltd. website" href="https://feistymeow.org/">Feisty
27         Meow® codebase</a> .&nbsp; Together, these services provide you with a
28       very flexible and powerful testbed for web development, especially suited
29       for <a target="_blank" title="it's cake" href="https://cakephp.org/">CakePHP</a>.&nbsp;
30       This VM was built with the assistance of and was partially funded by <a target="_blank"
31         title="saco design" href="http://sacodesign.com">Saco Design</a> of <a
32         target="_blank" title="winterport" href="http://www.winterportmaine.gov/">Winterport,
33         Maine</a>.</p>
34     <p>Commands in fixed-width bold below are intended to be typed into a bash
35       shell running on the cakelampvm virtual machine.&nbsp; The bash shell can
36       be obtained either by logging into the VM through ssh or by logging in
37       directly to the Virtualbox VM console.&nbsp; You may find the ssh session
38       more convenient, because copy &amp; paste features work as expected.</p>
39     <p>Commands preceded by a greater-than symbol ('&gt;') are intended to be
40       run on the Host PC in a Windows command prompt (or in a bash prompt
41       running on the Host PC).</p>
42     <h2> Guest VM Configuration<a id="#config" name="#config"></a></h2>
43     <ul>
44       <li>Hostname: <a target="_blank" title="the vm's website, when configured properly"
45           href="https://cakelampvm.com/">cakelampvm.com</a></li>
46       <li>Local IP Address: 10.28.42.20</li>
47       <li>Services Included: DNS (bind9), apache2, fluxbox X windowing system, <a
48           target="_blank" title="not just in the garden" href="https://www.gnome.org/">gnome
49           display manager</a></li>
50       <li>Main VM User: developer (password distributed separately)</li>
51       <li>Database Access: mysql root account (password distributed separately)</li>
52     </ul>
53     <h2>How to set up virtualbox for your host PC<a id="#virtualbox-setup" name="#virtualbox-setup"></a></h2>
54     <ol>
55       <li>Download and install virtualbox: <a target="_blank" href="https://www.virtualbox.org/wiki/Downloads">https://www.virtualbox.org/wiki/Downloads</a></li>
56       <li>Install the extension pack for Virtualbox: This provides USB drivers
57         and other features.&nbsp; This is installed on Virtualbox itself (on the
58         Host PC), not on the guests.</li>
59       <ol>
60         <li>Download the extension pack (also) at <a target="_blank" href="https://www.virtualbox.org/wiki/Downloads">https://www.virtualbox.org/wiki/Downloads</a></li>
61         <li>Stop any running Virtualbox VMs.</li>
62         <li>Close the Virtualbox control panel.</li>
63         <li>Double-click on the downloaded extensions package (in a file
64           explorer) and Virtualbox should be launched to install it.</li>
65       </ol>
66       <li>Run the Virtualbox control panel.</li>
67       <li>Download the cakelampvm guest vm package and unzip it.&nbsp; Store the
68         unzipped version in some appropriate place where you want the virtual
69         machine to reside on your host's hard drive.</li>
70       <li>Add the guest VM to your list of VMs.&nbsp; From the Virtualbox menus,
71         choose the "Machine" menu and select "Add".&nbsp; Point the selector
72         dialog at the cakelampvm folder you created above and open the
73         cakelampvm.vbox file.</li>
74       <li>Now the cakelampvm should show up in the list of virtual
75         machines.&nbsp; Before starting it, perform the following network
76         configuration sections.</li>
77     </ol>
78     <h3>Configure the Host-Only network on Virtualbox<a id="#host-only" name="#host-only"></a></h3>
79     <p>Configuring host-only networking for the VM makes the VM completely local
80       to your machine.&nbsp; The cakelampvm will not be accessible on the
81       internet or from the LAN, and can only be accessed by your host PC.&nbsp;
82       This is a key component of security for your VM and your host PC, and is
83       considered a crucial configuration step.</p>
84     <p>Note: If the host-only or NAT network exist ahead of time, Virtualbox may
85       complain about them even if they have the correct configuration.&nbsp;
86       This can be corrected simply by opening the cakelampvm settings and
87       selecting the appropriate network names again.</p>
88     <p>To configure the host-only network, follow these steps:</p>
89     <ol>
90       <li> Go to virtual box "Preferences" (global preferences, not for a
91         specific vm).</li>
92       <li> Click on the "Network" tab.</li>
93       <li> Choose the "Host-only Networks" tab from within "Network".</li>
94       <li> Click the plus icon to add a new host-only network, or if there is
95         already a Host-only network, then edit it.</li>
96       <li>Set the "Adapter" parameters:<br>
97         IPv4 Address: 10.28.42.1<br>
98         IPv4 Network Mask: 255.255.255.0<br>
99         IPv6 Address: (leave blank)<br>
100         IPv6 Prefix Length: 0<br>
101         Virtualbox will fill in the other details like so (this dialog may
102         differ between versions of virtualbox):<br>
103         <p><img alt="host only network adapter" src="images/host_only_network_adapter.png"></p>
104       </li>
105       <li>Set the "DHCP Server Settings" to disabled, e.g.<br>
106         <img alt="host only dhcp" src="images/host_only_adapter_dhcp_server.png"><br>
107         This is disabled because we will be using statically assigned addresses
108         for convenience and stability.</li>
109     </ol>
110     <p>Additional information on host-only (and other) network adapter types is
111       at: https://www.virtualbox.org/manual/ch06.html#network_nat_service</p>
112     <h3>Configure the NAT Network on Virtualbox<a id="#nat-network" name="#nat-network"></a></h3>
113     <p>The NAT (Network Address Translation) network allows the VM to get off of
114       the machine and onto the internet safely.&nbsp; It will use this interface
115       for any communication off of the host machine.&nbsp; This is another
116       crucial component for the security of the VM and your host PC.&nbsp; Since
117       the real IP address of the VM is hidden behind the NAT firewall on
118       Virtualbox, this keeps the VM safe from attackers, and hence your machine
119       stays safe as well.</p>
120     <p>To set up the NAT network, follow these steps:</p>
121     <ol>
122       <li> Go to virtual box "Preferences" (global preferences, not for a
123         specific vm).</li>
124       <li> Click on the "Network" tab.</li>
125       <li> Choose the "Nat Networks" tab from within "Network".</li>
126       <li> Click the plus icon to add a new host-only network.</li>
127       <li>Set the "NAT Network Details" parameters:<br>
128         Network Name: NatNetwork<br>
129         Network CIDR: 10.0.2.0/24<br>
130         Supports DHCP: checked<br>
131         Supports IPv6: optionally checked<br>
132         These are my settings, with IPv6 left disabled (this dialog may differ
133         between versions of virtualbox):<br>
134         <img alt="nat net config" src="images/nat_network_config.png"></li>
135     </ol>
136     <h2>Starting up the VM and Connecting to It<a id="#start-vm" name="#start-vm"></a></h2>
137     <p>&#9733; This section requires that the VM is already configured properly for
138       Host-Only and NAT networks.</p>
139     <p>Using the Virtualbox interface, you should now be able to start your
140       virtual machine.&nbsp; Virtualbox will complain if it detects any
141       remaining configuration problems in the VM.&nbsp; The Linux boot sequence
142       will show many lines of text, before bringing up a black console window
143       with a login dialog.</p>
144     <p>If Windows complains about the Virtualbox application slamming into its
145       firewall, then allow the Virtualbox to get through.&nbsp; Usually, telling
146       Windows that once is enough, but if any odd network access problems
147       result, edit the Windows firewall settings and allow Virtualbox to use
148       both "Public" and "Private" networks.&nbsp; (Cortana can find the firewall
149       settings if you ask her about 'firewall'.&nbsp; Within the firewall
150       configuration dialog, look for "Allow an app or feature through..." on the
151       left and configure Virtualbox from within that list.)</p>
152     You can log in directly on the VM console with the developer account, but it
153     is generally more useful to connect to the cakelampvm over ssh.&nbsp; If the
154     networking has been established properly, you should be able to do this
155     with:
156     <pre><span style="font-weight: bold;">ssh developer@10.28.42.20<br># or perform the equivalent connection with your ssh client.</span></pre>
157     <p>And then provide the password to log in.</p>
158     <p> </p>
159     <p> &#9733; It is very important that the ssh connection is working properly
160       before proceeding to other configuration steps.&nbsp; If ssh is not
161       working, try pinging the host:</p>
162     <pre><b>ping 10.28.42.20</b></pre>
163     <p>If the ping is also failing, then please re-check the two network
164       configuration sections above (for Host-Only networking and NAT
165       networking).&nbsp; These are both required for the VM's network to
166       function as designed.</p>
167     <p>Optional: Once the DNS services are set up (discussed in detail below),
168       you will be able to run the much friendlier command:</p>
169     <pre><span style="font-weight: bold;">ssh developer@cakelampvm.com</span></pre>
170     <h4>Key Forwarding to the VM</h4>
171     <p>It is important to set up ssh key forwarding to enable your use of git
172       repositories while logged into the VM.&nbsp; Key forwarding should be
173       enabled for the VM's two fake host identities:</p>
174     <pre><span style="font-weight: bold;">cakelampvm.com<br>10.28.42.20</span></pre>
175     <p>The details of configuring ssh key forwarding vary for each ssh
176       client.&nbsp; For Linux ssh, the <b>~/.ssh/config</b> file might contain
177       this information:</p>
178     <pre><b>Host cakelampvm.com 10.28.42.20<br>&nbsp; ForwardAgent yes<br></b></pre>
179     <pre><span style="font-weight: bold;"></span></pre>
180     <h2>Updating cakelampvm to the Latest Model<a id="#update-vm" name="#update-vm"></a></h2>
181     <p>&#9733; This section requires that the VM is already configured and is
182       accessible via ssh.</p>
183     <p>argh: fix this info... The cakelampvm v002 is released with the intention
184       that it not need to be released again.&nbsp; Version 001 was not built
185       with that explicit intention, which then required the release of Version
186       002.&nbsp; But we hope to not need a v003 release...</p>
187     <p>There is an update feature built into the VM that is quite easy to
188       use.&nbsp; The updates are driven by the feisty meow script repository in
189       conjunction with a local scripted command.&nbsp; To activate the "update
190       process" for your VM, run the following commands on the VM, logged in as
191       the <i>developer</i> user:</p>
192     <pre><span style="font-weight: bold;"># update to the latest version of feisty meow.<br>rpuffer $FEISTY_MEOW_APEX; recustomize<br># enact any configuration changes needed, such as permissions and account setup.
193 revamp_cakelampvm</span></pre>
194     <span style="font-weight: bold;"> </span>
195     <p>These two commands can be run at any time to patch up your VM to the
196       latest configuration.</p>
197     <p>Recent versions of feisty meow support a new "<span style="font-weight: bold; font-family: monospace;">get_feisty</span>"
198       command, which will behave the same as the first line above.&nbsp; Once
199       you have run the "puffer..." command above for the first time (on
200       cakelampvm v002), this new command becomes available.</p>
201     <ul>
202       <li>The "<span style="font-weight: bold; font-family: monospace;">get_feisty</span>"
203         command is useful in its own right for getting the latest version of the
204         feisty meow code; run it again if you need bug fixes or if you want the
205         most recent cakelampvm documentation.</li>
206       <li>The "<span style="font-weight: bold; font-family: monospace;">revamp_cakelampvm</span>"
207         command can be used to repair many situations when the cakelampvm has
208         gone astray, especially for problems with permissions.</li>
209     </ul>
210     <h2>First Tasks as the Developer User</h2>
211     <p>&#9733; This section requires that the VM is already configured and is
212       accessible via ssh.</p>
213     <p>Here are some first steps that will make the vm your own.</p>
214     <ol>
215       <li>Change your password for the developer account.&nbsp; (This may
216         eventually be required and automatic.)&nbsp; First, log into the VM with
217         ssh.&nbsp; Then type this command:<br>
218         <pre><span style="font-weight: bold;">passwd</span></pre>
219         The 'passwd' command will ask for your current password, and then for a
220         new password plus a verification of that new password.<br>
221         You will probably want to change your samba password as well, which is
222         used when accessing the virtual machine over the network.&nbsp; This is
223         a different, but very similar, command on Linux:<br>
224         <pre><span style="font-weight: bold;">smbpasswd</span></pre>
225         &nbsp;</li>
226       <li>Change your git configuration for the user and email address.&nbsp;
227         This is how we've configured it so far:<br>
228         <ul>
229           <li>
230             <pre><span style="font-weight: bold;">git config --global user.email "developer@cakelampvm.com"</span></pre>
231           </li>
232           <li>
233             <pre><span style="font-weight: bold;">git config --global user.name "Developer J. Cakemo"</span></pre>
234           </li>
235         </ul>
236         If you're developing on a real project, you probably don't want the
237         bogus email and even more bogus name above attached to your
238         commits.&nbsp; Just run the two commands again but with proper values.</li>
239     </ol>
240     <h2>Powering up with the Feisty Meow® scripts<a id="#powerup" name="#powerup"></a></h2>
241     The feisty meow scripts are a cohesive bash scripting environment for
242     getting a variety of tasks done.&nbsp; The feisty meow scripts recently
243     incorporated the "avbash" collection from Saco Design and added those
244     scripts to a new "site_avenger" collection of scripts.&nbsp; The site
245     avenger scripts provide tools for bringing up CakePHP web sites and managing
246     the collection of repositories for those sites.&nbsp; Each website is
247     considered an "application", and the application name itself (e.g.
248     "winterportlibrary") can often provide all the details for "powering up" the
249     site.&nbsp; The feisty meow team has added additional scripts for managing
250     DNS domains and Apache websites that provide the capability to "stand up" an
251     entire website around an application, with an accompanying DNS domain and an
252     Apache2 site definition.
253     <p>The site avenger scripts are documented separately within the feisty meow
254       codebase.&nbsp; Consult the <span style="text-decoration: underline;">f</span><a
255         target="_blank" title="quickstart" href="https://feistymeow.org/feisty_meow/readme.txt">eisty
256 meow
257         readme</a> file first, as it provides some valuable information on
258       configuring the codebase initially.&nbsp; The site avenger script commands
259       are documented in the <a target="_blank" title="useful commands" href="https://feistymeow.org/feisty_meow/documentation/feisty_meow_command_reference.txt">feisty
260         meow command reference</a> file.</p>
261     <p>(The feisty meow codebase is already configured for the developer account
262       on the cakelampvm virtual machine.)</p>
263     <h2>Using the guest VM's DNS services<a id="#dns-from-vm" name="#dns-from-vm"></a></h2>
264     <p>&#9733; This section requires that the VM is already configured and is
265       accessible via ssh.</p>
266     <p>The cakelampvm has been set up to provide a DNS server which will answer
267       name lookup requests on any of the sites that the cakelampvm is hosting
268       for you.&nbsp; It will also serve as a general DNS server for any other
269       domains that need to be looked up.</p>
270     <p>To use the cakelampvm DNS, modify your host operating system network
271       configuration by adding or changing the DNS server to use the guest VM's
272       DNS service.&nbsp; The cakelampvm is available at the local IP address
273       10.28.42.20.&nbsp; (The DNS server can be tested with nslookup, dig and
274       other tools.)</p>
275     <p>Note that the cakelampvm DNS should be listed first, if one intends to
276       override any DNS names that actually exist out on the internet.&nbsp;
277       Further, we have found it most effective to have *only* the cakelampvm as
278       your DNS server, because a secondary DNS server can "take over" providing
279       the name lookups, and thus foul up DNS requests that should succeed for
280       your VM-hosted sites.</p>
281     <p>If your Host PC is running Windows, see the DNS configuration section
282       below that is tailored to that operating system.</p>
283     <p>Important Note: It behooves you to remember to switch back to a normal
284       DNS server configuration when you shut off the cakelampvm, or your machine
285       will not know the names of any sites on the internet any more!&nbsp; The
286       official Google DNS servers are 8.8.8.8 and 8.8.4.4.</p>
287     <p>Once the DNS server is properly set up (by whatever means necessary),
288       these ping commands should get answering responses (from 10.28.42.20) on
289       both the cakelampvm VM and on your host PC.&nbsp; Note: ping on Linux
290       keeps going forever, so hit control-C when you are tired of seeing the
291       pings:</p>
292     <pre><span style="font-weight: bold;">ping cakelampvm.com</span></pre>
293     <span style="font-weight: bold;"> </span>
294     <pre><span style="font-weight: bold;">ping www.cakelampvm.com</span></pre>
295     <p>Note that any other answer than 10.28.42.20 for the address is *bzzzt*
296       wrong, and means something needs to be fixed.</p>
297     <p>If these pings succeed (which hopefully they will!), then try accessing
298       the websites of each domain:</p>
299     <pre>(browse to) <a target="_blank" title="vm website if dns working" href="http://cakelampvm.com">http://cakelampvm.com</a></pre>
300     <pre>(browse to) <a target="_blank" title="mapsdemo app, hopefully functional"
301 href="http://mapsdemo.cakelampvm.com">http://mapsdemo.cakelampvm.com</a></pre>
302     <p>These should show local sites on the VM rather than sites on the
303       internet.&nbsp; If you instead get failures to find the domains, or if the
304       "real internet" site comes up for cakelampvm.com (the page covered with
305       red X marks and complaining), then the DNS is not hooked up properly yet.</p>
306     <h4>Setting up DNS on Windows<a id="#windoze-dns" name="#windoze-dns"></a></h4>
307     <p>The ipconfig tool will provide helpful information about your current
308       networking and DNS configuration:</p>
309     <pre><span style="font-weight: bold;">&gt; ipconfig /all</span></pre>
310     <p>The DNS configuration on Windows is somewhat byzantine.&nbsp; The pipe
311       characters ('|') below are used to separate the menus or tabs or dialogs
312       to traverse.&nbsp; Follow this path to get to the DNS config:</p>
313     <pre>Control Panel | Network &amp; Internet | Network &amp; Sharing | click WiFI or Ethernet link near top right | click Adapter Settings button...<br>  &nbsp;| click on the specific network device to modify | select Properties</pre>
314     <p>Once the properties dialog is displayed, find "internet protocol version
315       4" in the list and double click it.</p>
316     <p>Change the DNS setting from "obtain...automatically" to "use the
317       following dns addresses".</p>
318     <p>Enter 10.28.42.20 as the first DNS address and clear the second address
319       (all blanks).</p>
320     <p>Hit okay, then okay, then close, etc to back out of adapter
321       configuration.</p>
322     <h4>Troubleshooting the DNS</h4>
323     <p>If your pings are getting the wrong answers and you're certain the DNS
324       settings on your Host PC are right, then you may need to flush your DNS
325       cache, and that might be sufficient to start getting the right IP
326       address.&nbsp; On Windows, the command for flushing DNS is:</p>
327     <pre><span style="font-weight: bold;">&gt; ipconfig /flushdns</span></pre>
328     <p>and on Linux the flush DNS command can be many different things, but try
329       these two most common options:</p>
330     <pre><span style="font-weight: bold;"># restarts the client side DNS cache.<br>sudo service dns-clean restart</span></pre>
331     <p>or</p>
332     <pre><span style="font-weight: bold;"># restarts the nscd caching server.<br>sudo service nscd restart</span></pre>
333     After, this try the pings again.&nbsp; If they still fail, please go back
334     over your DNS configuration very carefully.&nbsp; The cakelampvm's DNS
335     feature *does* actually work, but operating systems sometimes do their best
336     to deny this.<br>
337     <h4>Host Key Issues for ssh</h4>
338     <p>There is one caveat to be aware of when connecting to the cakelampvm.com
339       domain.&nbsp; If you have accidentally added the "real" cakelampvm.com
340       domain from the internet to your ssh known_keys at some point, then ssh
341       will complain about connecting to the VM on the cakelampvm.com
342       domain.&nbsp; This complaint will look like:</p>
343     <pre>The authenticity of host 'cakelampvm.com (104.236.56.82)' can't be established.</pre>
344     <p>Note that the IP address shown is not our beloved 10.28.42.20 local IP
345       address.</p>
346     <p>To fix this, remove the entry pointing at the "real" site from the
347       known_hosts file (ssh will print out the line number of the offending
348       entry).&nbsp; The DNS configuration needs to be configured before you will
349       get the warning about the cakelampvm.com domain.&nbsp; Up until then, the
350       domain name is always referring to the site out on the internet with the
351       red X's and warnings.&nbsp; See the DNS configuration section below to
352       configure DNS the first time.</p>
353     <p>Once you connect to the VM and the ssh client records the VM's host key
354       in your known_hosts, then you're in good shape.&nbsp; This state also
355       gives you a "canary in a coal mine" warning system...&nbsp; Once the VM is
356       registered as a known host, then any attempt to connect back to the "real"
357       internet version of cakelampvm.com will garner a complaint from ssh.&nbsp;
358       This version of the ssh warning should be heeded; you do not want to
359       connect to the real internet site, and the warning indicates that the host
360       PC is no longer using the DNS on the VM (since it reached the real
361       internet site instead of the VM).&nbsp; That situation needs to be
362       corrected by running through the DNS configuration section again (and
363       testing the DNS until it is working).</p>
364     <h4>Troubleshooting the Apache Sites</h4>
365     <p>If your DNS pings and lookups are functioning properly, but you're just
366       not getting the right websites, then try clearing your browser's cache and
367       shutting the browser application down.&nbsp; Then, start the browser up
368       and try the address again.&nbsp; Often this cache dumping is enough to fix
369       the browser so that you start seeing the local website versions on
370       cakelampvm.com.</p>
371     <h2>Editing files on the guest VM from the host<a id="#editing-files-on-vm"
372         name="#editing-files-on-vm"></a></h2>
373     <p>On the host computer, look for the guest vm as a networked computer
374       called cakelampvm.&nbsp; This should provide some network shares using
375       Microsoft SMB protocol, and they can be attached to using the "developer"
376       user and its password.</p>
377     <p>On windows, one may want to mount this network location as a drive letter
378       for easier access.</p>
379     <p>Currently, the root of all web servers is exposed as "www".&nbsp; Editing
380       the files in those folders requires ownership by the developer user.&nbsp;
381       The existing mapsdemo site is owned by a different user ("fred") rather
382       than developer, mostly as a test case.&nbsp; The "fred", "developer", and
383       "www-data" accounts on the VM have all been put into each others Unix
384       "groups" so that they can access each other's files, and thus you may not
385       notice any issues editing fred's files.</p>
386     <p>One should be able to create a new directory over the network also.&nbsp;
387       Try creating a junk folder in the "www" folder, and then deleting it
388       again.&nbsp; That should succeed, and this approach can be used to create
389       folders (from the Host PC) that are owned by the developer user (on the
390       VM).&nbsp; You should be able to create folders or copy files within the
391       developer's home folder also ("/home/developer").</p>
392     <p>If you run into any permission problems that prevent file access, either
393       remotely or within the VM itself, then try running this command to fix
394       them (repeated from the section above about updating the cakelampvm):</p>
395     <pre><span style="font-weight: bold;">revamp_cakelampvm</span></pre>
396     <p>Afterwards, the www folder and others should allow the developer user to
397       create new folders at will.</p>
398     <h2>Accessing files on the host PC from the guest VM<a id="#samba-shares" name="#samba-shares"></a></h2>
399     <p>If you want to share a folder from the host to the guest, perhaps for
400       driver updates or other conveniences, then make the share with these
401       steps:</p>
402     <ol>
403       <li>Create a folder on the host that is to be shared.</li>
404       <li>Right-click on the vm in Virtualbox manager and choose "Settings".</li>
405       <li>In the "Shared Folders" tab of the settings, go to "Machine Folders".</li>
406       <li>Click the folder plus icon to create a new share.</li>
407       <li>Fill in the "Folder Path" on the host PC to the folder that will be
408         shared, and give it a name for the guest.&nbsp; We assume the folder
409         name will be "myshare".</li>
410       <li>On the guest vm, run the following commands to mount the share:<br>
411         <pre><span style="font-weight: bold;"># make the guest's version of the shared folder<br>mkdir ~/shared<br># mount the vm's share name onto the folder on the vm.<br>sudo mount -t vboxsf myshare ~/shared</span></pre>
412       </li>
413     </ol>
414     <h2>X11 applications launched from the VM</h2>
415     <p>[incomplete section]</p>
416     <p>If a feature called "X forwarding" is enabled in your ssh client, then
417       you can start graphical applications on the VM and display them on your
418       local machine.&nbsp; This works right away on most Linux hosts, but can
419       also work on PCs with X window system installed.&nbsp; This section
420       describes how to set up Cygwin to run X server, which enables X11
421       forwarding to your local display.</p>
422     <p>...{insert that info}...</p>
423     <h2>Handy Techniques for Using cakelampvm</h2>
424     <h3>Assorted Guides and Cheat-Sheets</h3>
425     <p>A Cheat sheet for the Vim editor (there are many of these available): <a
426         target="_blank" title="vim commands" href="https://vim.rtorr.com/">https://vim.rtorr.com/</a></p>
427     <p>A git branching model that seems to work well: <a target="_blank" title="release and patch process"
428         href="http://nvie.com/posts/a-successful-git-branching-model/">http://nvie.com/posts/a-successful-git-branching-model/</a></p>
429     <p>This is a basic guide to the Google Developer Console and API Key
430       management: <a target="_blank" title="apis and creds at google" href="https://feistymeow.org//feisty_meow/documentation/google_apis/google_apis_and_credentials.pdf">Google
431         API Docs</a>&nbsp; </p>
432     <h3>Using the "meld" Tool to Compare Files &amp; Directories</h3>
433     <p>Meld is a great comparison tool that displays differences between two
434       files or directories or directory trees in a graphical view.&nbsp; Meld is
435       pre-installed on the VM.&nbsp; This tool can be launched either in the
436       VM's X Windowing System (on the console) or if X11 forwarding is enabled.</p>
437     <p>To run meld, just type this command:</p>
438     <pre><span style="font-weight: bold;">meld A B</span></pre>
439     <p>where A and B are either both file names or they are both directory
440       names.&nbsp; If A and B are directories, meld will compare the entire tree
441       structure between the two directories.&nbsp; It allows one to copy from
442       one side to the other, even if the item that needs to be copied is an
443       entire subdirectory.</p>
444     <h3>Get the network address on the guest vm</h3>
445     <p>Run this command:</p>
446     <pre><span style="font-weight: bold;">ifconfig</span></pre>
447     <p>In the results, look for "<span style="font-family: monospace;">inet addr</span>".&nbsp;
448       There may be more than one, if there are multiple network interfaces.</p>
449     <p>The standard IP address is 10.28.42.20 for the cakelampvm.</p>
450     <h3>How to cleanly reboot or shut down the guest VM</h3>
451     <p>When you've got the DNS and everything integrated, these commands will
452       manage the vm's state:</p>
453     <p>First, log into the guest VM:</p>
454     <pre><span style="font-weight: bold;">ssh developer@cakelampvm.com</span></pre>
455     <p>Then, to reboot the guest VM:</p>
456     <pre><span style="font-weight: bold;">sudo reboot</span></pre>
457     <p>Or, to halt the guest VM:</p>
458     <pre><span style="font-weight: bold;">sudo shutdown -h now</span></pre>
459     <p>Using these commands is kinder to the VM than just cycling the power from
460       the Virtualbox control panel.</p>
461     <h1>Gritty Details of the Nitty Variety<a id="#nitty-gritty" name="#nitty-gritty"></a></h1>
462     <p>This is the lowest level of plumbing for your VM.&nbsp; Hopefully you
463       will not need to engage with this section.&nbsp; The most useful doc
464       section here is the one below about the "Virtualbox guest additions",
465       which you will probably need at some future point.&nbsp; Oracle releases
466       updates to the guest additions fairly regularly.</p>
467     <h2>Configuring the guest VM</h2>
468     <p>The guest VM should already be set up appropriately.&nbsp; These steps
469       are provided for reference and updates.</p>
470     <h3>Set up Virtualbox guest additions for the VM</h3>
471     This procedure is needed if the guest provides an older or incompatible
472     version of the guest additions (which have already been installed on the
473     guest vm).&nbsp; It may also be necessary when a new version of the guest
474     additions becomes available.
475     <ol>
476       <li>To install the guest additions, open the guest VM and have its window
477         in focus.</li>
478       <li>Choose the "Devices" menu and select "Insert Guest Additions CD
479         Image".&nbsp; This will mount the CD's ISO image on the VM.</li>
480       <li>On the guest VM, it may be necessary to mount the CD image that's now
481         available:<br>
482         <pre><span style="font-weight: bold;">sudo mount /dev/sr0 /media/cdrom</span></pre>
483         <p>Linux will mention that the device is mounted "read-only".</p>
484       </li>
485       <li>Since the VM currently has no windowing system installed, one must
486         start the Guest Additions install manually:<br>
487         <pre><span style="font-weight: bold;">cd /media/cdrom<br>sudo sh VBoxLinuxAdditions.run</span></pre>
488       </li>
489       <li>The latest Virtualbox guest additions should now be installed.</li>
490     </ol>
491     <h3>Set up network adapters on guest VM</h3>
492     <p>The network interfaces should already be configured on the guest within
493       the Virtualbox configuration.&nbsp; This is available by clicking on the
494       VM in the Virtualbox manager and selecting "Settings".&nbsp; These are the
495       configuration settings used:</p>
496     Adapter 1:<br>
497     &nbsp; Attached to: Host-only Adapter<br>
498     &nbsp; Name: vboxnet0&nbsp; <br>
499     <p>Adapter 2:<br>
500       &nbsp; Attached to: Nat Network<br>
501       &nbsp; Name: NatNetwork</p>
502     <p>On the guest VM itself, the network settings are specified in a file
503       called /etc/network/interfaces.&nbsp; Here are the current contents of
504       that file:</p>
505     <pre>source /etc/network/interfaces.d/*<br><br>auto lo<br>iface lo inet loopback<br><br>auto enp0s3<br>iface enp0s3 inet static<br>&nbsp; address 10.28.42.20<br>&nbsp; netmask 255.255.255.0<br>&nbsp; network 10.28.42.0<br>&nbsp; broadcast 10.28.42.255<br>&nbsp; dns-domain cakelampvm.com<br>&nbsp; dns-search cakelampvm.com<br>&nbsp; dns-nameservers 127.0.0.1 8.8.8.8</pre>
506     <pre>auto enp0s8</pre>
507     <pre>iface enp0s8 inet dhcp</pre>
508     <p> </p>
509     <h3>Compacting the VM Disk Image</h3>
510     <p>To minimize the size used for the disk image, there are three major
511       steps.</p>
512     <p>1. While running the VM, run this command:</p>
513     <pre><span style="font-weight: bold;">sudo apt clean</span></pre>
514     <p>This throws away any cached data from the apt tool, which can be
515       substantial.</p>
516     <p>If there are other junk files you know of that can be removed, delete
517       those now also.</p>
518     <p>2. Reboot the VM to the gparted ISO image (available at the <a target="_blank"
519         title="great free partition editor" href="https://gparted.org/livecd.php">gparted
520         site</a>) and run the following command:</p>
521     <pre><span style="font-weight: bold;">sudo zerofree /dev/sda</span></pre>
522     <p>This sets all free space to the zero byte, enabling Virtualbox to free
523       that space in the next step.</p>
524     <p>3. Shut the vm down after zerofree is complete and run this command on
525       the host PC (this is the Linux version of the command):</p>
526     <pre><span style="font-weight: bold;">VBoxManage modifyhd --compact ~/cake_lamp_vm/cake-lamp-vm-hd.vdi</span></pre>
527     <p>Replace the <span style="font-family: monospace;">~/cake_lamp_vm</span>
528       path with the real VM storage path.&nbsp; This command compacts the root
529       (and only) partition of the VM.</p>
530     <p>After these steps are complete, the VM should be its minimal size.</p>
531     <h2>Adding a new website and domain on the guest VM</h2>
532     <p>Note: these instructions, even the quick approaches below, pale in
533       comparison to the ease of use of the "standup" command in feisty meow's
534       site avenger scripts.&nbsp; The standup command is detailed in the&nbsp;<a
535         target="_blank" title="useful commands" href="https://feistymeow.org/feisty_meow/documentation/feisty_meow_command_reference.txt">feisty
536         meow command reference</a> document.&nbsp; These instructions are for
537       situations when the domain or site is idiosyncratic in some way that
538       standup doesn't support.</p>
539     <p>To add a new website, you will first need to pick one of the DNS options
540       below (A or B) depending on how you want to name the site.&nbsp; If the
541       DNS name of the site is contained within another existing domain (e.g.,
542       "A.B.C" has subdomain A contained in domain B.C), use Option A.&nbsp; If
543       the DNS name is a so-called "Second Level Domain" (SLD), then it stands on
544       its own (e.g., "B.C" is an SLD).</p>
545     <p>Once the DNS option has been picked and implemented, continue to the next
546       section of "Creating a New Apache Site".</p>
547     <p>For either Option A or Option B, first connect to the cakelampvm via ssh
548       as the developer user, e.g.: ssh developer@cakelampvm.com </p>
549     <h3>DNS Option A: Adding a sub-domain in an existing domain</h3>
550     <p>Let us say a customer needs an application called "excalibur".&nbsp; It
551       will be a new subdomain within an existing domain, such as the
552       "cakelampvm.com" domain, meaning we want the VM to start answering
553       requests for "excalibur.cakelampvm.com".</p>
554     Note that this option requires the containing domain "cakelampvm.com" to
555     already exist before adding the subdomain; see DNS Option B below for
556     details on how to add a containing domain for the first time.
557     <h4>Quick approach: Use the feisty meow "add_domain" command.</h4>
558     <p>Run this command in a bash shell on the VM:</p>
559     <pre><span style="font-weight: bold;">add_domain excalibur.cakelampvm.com</span></pre>
560     <p>Done.</p>
561     <h4>Manual approach: Edit the bind9 configuration.</h4>
562     <p>Note: the manual approach is not compatible with later use of feisty
563       meow's "remove_domain".</p>
564     Execute the following command to edit the DNS file for the cakelampvm
565     domain:
566     <pre><span style="font-weight: bold;">sudo vi /etc/bind/cakelampvm.com.conf</span></pre>
567     <p>Add a stanza for the new site at the end of this file:</p>
568     <pre>excalibur.cakelampvm.com.&nbsp;&nbsp;&nbsp; IN A&nbsp;&nbsp;&nbsp; 10.28.42.20<br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; IN HINFO "linux server" "ubuntu"</pre>
569     <p>Restart the DNS server:</p>
570     <pre><span style="font-weight: bold;">sudo service bind9 restart</span></pre>
571     <p>Afterwards, pinging excalibur.cakelampvm.com should work from both the
572       guest VM and the host PC.</p>
573     <h3>DNS Option B: Using an entirely new domain for the site</h3>
574     <p>This is a similar procedure to Option A, but we will create a totally new
575       config file for the new domain and add it to the bind directory.&nbsp; For
576       this example, we need to add the site "excalibur.tv" into the DNS.</p>
577     <h4>Quick approach: Use the feisty meow "add_domain" command.</h4>
578     Run this command in a bash shell on the VM:
579     <pre><span style="font-weight: bold;">add_domain excalibur.tv</span></pre>
580     <p>Done.</p>
581     <h4>Manual approach: Edit a new DNS config file</h4>
582     <p>Note: the manual approach is not compatible with later use of feisty
583       meow's "remove_domain".</p>
584     Create a file called /etc/bind/excalibur.tv.conf for our new domain
585     excalibur.tv with these contents:
586     <pre>$TTL 1W<br>@&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; IN SOA&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; @&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; fred.cakelampvm.com. (<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 2017100801&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; ; serial<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 2H&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; ; refresh<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 8M&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; ; retry<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 14D&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; ; expiry<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 6H )&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; ; minimum<br><br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; IN NS&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; ns.cakelampvm.com.<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; IN MX&nbsp;&nbsp; 10&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; mail.cakelampvm.com.<br><br># new SLD for our excalibur site.<br>excalibur.tv.&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; IN A&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 10.28.42.20<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; IN HINFO&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; "linux server" "ubuntu"</pre>
587     The gnarly prefix stuff above the "excalibur.tv." listing establishes
588     configuration info for the new domain.&nbsp; This file relies on the
589     existing cakelampvm.com infrastructure in DNS, such as the "ns" host, which
590     is the domain's name server.&nbsp; However, the new domain does <span style="text-decoration: underline;">not</span>
591     live inside the cakelampvm.com domain.<br>
592     <p>Now that the config file is in place, edit "/etc/bind/named.conf.local"
593       to add the new file by adding this bit of configuration at the end:</p>
594     <pre>zone "excalibur.tv" in {<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; file "/etc/bind/excalibur.tv.conf";<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; type master;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; allow-query { any; };<br>};</pre>
595     <p>Restart the DNS server:</p>
596     <pre><span style="font-weight: bold;">sudo service bind9 restart</span></pre>
597     <p>Afterwards, pinging excalibur.tv should work from both the guest and the
598       host.</p>
599     <h3>Creating a New Apache Site</h3>
600     <p>First, connect to the cakelampvm via ssh as the developer user, e.g.: ssh
601       developer@cakelampvm.com </p>
602     <h4>Quick approach: Use the feisty meow "add_apache_site" command.</h4>
603     <p>Run this command in a bash shell on the VM:</p>
604     <pre><span style="font-weight: bold;">add_apache_site excalibur excalibur.tv</span></pre>
605     <p>(The first parameter is the application name, the second is the domain
606       name.)</p>
607     <p>Done.</p>
608     <h4>Manual approach: Edit an Apache config file</h4>
609     <p>Note: the manual approach is not compatible with later use of feisty
610       meow's "remove_apache_site".</p>
611     <p>For Apache, the choice of DNS Option A or B, subdomain or SLD, does not
612       matter.&nbsp; The site configuration file just has to accurately specify
613       the domain in question.</p>
614     <p>Start with the following template file for the new website, and modify it
615       for the appropriate host name and "DocumentRoot" path:</p>
616     <pre>&lt;VirtualHost *:80&gt;<br>&nbsp;&nbsp;&nbsp; ServerName excalibur.tv
617 &nbsp;&nbsp;&nbsp; DocumentRoot /home/apps/excalibur<br>&nbsp;&nbsp;&nbsp; ErrorLog ${APACHE_LOG_DIR}/excalibur.tv-error.log<br>&nbsp;&nbsp;&nbsp; CustomLog ${APACHE_LOG_DIR}/excalibur.tv-access.log combined<br>&nbsp;&nbsp;&nbsp; Include /etc/apache2/conf-library/basic-options.conf<br>&nbsp;&nbsp;&nbsp; Include /etc/apache2/conf-library/rewrite-enabling.conf<br>&lt;/VirtualHost&gt;</pre>
618     <p>The above example is appropriate for our excalibur app in the
619       excalibur.tv domain (using DNS Option B).&nbsp; Modifying the excalibur.tv
620       references in it (and the path in the DocumentRoot) is sufficient to
621       re-target it for any domain you want.</p>
622     <p>Copy the new site config file into "/etc/apache2/sites-available" with an
623       appropriate file name that includes the site's domain name.&nbsp; We will
624       call our config file "excalibur.tv.conf".&nbsp; If you developed the file
625       in your home folder, this would be the command to move it up to Apache:</p>
626     <pre><span style="font-weight: bold;">sudo cp ~/excalibur.tv.conf /etc/apache2/sites-available</span></pre>
627     <p>Then tell apache to use the new file:</p>
628     <pre><span style="font-weight: bold;">sudo a2ensite excalibur.tv<br># the '.conf' portion of the filename is unnecessary for this command.</span>
629 </pre>
630     <p>Finally, restart apache to get it to begin serving the site:</p>
631     <pre><span style="font-weight: bold;">sudo service apache2 restart</span></pre>
632     <h3>Test the new web site</h3>
633     <p>Given the configuration above, your host PC should now be able to access
634       the new website on the domain "excalibur.tv".</p>
635     <p>To test this, first try pinging the new DNS name:</p>
636     <pre><span style="font-weight: bold;">ping excalibur.tv</span></pre>
637     <p>If there are responses to the ping <span style="font-weight: bold;">*and*</span>
638       the answer is 10.28.42.20, then it means the DNS is working.</p>
639     <p>If there are no responses or it's some other IP address talking back,
640       check the instructions in the above DNS sections.</p>
641     <p>Once the DNS is working, try browsing to the site at "<a title="it's excalibur, wilbur!"
642         href="http://excalibur.tv">http://excalibur.tv</a>".&nbsp; That should
643       at least bring up the configured site storage path, even if nothing is
644       being served from that folder yet.</p>
645     <p>If the new site is not showing up properly, try examining the apache logs
646       for any error messages that can be corrected.&nbsp; The log files are
647       stored in "/var/log/apache2" and are named after the website (if
648       configured through the above process).</p>
649     <h2>Notes on building the Cake Lamp VM</h2>
650     <p>This is all work that should already have been done.&nbsp; It is
651       mentioned here just as breadcrumbs for a future vm builder.</p>
652     <ul>
653       <li>Downloaded and installed Virtualbox for host computer (where the vm
654         image will be built).</li>
655       <li>Downloaded ubuntu server 16.04 iso. (<a target="_blank" title="ubuntu server"
656           href="https://www.ubuntu.com/download/server">https://www.ubuntu.com/download/server</a>)</li>
657       <li>Created a new vm in Virtualbox, telling it to start from the ubuntu
658         server iso.</li>
659       <li>Installed LAMP stack on guest VM.&nbsp; Some help here: <a target="_blank"
660           title="lamplighter" href="http://howtoubuntu.org/how-to-install-lamp-on-ubuntu">http://howtoubuntu.org/how-to-install-lamp-on-ubuntu</a></li>
661       <li>Configured CAKE on the guest VM.&nbsp; Useful link: <a target="_blank"
662           title="cakebundtu" href="https://askubuntu.com/questions/628938/how-to-install-cakephp-in-ubuntu-14-04">https://askubuntu.com/questions/628938/how-to-install-cakephp-in-ubuntu-14-04</a></li>
663       <li>Configured the two network adapters as needed (one for host-only
664         network and one for nat network).&nbsp; Here's some info about
665         Virtualbox networking with two adapters similar to our setup: <a target="_blank"
666           href="https://askubuntu.com/questions/293816/in-virtualbox-how-do-i-set-up-host-only-virtual-machines-that-can-access-the-in">https://askubuntu.com/questions/293816/in-virtualbox-how-do-i-set-up-host-only-...</a><br>
667       </li>
668       <li>Installed and configured Samba service for the guest VM.&nbsp; The
669         main config file lives in "/etc/samba/smb.conf".&nbsp; Some pointers
670         here: <a target="_blank" href="https://help.ubuntu.com/community/How%20to%20Create%20a%20Network%20Share%20Via%20Samba%20Via%20CLI%20%28Command-line%20interface/Linux%20Terminal%29%20-%20Uncomplicated%2C%20Simple%20and%20Brief%20Way%21">https://help.ubuntu.com/community/How%20to%20Create...</a></li>
671     </ul>
672     <p><br>
673     </p>
674     <ul>
675     </ul>
676     <h6> </h6>
677     <p> </p>
678   </body>
679 </html>