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