1f127fc356cc434b47d9dad786ae0c0810fd95c8
[feisty_meow.git] / production / sites / cakelampvm.com / docs / manual / cakelampvm_guide_v002.html
1 <!DOCTYPE html>
2 <html>
3   <head>
4     <meta content="text/html; charset=windows-1252" http-equiv="content-type">
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     <h2 style="   text-align: center;">By Chris Koeritz<br>
11       <span style="font-family: Comic Sans MS;">feisty meow® concerns ltd</span></h2>
12     <h3 style="   text-align: center;"> Vintage: cakelampvm v002 &nbsp;&nbsp;
13       Updated: 2017-11-20 (rev F)</h3>
14     <p>The cakelampvm project provides a Virtualbox VM that acts as an "internet
15       in a bottle", serving up your web sites securely and only to your local
16       host.&nbsp; The virtual machine provides DNS services (<a target="_blank"
17         title="dns server" href="http://www.bind9.net/">bind9</a>), a Web server
18       (<a target="_blank" title="patchy" href="https://httpd.apache.org/">Apache2</a>),
19       a full <a target="_blank" title="ubuntu means compassion and humanity" href="https://www.ubuntu.com/">Ubuntu</a>
20       <a target="_blank" title="it's pronounced leenoox" href="https://www.linuxfoundation.org/">Linux</a>
21       desktop environment, the <a target="_blank" title="flux is change" href="http://fluxbox.org/">Fluxbox</a>
22       <a target="_blank" title="x11 -- best windowing system" href="https://www.x.org/">X
23         window manager</a>, and a suite of tools called the <a target="_blank"
24         title="feisty meow® concerns ltd. website" href="https://feistymeow.org/">Feisty
25         Meow® codebase</a> .&nbsp; Together, these services provide you with a
26       very flexible and powerful testbed for web development, especially suited
27       for <a target="_blank" title="it's cake" href="https://cakephp.org/">CakePHP</a>.&nbsp;
28       This VM was built with the assistance of and was partially funded by <a target="_blank"
29         title="saco design" href="http://sacodesign.com">Saco Design</a> of <a
30         target="_blank" title="winterport" href="http://www.winterportmaine.gov/">Winterport,
31         Maine</a>.</p>
32     <p>Commands preceded by an octothorpe ('#') below are intended to be typed
33       into a bash shell running on the cakelampvm virtual machine.&nbsp; The
34       bash shell can be obtained either by logging into the VM through ssh or by
35       logging in directly to the Virtualbox VM console.&nbsp; You may find the
36       ssh session more convenient, because copy &amp; paste features work as
37       expected.</p>
38     <p>Commands preceded by a greater-than symbol ('&gt;') are intended to be
39       run on the Host PC in a Windows command prompt (or in a bash prompt
40       running on the Host PC).</p>
41     <h2> Guest VM Configuration<a id="#config" name="#config"></a></h2>
42     <ul>
43       <li>Hostname: <a target="_blank" title="the vm's website, when configured properly"
44           href="https://cakelampvm.com/">cakelampvm.com</a></li>
45       <li>Local IP Address: 10.28.42.20</li>
46       <li>Services Included: DNS (bind9), apache2, fluxbox X windowing system, <a
47           target="_blank" title="not just in the garden" href="https://www.gnome.org/">gnome
48           display manager</a></li>
49       <li>Main VM User: developer (password distributed separately)</li>
50       <li>Database Access: mysql root account, password: (password distributed
51         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:<br>
102         <p><img alt="host only network adapter" src="images/host_only_network_adapter.png"></p>
103       </li>
104       <li>Set the "DHCP Server Settings" to disabled, e.g.<br>
105         <img alt="host only dhcp" src="images/host_only_adapter_dhcp_server.png"><br>
106         This is disabled because we will be using statically assigned addresses
107         for convenience and stability.</li>
108     </ol>
109     <p>Additional information on host-only (and other) network adapter types is
110       at: https://www.virtualbox.org/manual/ch06.html#network_nat_service</p>
111     <h3>Configure the NAT Network on Virtualbox<a id="#nat-network" name="#nat-network"></a></h3>
112     <p>The NAT (Network Address Translation) network allows the VM to get off of
113       the machine and onto the internet safely.&nbsp; It will use this interface
114       for any communication off of the host machine.&nbsp; This is another
115       crucial component for the security of the VM and your host PC.&nbsp; Since
116       the real IP address of the VM is hidden behind the NAT firewall on
117       Virtualbox, this keeps the VM safe from attackers, and hence your machine
118       stays safe as well.</p>
119     <p>To set up the NAT network, follow these steps:</p>
120     <ol>
121       <li> Go to virtual box "Preferences" (global preferences, not for a
122         specific vm).</li>
123       <li> Click on the "Network" tab.</li>
124       <li> Choose the "Nat Networks" tab from within "Network".</li>
125       <li> Click the plus icon to add a new host-only network.</li>
126       <li>Set the "NAT Network Details" parameters:<br>
127         Network Name: NatNetwork<br>
128         Network CIDR: 10.0.2.0/24<br>
129         Supports DHCP: checked<br>
130         Supports IPv6: optionally checked<br>
131         These are my settings, with IPv6 left disabled:<br>
132         <img alt="nat net config" src="images/nat_network_config.png"></li>
133     </ol>
134     <h2>Starting up the VM<a id="#start-vm" name="#start-vm"></a></h2>
135     <p>Using the Virtualbox interface, you should now be able to start your
136       virtual machine.&nbsp; Virtualbox will complain if it detects any
137       remaining configuration problems in the VM.&nbsp; The Linux boot sequence
138       will show many lines of text, before bringing up a black console window
139       with a login dialog.</p>
140     <p>If Windows complains about the Virtualbox application slamming into its
141       firewall, then allow the Virtualbox to get through.&nbsp; Usually, telling
142       Windows that once is enough, but if any odd network access problems
143       result, edit the Windows firewall settings and allow Virtualbox to use
144       both "Public" and "Private" networks.</p>
145     <p>You can log in directly on the VM console with the developer account, but
146       it is generally more useful to connect to the cakelampvm over ssh.&nbsp;
147       If the networking has been established properly, you should be able to do
148       this with:</p>
149     <pre># ssh developer@10.28.42.20&nbsp;  # or the equivalent with your ssh client</pre>
150     <p>And then provide the password to log in.</p>
151     <p>Once the DNS services are set up (discussed in detail below), you will be
152       able to run the much friendlier command:</p>
153     <pre># ssh developer@cakelampvm.com</pre>
154     <h2>Updating cakelampvm to the Latest Model<a id="#update-vm" name="#update-vm"></a></h2>
155     <p>The cakelampvm v002 is released with the intention that it not need to be
156       released again.&nbsp; Version 001 was not built with that explicit
157       intention, which then required the release of Version 002.&nbsp; But we
158       hope to not need a v003 release...</p>
159     <p>There is an update feature built into the VM that is quite easy to
160       use.&nbsp; The updates are driven by the feisty meow script repository in
161       conjunction with a local scripted command.&nbsp; To activate the "update
162       process" for your VM, run the following commands on the VM (without the
163       initial '#' symbol):</p>
164     <pre># rpuffer $FEISTY_MEOW_APEX&nbsp;&nbsp; # updates to the latest version of feisty meow
165 # revamp_cakelampvm&nbsp;&nbsp;&nbsp;        # enacts any configuration changes needed,<br>                              # plus fixes web folder and other permissions.</pre>
166     <p>These two commands can be run at any time to patch up your VM to the
167       latest.</p>
168     <p>The first command ("rpuffer ...") is also useful on its own for getting
169       the latest version of the feisty meow code.&nbsp; Run it again if there
170       are bug fixes you need for any of the scripts or if you would like the
171       most up-to-date cakelampvm documentation.</p>
172     <h2>First Tasks as the Developer User</h2>
173     <p>Here are some first steps that will make the vm your own:</p>
174     <ol>
175       <li>Change your password for the developer account.&nbsp; (This may
176         eventually be required and automatic.)&nbsp; First, log into the VM with
177         ssh.&nbsp; Then type this command:<br>
178         <pre># passwd</pre>
179         The 'passwd' command will ask for your current password, and then for a
180         new password plus a verification of that new password.<br>
181         &nbsp;</li>
182       <li>Change your git configuration for the user and email address.&nbsp; This
183         is how we've configured it so far:<br>
184         <pre># git config --global user.email "developer@cakelampvm.com"</pre>
185         <pre># git config --global user.name "Developer J. Cakemo"</pre>
186         If you're developing on a real project, you probably don't want the
187         bogus email and even more bogus name above attached to your
188         commits.&nbsp; Just run the two commands again but with proper values.</li>
189     </ol>
190     <h2>Powering up with the Feisty Meow® scripts<a id="#powerup" name="#powerup"></a></h2>
191     The feisty meow scripts are a cohesive bash scripting environment for
192     getting a variety of tasks done.&nbsp; The feisty meow scripts recently
193     incorporated the "avbash" collection from Saco Design and added those
194     scripts to a new "site_avenger" collection of scripts.&nbsp; The site
195     avenger scripts provide tools for bringing up CakePHP web sites and managing
196     the collection of repositories for those sites.&nbsp; Each website is
197     considered an "application", and the application name itself (e.g.
198     "winterportlibrary") can often provide all the details for "powering up" the
199     site.&nbsp; The feisty meow team has added additional scripts for managing
200     DNS domains and Apache websites that provide the capability to "stand up" an
201     entire website around an application, with an accompanying DNS domain and an
202     Apache2 site definition.
203     <p>The site avenger scripts are documented separately within the feisty meow
204       codebase.&nbsp; Consult the <span style="text-decoration: underline;">f</span><a
205         target="_blank" title="quickstart" href="https://feistymeow.org/feisty_meow/readme.txt">eisty
206 meow
207         readme</a> file first, as it provides some valuable information on
208       configuring the codebase initially.&nbsp; The site avenger script commands
209       are documented in the <a target="_blank" title="useful commands" href="https://feistymeow.org/feisty_meow/documentation/feisty_meow_command_reference.txt">feisty
210         meow command reference</a> file.</p>
211     <p>(The feisty meow codebase is already configured for the developer account
212       on the cakelampvm virtual machine.)</p>
213     <h2>X11 applications launched from the VM</h2>
214     <p>[incomplete section]</p>
215     <p>If a feature called "X forwarding" is enabled in your ssh client, then
216       you can start graphical applications on the VM and display them on your
217       local machine.&nbsp; This works right away on most Linux hosts, but can
218       also work on PCs with X window system installed.&nbsp; This section
219       describes how to set up Cygwin to run X server, which enables X11
220       forwarding to your local display.</p>
221     <p>...{insert that info}...</p>
222     <h2>Using the guest VM's DNS services<a id="#dns-from-vm" name="#dns-from-vm"></a></h2>
223     <p>The cakelampvm has been set up to provide a DNS server which will answer
224       name lookup requests on any of the sites that the cakelampvm is hosting
225       for you.&nbsp; It will also serve as a general DNS server for any other
226       domains that need to be looked up.</p>
227     <p>To use the cakelampvm DNS, modify your host operating system network
228       configuration by adding or changing the DNS server to use the guest VM's
229       DNS service.&nbsp; The cakelampvm is available at the local IP address
230       10.28.42.20.&nbsp; (The DNS server can be tested with nslookup, dig and
231       other tools.)</p>
232     <p>Note that the cakelampvm DNS should be listed first, if one intends to
233       override any DNS names that actually exist out on the internet.&nbsp; We
234       have also found it most effective to have only the cakelampvm as your DNS
235       server, because a secondary DNS server can "take over" providing the name
236       lookups, and thus foul up DNS requests that should succeed for your
237       VM-hosted sites.</p>
238     <p>If your Host PC is running Windows, see the DNS configuration section
239       below that is tailored to that operating system.</p>
240     <p>Important Note: It behooves you to remember to switch back to a normal
241       DNS server configuration when you shut off the cakelampvm, or your machine
242       will not know the names of any sites on the internet any more!</p>
243     <p>Once the DNS server is properly set up (by whatever means necessary),
244       these ping commands should get answering responses (from 10.28.42.20) on
245       both the cakelampvm VM and on your host PC.&nbsp; Note: ping on Linux
246       keeps going forever, so hit control-C when you are tired of seeing the
247       pings:</p>
248     <pre># ping cakelampvm.com</pre>
249     <pre># ping mapsdemo.cakelampvm.com</pre>
250     <p>Note that any other answer than 10.28.42.20 for the address is *bzzzt*
251       wrong, and means something needs to be fixed.</p>
252     <p>If these pings succeed (which hopefully they will!), then try accessing
253       the websites of each domain:</p>
254     <pre>(browse to) <a target="_blank" title="vm website if dns working" href="http://cakelampvm.com">http://cakelampvm.com</a></pre>
255     <pre>(browse to) <a target="_blank" title="mapsdemo app, hopefully functional"
256 href="http://mapsdemo.cakelampvm.com">http://mapsdemo.cakelampvm.com</a></pre>
257     <p>These should show local sites on the VM rather than sites on the
258       internet.&nbsp; If you instead get failures to find the domains, or if the
259       "real internet" site comes up for cakelampvm.com (the page covered with
260       red X marks and complaining), then the DNS is not hooked up properly yet.</p>
261     <h4>Troubleshooting the DNS</h4>
262     <p>If your pings are getting the wrong answers and you're certain the DNS
263       settings on your Host PC are right, then you may need to flush your DNS
264       cache, and that might be sufficient.&nbsp; On Windows, the command for
265       flushing DNS is:</p>
266     <pre>&gt; ipconfig /flushdns</pre>
267     <p>and on Linux the flush DNS command can be many different things, but try
268       these two most common options:</p>
269     <pre># sudo service dns-clean restart&nbsp;&nbsp; # restarts the client side DNS cache.</pre>
270     <p>or</p>
271     <pre># sudo service nscd restart&nbsp;&nbsp; # restarts the nscd caching server.</pre>
272     After, this try the pings again.&nbsp; If they still fail, please go back
273     over your DNS configuration very carefully.&nbsp; The cakelampvm's DNS
274     feature *does* actually work, but operating systems sometimes do their best
275     to deny this.<br>
276     <h4>Troubleshooting the Apache Sites</h4>
277     <p>If your DNS pings and lookups are functioning properly, but you're just
278       not getting the right websites, then try clearing your browser's cache and
279       shutting the browser application down.&nbsp; Then, start the browser up
280       and try the address again.&nbsp; Often this cache dumping is enough to fix
281       the browser so that you start seeing the local website versions on
282       cakelampvm.com.</p>
283     <h3>Setting up DNS on Windows<a id="#windoze-dns" name="#windoze-dns"></a></h3>
284     <p>The ipconfig tool will provide helpful information about your current
285       networking and DNS configuration:</p>
286     <pre>ipconfig --all</pre>
287     <p>The DNS configuration on Windows is somewhat byzantine.&nbsp; The pipe
288       characters ('|') below are used to separate the menus or tabs or dialogs
289       to traverse.&nbsp; Follow this path to get to the DNS config:</p>
290     <pre>Control Panel | Network &amp; Sharing | click WiFI or Ethernet link near top right | click Adapter Settings on left | click on specific network device to modify | select Properties</pre>
291     <p><br>
292     </p>
293     <p>{fill in rest}<br>
294     </p>
295     <p><br>
296     </p>
297     <h2>Editing files on the guest VM from the host<a id="#editing-files-on-vm"
298         name="#editing-files-on-vm"></a></h2>
299     <p>On the host computer, look for the guest vm as a networked computer
300       called cakelampvm.&nbsp; This should provide some network shares using
301       Microsoft SMB protocol, and they can be attached to using the "developer"
302       user and its password.</p>
303     <p>On windows, one may want to mount this network location as a drive letter
304       for easier access.</p>
305     <p>Currently, the root of all web servers is exposed as "www".&nbsp; Editing
306       the files in those folders requires ownership by the developer user.&nbsp;
307       The existing mapsdemo site is owned by a different user ("fred") rather
308       than developer, mostly as a test case.&nbsp; The "fred", "developer", and
309       "www-data" accounts on the VM have all been put into each others Unix
310       "groups" so that they can access each other's files, and thus you may not
311       notice any issues editing fred's files.</p>
312     <p>One should be able to create a new directory over the network also.&nbsp;
313       Try creating a junk folder in the "www" folder, and then deleting it
314       again.&nbsp; That should succeed, and this approach can be used to create
315       folders (from the Host PC) that are owned by the developer user (on the
316       VM).&nbsp; You should be able to create folders or copy files within the
317       developer's home folder also ("/home/developer").</p>
318     <p>If you run into any permission problems that prevent file access, either
319       remotely or within the VM itself, then try running this command to fix
320       them (repeated from the section above about updating the cakelampvm):</p>
321     <pre># revamp_cakelampvm</pre>
322     <p>Afterwards, the www folder and others should allow the developer user to
323       create new folders at will.</p>
324     <h2>Accessing files on the host PC from the guest VM<a id="#samba-shares" name="#samba-shares"></a></h2>
325     <p>If you want to share a folder from the host to the guest, perhaps for
326       driver updates or other conveniences, then make the share with these
327       steps:</p>
328     <ol>
329       <li>Create a folder on the host that is to be shared.</li>
330       <li>Right-click on the vm in Virtualbox manager and choose "Settings".</li>
331       <li>In the "Shared Folders" tab of the settings, go to "Machine Folders".</li>
332       <li>Click the folder plus icon to create a new share.</li>
333       <li>Fill in the "Folder Path" on the host PC to the folder that will be
334         shared, and give it a name for the guest.&nbsp; We assume the folder
335         name will be "myshare".</li>
336       <li>On the guest vm, run the following commands to mount the share:<br>
337         <pre># mkdir ~/shared&nbsp;&nbsp;&nbsp; # for the guest's version of the shared folder<br># sudo mount -t vboxsf myshare ~/shared&nbsp;&nbsp;&nbsp; # mount the vm's share name onto the folder on the vm.</pre>
338       </li>
339     </ol>
340     <h2>Adding a new website and domain on the guest VM</h2>
341     <p>Note: these instructions, even the quick approaches below, pale in
342       comparison to the ease of use of the "standup" command in feisty meow's
343       site avenger scripts.&nbsp; The standup command is detailed in the&nbsp;<a
344         target="_blank" title="useful commands" href="https://feistymeow.org/feisty_meow/documentation/feisty_meow_command_reference.txt">feisty
345         meow command reference</a> document.&nbsp; These instructions are for
346       situations when the domain or site is idiosyncratic in some way that
347       standup doesn't support.</p>
348     <p>To add a new website, you will first need to pick one of the DNS options
349       below (A or B) depending on how you want to name the site.&nbsp; If the
350       DNS name of the site is contained within another existing domain (e.g.,
351       "A.B.C" has subdomain A contained in domain B.C), use Option A.&nbsp; If
352       the DNS name is a so-called "Second Level Domain" (SLD), then it stands on
353       its own (e.g., "B.C" is an SLD).</p>
354     <p>Once the DNS option has been picked and implemented, continue to the next
355       section of "Creating a New Apache Site".</p>
356     <p>For either Option A or Option B, first connect to the cakelampvm via ssh
357       as the developer user, e.g.: ssh developer@cakelampvm.com </p>
358     <h3>DNS Option A: Adding a sub-domain in an existing domain</h3>
359     <p>Let us say a customer needs an application called "excalibur".&nbsp; It
360       will be a new subdomain within an existing domain, such as the
361       "cakelampvm.com" domain, meaning we want the VM to start answering
362       requests for "excalibur.cakelampvm.com".</p>
363     Note that this option requires the containing domain "cakelampvm.com" to
364     already exist before adding the subdomain; see DNS Option B below for
365     details on how to add a containing domain for the first time.
366     <h4>Quick approach: Use the feisty meow "add_domain" command.</h4>
367     <p>Run this command in a bash shell on the VM:</p>
368     <pre># add_domain excalibur.cakelampvm.com</pre>
369     <p>Done.</p>
370     <h4>Manual approach: Edit the bind9 configuration.</h4>
371     <p>Note: the manual approach is not compatible with later use of feisty
372       meow's "remove_domain".</p>
373     Execute the following command to edit the DNS file for the cakelampvm
374     domain:
375     <pre># sudo vi /etc/bind/cakelampvm.com.conf</pre>
376     <p>Add a stanza for the new site at the end of this file:</p>
377     <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>
378     <p>Restart the DNS server:</p>
379     <pre># sudo service bind9 restart</pre>
380     <p>Afterwards, pinging excalibur.cakelampvm.com should work from both the
381       guest VM and the host PC.</p>
382     <h3>DNS Option B: Using an entirely new domain for the site</h3>
383     <p>This is a similar procedure to Option A, but we will create a totally new
384       config file for the new domain and add it to the bind directory.&nbsp; For
385       this example, we need to add the site "excalibur.tv" into the DNS.</p>
386     <h4>Quick approach: Use the feisty meow "add_domain" command.</h4>
387     Run this command in a bash shell on the VM:
388     <pre># add_domain excalibur.tv</pre>
389     <p>Done.</p>
390     <h4>Manual approach: Edit a new DNS config file</h4>
391     <p>Note: the manual approach is not compatible with later use of feisty
392       meow's "remove_domain".</p>
393     Create a file called /etc/bind/excalibur.tv.conf for our new domain
394     excalibur.tv with these contents:
395     <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>
396     The gnarly prefix stuff above the "excalibur.tv." listing establishes
397     configuration info for the new domain.&nbsp; This file relies on the
398     existing cakelampvm.com infrastructure in DNS, such as the "ns" host, which
399     is the domain's name server.&nbsp; However, the new domain does <span style="text-decoration: underline;">not</span>
400     live inside the cakelampvm.com domain.<br>
401     <p>Now that the config file is in place, edit "/etc/bind/named.conf.local"
402       to add the new file by adding this bit of configuration at the end:</p>
403     <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>
404     <p>Restart the DNS server:</p>
405     <pre># sudo service bind9 restart</pre>
406     <p>Afterwards, pinging excalibur.tv should work from both the guest and the
407       host.</p>
408     <h3>Creating a New Apache Site</h3>
409     <p>First, connect to the cakelampvm via ssh as the developer user, e.g.: ssh
410       developer@cakelampvm.com </p>
411     <h4>Quick approach: Use the feisty meow "add_apache_site" command.</h4>
412     <p>Run this command in a bash shell on the VM:</p>
413     <pre># add_apache_site excalibur excalibur.tv</pre>
414     <p>(The first parameter is the application name, the second is the domain
415       name.)</p>
416     <p>Done.</p>
417     <h4>Manual approach: Edit an Apache config file</h4>
418     <p>Note: the manual approach is not compatible with later use of feisty
419       meow's "remove_apache_site".</p>
420     <p>For Apache, the choice of DNS Option A or B, subdomain or SLD, does not
421       matter.&nbsp; The site configuration file just has to accurately specify
422       the domain in question.</p>
423     <p>Start with the following template file for the new website, and modify it
424       for the appropriate host name and "DocumentRoot" path:</p>
425     <pre>&lt;VirtualHost *:80&gt;<br>&nbsp;&nbsp;&nbsp; ServerName excalibur.tv
426 &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>
427     <p>The above example is appropriate for our excalibur app in the
428       excalibur.tv domain (using DNS Option B).&nbsp; Modifying the excalibur.tv
429       references in it (and the path in the DocumentRoot) is sufficient to
430       re-target it for any domain you want.</p>
431     <p>Copy the new site config file into "/etc/apache2/sites-available" with an
432       appropriate file name that includes the site's domain name.&nbsp; We will
433       call our config file "excalibur.tv.conf".&nbsp; If you developed the file
434       in your home folder, this would be the command to move it up to Apache:</p>
435     <pre># sudo cp ~/excalibur.tv.conf /etc/apache2/sites-available</pre>
436     <p>Then tell apache to use the new file:</p>
437     <pre># sudo a2ensite excalibur.tv  # the '.conf' portion of the filename is unnecessary for this command.
438 </pre>
439     <p>Finally, restart apache to get it to begin serving the site:</p>
440     <pre># sudo service apache2 restart</pre>
441     <h3>Test the new web site</h3>
442     <p>Given the configuration above, your host PC should now be able to access
443       the new website on the domain "excalibur.tv".</p>
444     <p>To test this, first try pinging the new DNS name:</p>
445     <pre># ping excalibur.tv</pre>
446     <p>If there are responses to the ping *and* the answer is 10.28.42.20, then
447       it means the DNS is working.&nbsp; If there are no responses or it's some
448       other IP address talking back, check the instructions in the above DNS
449       sections.</p>
450     <p>Once the DNS is working, try browsing to the site at "<a title="it's excalibur, wilbur!"
451         href="http://excalibur.tv">http://excalibur.tv</a>".&nbsp; That should
452       at least bring up the configured site storage path, even if nothing is
453       being served from that folder yet.</p>
454     <p>If the new site is not showing up properly, try examining the apache logs
455       for any error messages that can be corrected.&nbsp; The log files are
456       stored in "/var/log/apache2" and are named after the website (if
457       configured through the above process).</p>
458     <h2>Handy Techniques for Using cakelampvm</h2>
459     <h3>Assorted Guides and Cheat-Sheets</h3>
460     <p>A Cheat sheet for the Vim editor (there are many of these available): <a
461         target="_blank" title="vim commands" href="https://vim.rtorr.com/">https://vim.rtorr.com/</a></p>
462     <p>A git branching model that seems to work well: <a target="_blank" title="release and patch process"
463         href="http://nvie.com/posts/a-successful-git-branching-model/">http://nvie.com/posts/a-successful-git-branching-model/</a></p>
464     <h3>Get the network address on the guest vm</h3>
465     <p>Run this command: ifconfig</p>
466     <p>In the results, look for "inet addr".&nbsp; There may be more than one,
467       if there are multiple network interfaces.</p>
468     <p>The standard IP address is 10.28.42.20 for the cakelampvm.</p>
469     <h3>How to cleanly reboot or shut down the guest VM</h3>
470     <p>When you've got the DNS and everything integrated, these commands will
471       manage the vm's state:</p>
472     <p>First, log into the guest VM:</p>
473     <pre># ssh developer@cakelampvm.com</pre>
474     <p>Then, to reboot the guest VM:</p>
475     <pre># sudo reboot</pre>
476     <p>Or, to halt the guest VM:</p>
477     <pre># sudo shutdown -h now</pre>
478     <p>Using these commands is kinder to the VM than just cycling the power from
479       the Virtualbox control panel.</p>
480     <p><br>
481     </p>
482     <h1>Gritty Details of the Nitty Variety<a id="#nitty-gritty" name="#nitty-gritty"></a></h1>
483     <p>This is the lowest level of plumbing for your VM.&nbsp; Hopefully you
484       will not need to engage with this section.&nbsp; The most useful doc
485       section here is the one below about the "Virtualbox guest additions",
486       which you will probably need at some future point.&nbsp; Oracle releases
487       updates to the guest additions fairly regularly.</p>
488     <h2>Configuring the guest VM</h2>
489     <p>The guest VM should already be set up appropriately.&nbsp; These steps
490       are provided for reference and updates.</p>
491     <h3>Set up Virtualbox guest additions for the VM</h3>
492     This procedure is needed if the guest provides an older or incompatible
493     version of the guest additions (which have already been installed on the
494     guest vm).&nbsp; It may also be necessary when a new version of the guest
495     additions becomes available.
496     <ol>
497       <li>To install the guest additions, open the guest VM and have its window
498         in focus.</li>
499       <li>Choose the "Devices" menu and select "Insert Guest Additions CD
500         Image".&nbsp; This will mount the CD's ISO image on the VM.</li>
501       <li>On the guest VM, it may be necessary to mount the CD image that's now
502         available:<br>
503         <pre># sudo mount /dev/sr0 /media/cdrom</pre>
504         <p>Linux will mention that the device is mounted "read-only".</p>
505       </li>
506       <li>Since the VM currently has no windowing system installed, one must
507         start the Guest Additions install manually:<br>
508         <pre># cd /media/cdrom<br># sudo sh VBoxLinuxAdditions.run</pre>
509       </li>
510       <li>The latest Virtualbox guest additions should now be installed.</li>
511     </ol>
512     <h3>Set up network adapters on guest VM</h3>
513     <p>The network interfaces should already be configured on the guest within
514       the Virtualbox configuration.&nbsp; This is available by clicking on the
515       VM in the Virtualbox manager and selecting "Settings".&nbsp; These are the
516       configuration settings used:</p>
517     Adapter 1:<br>
518     &nbsp; Attached to: Host-only Adapter<br>
519     &nbsp; Name: vboxnet0&nbsp; <br>
520     <p>Adapter 2:<br>
521       &nbsp; Attached to: Nat Network<br>
522       &nbsp; Name: NatNetwork</p>
523     <p>On the guest VM itself, the network settings are specified in a file
524       called /etc/network/interfaces.&nbsp; Here are the current contents of
525       that file:</p>
526     <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>
527     <pre>auto enp0s8</pre>
528     <pre>iface enp0s8 inet dhcp</pre>
529     <p> </p>
530     <h2>Notes on building the Cake Lamp VM</h2>
531     <p>This is all work that should already have been done.&nbsp; It is
532       mentioned here just as breadcrumbs for a future vm builder.</p>
533     <ul>
534       <li>Downloaded and installed Virtualbox for host computer (where the vm
535         image will be built).</li>
536       <li>Downloaded ubuntu server 16.04 iso.
537         (https://www.ubuntu.com/download/server)</li>
538       <li>Created a new vm in Virtualbox, telling it to start from the ubuntu
539         server iso.</li>
540       <li>Installed LAMP stack on guest VM.&nbsp; Some help here:
541         http://howtoubuntu.org/how-to-install-lamp-on-ubuntu</li>
542       <li>Configured CAKE on the guest VM.&nbsp; Useful link:
543         https://askubuntu.com/questions/628938/how-to-install-cakephp-in-ubuntu-14-04</li>
544       <li>Configured the two network adapters as needed (one for host-only
545         network and one for nat network).&nbsp; Here's some info about
546         Virtualbox networking with two adapters similar to our setup:
547 https://askubuntu.com/questions/293816/in-virtualbox-how-do-i-set-up-host-only-virtual-machines-that-can-access-the-in<br>
548       </li>
549       <li>Installed and configured Samba service for the guest VM.&nbsp; The
550         main config file lives in "/etc/samba/smb.conf".&nbsp; Some pointers
551         here:
552 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</li>
553     </ul>
554     <p><br>
555     </p>
556     <ul>
557     </ul>
558     <h6> </h6>
559     <p> </p>
560   </body>
561 </html>