tastier yet
[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</h2>
11     <h3 style="   text-align: center;"> Vintage: cakelampvm v002 &nbsp;&nbsp;
12       Updated: 2017-11-16</h3>
13     <p>The cakelampvm project provides a Virtualbox VM that acts as an "internet
14       in a bottle".&nbsp; The virtual machine provides DNS services (<a title="dns server"
15         href="http://www.bind9.net/">bind9</a>), a Web server (<a title="patchy"
16         href="https://httpd.apache.org/">Apache2</a>), a full <a title="ubuntu means compassion and humanity"
17         href="https://www.ubuntu.com/">Ubuntu</a> <a title="it's pronounced leenoox"
18         href="https://www.linuxfoundation.org/">Linux</a> desktop environment,
19       the <a title="flux is change" href="http://fluxbox.org/">Fluxbox</a> <a
20         title="a better windows" href="https://www.x.org/">X window manager</a>,
21       and a suite of tools called the <a title="feisty meow® concerns ltd. website"
22         href="https://feistymeow.org/">Feisty Meow® codebase</a> .&nbsp;
23       Together, these services provide you with a very flexible and powerful
24       testbed for web development, especially suited for <a title="it's cake" href="https://cakephp.org/">CakePHP</a>.</p>
25     <h2> Guest VM Configuration<a id="#config" name="#config"></a></h2>
26     <ul>
27       <li>hostname: <a title="the vm's website, when configured properly" href="https://cakelampvm.com/">cakelampvm.com</a></li>
28       <li>local IP address: 10.28.42.20</li>
29       <li>services: DNS (bind9), apache2, fluxbox X windowing system, <a title="not just in the garden"
30           href="https://www.gnome.org/">gnome display manager</a></li>
31       <li>main user: developer (password distributed separately)</li>
32       <li>mysql root password: (password distributed separately)</li>
33     </ul>
34     <h2>Powering up with the Feisty Meow® scripts<a id="#powerup" name="#powerup"></a></h2>
35     The feisty meow scripts are a cohesive bash scripting environment for
36     getting a variety of tasks done.&nbsp; The scripts recently incorporated the
37     "avbash" collection from Saco Designs and added those scripts to the
38     "site_avenger" collection of scripts.&nbsp; These provide tools for bringing
39     up CakePHP web sites and managing the collection of repositories for those
40     sites.&nbsp; Each website is considered an "application", and the
41     application name itself (e.g. "winterportlibrary") can often provide all the
42     details for "powering up" the site.&nbsp; The feisty meow team has added
43     additional scripts for managing DNS domains and Apache websites that provide
44     the capability to "stand up" an entire website around an application, with
45     accompanying domain.
46     <p>The site avenger scripts are documented separately within the feisty meow
47       codebase.&nbsp; Consult the <span style="text-decoration: underline;">f</span><a
48         title="quickstart" href="https://feistymeow.org/feisty_meow/readme.txt">eisty
49 meow
50         readme</a> file first, as it provides some valuable information on
51       configuring the codebase.&nbsp; The site avenger script documentation is
52       available in the <a title="useful commands" href="https://feistymeow.org/feisty_meow/documentation/feisty_meow_command_reference.txt">feisty
53         meow command reference</a> file.</p>
54     <p>(The feisty meow codebase is already configured for the developer account
55       on the cakelampvm virtual machine.)</p>
56     <h2>How to set up virtualbox for your host PC<a id="#virtualbox-setup" name="#virtualbox-setup"></a></h2>
57     <ol>
58       <li>Download and install virtualbox:
59         https://www.virtualbox.org/wiki/Downloads</li>
60       <li>Install the extension pack for virtualbox: This provides USB drivers
61         and other features.&nbsp; This is installed on virtualbox itself, not on
62         the guests.</li>
63       <ol>
64         <li>Download the extension pack at
65           https://www.virtualbox.org/wiki/Downloads</li>
66         <li>Stop any running virtualbox vms.</li>
67         <li>Close virtualbox control panel.</li>
68         <li>Double-click on the downloaded extensions package (in a file
69           explorer) and virtualbox should install it.</li>
70       </ol>
71       <li>Run the virtualbox control panel.</li>
72       <li>Download the cakelampvm guest vm package and unzip it.&nbsp; Store the
73         unzipped version in some appropriate place where you want the virtual
74         machine to reside on your host's hard drive.</li>
75       <li>Add the guest VM to your list of VMs.&nbsp; From the virtualbox menus,
76         choose the "Machine" menu and select "Add".&nbsp; Point the selector
77         dialog at the cakelampvm folder you created above and open the
78         cakelampvm.vbox file.</li>
79       <li>Now the cakelampvm should show up in the list of virtual
80         machines.&nbsp; Before starting it, perform the following network
81         configuration sections.</li>
82     </ol>
83     <h3>Configure the Host-Only network on virtualbox<a id="#host-only" name="#host-only"></a></h3>
84     <p>Configuring host-only networking for the VM makes the VM completely local
85       to your machine.&nbsp; The cakelampvm will not be accessible on the
86       internet or from the LAN, and can only be accessed by your host PC.</p>
87     <p>Note: If the host-only or NAT network exist ahead of time, virtualbox may
88       complain about them even if they have the correct configuration.&nbsp;
89       This can be corrected simply by opening the VM settings and selecting the
90       appropriate network names again.</p>
91     <p>To configure the host-only network, follow these steps:</p>
92     <ol>
93       <li> Go to virtual box "Preferences" (global preferences, not for a
94         specific vm).</li>
95       <li> Click on the "Network" tab.</li>
96       <li> Choose the "Host-only Networks" tab from within "Network".</li>
97       <li> Click the plus icon to add a new host-only network, or if there is
98         already a Host-only network, then edit it.</li>
99       <li>Set the "Adapter" parameters:<br>
100         IPv4 Address: 10.28.42.1<br>
101         IPv4 Network Mask: 255.255.255.0<br>
102         IPv6 Address: (leave blank)<br>
103         IPv6 Prefix Length: 0<br>
104         Virtualbox will fill in the other details like so:<br>
105         <p><img alt="host only network adapter" src="images/host_only_network_adapter.png"></p>
106       </li>
107       <li>Set the "DHCP Server Settings" to disabled, e.g.<br>
108         <img alt="host only dhcp" src="images/host_only_adapter_dhcp_server.png"><br>
109         This is disabled because we will be using statically assigned addresses
110         for convenience and stability.</li>
111     </ol>
112     <p>Additional information on host-only (and other) network adapter types is
113       at: https://www.virtualbox.org/manual/ch06.html#network_nat_service</p>
114     <h3>Configure the NAT Network on virtualbox<a id="#nat-network" name="#nat-network"></a></h3>
115     <p>The NAT (Network Address Translation) network allows the VM to get off of
116       the machine and onto the internet safely.&nbsp; It will use this interface
117       for any communication off of the host machine.&nbsp; Since the real IP
118       address of the VM is hidden behind the NAT firewall on Virtualbox, this
119       keeps the VM safe from attackers, and hence your machine stays safe as
120       well.</p>
121     <p>To set up the NAT network, follow these steps:</p>
122     <ol>
123       <li> Go to virtual box "Preferences" (global preferences, not for a
124         specific vm).</li>
125       <li> Click on the "Network" tab.</li>
126       <li> Choose the "Nat Networks" tab from within "Network".</li>
127       <li> Click the plus icon to add a new host-only network.</li>
128       <li>Set the "NAT Network Details" parameters:<br>
129         Network Name: NatNetwork<br>
130         Network CIDR: 10.0.2.0/24<br>
131         Supports DHCP: checked<br>
132         Supports IPv6: optionally checked<br>
133         These are my settings, with IPv6 left disabled:<br>
134         <img alt="nat net config" src="images/nat_network_config.png"></li>
135     </ol>
136     <h2>Start up the VM<a id="#start-vm" name="#start-vm"></a></h2>
137     <p>Using the virtualbox interface, you should now be able to start your
138       virtual machine.&nbsp; Virtualbox will complain if it detects any
139       remaining configuration problems in the VM, but it should start
140       normally.&nbsp; The Linux boot sequence will show many lines of text,
141       before bringing up a black console window with a login dialog.</p>
142     <p>You can log in directly on the VM console with the developer account, but
143       it is generally more useful to connect to the cakelampvm over ssh.&nbsp;
144       If the networking has been established properly, you should be able to do
145       this with:</p>
146     <pre>ssh developer@cakelampvm.com&nbsp; (or equivalent with your ssh client)</pre>
147     <p>And then provide the password to log in.</p>
148     <p>If a feature called "X forwarding" is enabled in your ssh client, then
149       you can start graphical applications on the VM and display them on your
150       local machine.&nbsp; This works right away on most Linux hosts, but can
151       also work on PCs with X window system installed.&nbsp; The section below
152       describes how to set up Cygwin to run X server, which enable X forwarding
153       to your local display.</p>
154     <p>...{insert that info}...</p>
155     <h2>Using the guest VM's DNS services<a id="#dns-from-vm" name="#dns-from-vm"></a></h2>
156     <p>The cakelampvm has been set up to provide a DNS server which will answer
157       name lookup requests on any of the sites that the cakelampvm is hosting
158       for you.&nbsp; It will also serve as a general DNS server for any other
159       domains that need to be looked up.</p>
160     <p>To use the cakelampvm DNS, modify your host operating system network
161       configuration by adding or changing the DNS server to use the guest VM's
162       DNS service.&nbsp; The cakelampvm is available at the local IP address
163       10.28.42.20.&nbsp; (The DNS server can be tested with nslookup, dig and
164       other tools.)</p>
165     <p>Note that the cakelampvm DNS should be listed first, if one intends to
166       override any DNS names that actually exist out on the internet.&nbsp; We
167       have also found it most effective to have only the cakelampvm as your DNS
168       server, because a secondary DNS server can "take over" providing the name
169       lookups, and thus foul up DNS requests that should succeed for your
170       VM-hosted sites.</p>
171     <p>It is important to remember to switch back to a normal DNS server
172       configuration when you shut off the cakelampvm, or your machine will not
173       know the names of any sites on the internet any more!</p>
174     <p>Once the DNS server is properly set up, these ping commands should get
175       answering responses (from 10.28.42.20):</p>
176     <pre>ping cakelampvm.com</pre>
177     <pre>ping defaultcake.cakelampvm.com</pre>
178     <pre>ping mapsdemo.cakelampvm.com</pre>
179     <h3>Setting up DNS on Windows<a id="#windoze-dns" name="#windoze-dns"></a></h3>
180     <p>The ipconfig tool will provide helpful information about your current
181       networking and DNS configuration:</p>
182     <pre>ipconfig --all</pre>
183     <p>The DNS configuration on Windows is somewhat byzantine.&nbsp; The pipe
184       characters ('|') below are used to separate the menus or tabs or dialogs
185       to traverse.&nbsp; Follow this path to get to the DNS config:</p>
186     <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>
187     <p><br>
188     </p>
189     <p>{fill in rest}<br>
190     </p>
191     <p><br>
192     </p>
193     <h2>Editing files on the guest VM from the host<a id="#editing-files-on-vm"
194         name="#editing-files-on-vm"></a></h2>
195     <p>On the host computer, look for the guest vm as a networked computer
196       called cakelampvm.&nbsp; This should provide some network shares using
197       Microsoft SMB protocol, and they can be attached to using the "developer"
198       user and its password.</p>
199     <p>On windows, one may want to mount this network location as a drive letter
200       for easier access.</p>
201     <p>Currently, the root of all web servers is exposed as "www".&nbsp; Editing
202       the files in those folders requires ownership by the developer user.&nbsp;
203       Currently the defaultcake server is owned by developer.</p>
204     <p>One should be able to create a new directory in the www folder owned by
205       the developer user over the network also, which can be used for creating
206       new projects.&nbsp; However, there is a config issue in the current vm
207       (v001) about this; to fix, run this command on the guest vm as the
208       developer user:</p>
209     <pre>sudo chmod g+w /var/www</pre>
210     <p>Afterwards, the www folder should allow the developer user to create new
211       folders at will.</p>
212     <h2>Accessing files on the host PC from the guest VM<a id="#samba-shares" name="#samba-shares"></a></h2>
213     <p>If you want to share a folder from the host to the guest, perhaps for
214       driver updates or other conveniences, then make the share with these
215       steps:</p>
216     <ol>
217       <li>Create a folder on the host that is to be shared.</li>
218       <li>Right-click on the vm in virtualbox manager and choose "Settings".</li>
219       <li>In the "Shared Folders" tab of the settings, go to "Machine Folders".</li>
220       <li>Click the folder plus icon to create a new share.</li>
221       <li>Fill in the "Folder Path" on the host PC to the folder that will be
222         shared, and give it a name for the guest.&nbsp; We assume the folder
223         name will be "myshare".</li>
224       <li>On the guest vm, run the following commands to mount the share:<br>
225         <pre>mkdir ~/shared&nbsp;&nbsp;&nbsp; # for the guest's version of the shared folder</pre>
226         <pre>sudo mount -t vboxsf myshare ~/shared&nbsp;&nbsp;&nbsp; # mount the vm's share name onto the folder on the vm.</pre>
227       </li>
228     </ol>
229     <h2>Adding a new website and domain on the guest VM</h2>
230     <p>Note: these instructions, even the quick approaches below, pale in
231       comparison to the ease of use of the "standup" command in feisty meow's
232       site avenger scripts.&nbsp; The standup command is detailed in the&nbsp;<a
233         title="useful commands" href="https://feistymeow.org/feisty_meow/documentation/feisty_meow_command_reference.txt">feisty
234         meow command reference</a> document.&nbsp; These instructions are for
235       situations when the domain or site is idiosyncratic in some way that
236       standup doesn't support.</p>
237     <p>To add a new website, you will first need to pick one of the DNS options
238       below (A or B) depending on how you want to name the site.&nbsp; If the
239       DNS name of the site is contained within another existing domain (e.g.,
240       "A.B.C" has subdomain A contained in domain B.C), use Option A.&nbsp; If
241       the DNS name is a so-called "Second Level Domain" (SLD), then it stands on
242       its own (e.g., "B.C" is an SLD).</p>
243     <p>Once the DNS option has been picked and implemented, continue to the next
244       section of "Creating a New Apache Site".</p>
245     <h3>DNS Option A: Adding a sub-domain in an existing domain</h3>
246     <p>Let us say a customer needs an application called "excalibur".&nbsp; It
247       will be a new subdomain within an existing domain, such as the
248       "cakelampvm.com" domain, meaning we want the VM to start answering
249       requests for "excalibur.cakelampvm.com".</p>
250     Note that this option requires the containing domain "cakelampvm.com" to
251     already exist before adding the subdomain; see DNS Option B below for
252     details on how to add a containing domain for the first time.
253     <h4>Quick approach: Use the feisty meow "add_domain" command.</h4>
254     <p> Connect to the cakelampvm via ssh as the developer user, e.g.: ssh
255       developer@cakelampvm.com </p>
256     <p>Run this command in a bash shell on the VM:</p>
257     <pre># add_domain excalibur.cakelampvm.com</pre>
258     <p>Done.</p>
259     <h4>Manual approach: Edit the bind9 configuration.</h4>
260     <p>Note: the manual approach is not compatible with later use of feisty
261       meow's "remove_domain".</p>
262     Connect to the cakelampvm via ssh as the developer user, e.g.: ssh
263     developer@cakelampvm.com
264     <p>Execute the following command to edit the DNS file for the cakelampvm
265       domain:</p>
266     <pre># sudo vi /etc/bind/cakelampvm.com.conf</pre>
267     <p>Add a stanza for the new site at the end of this file:</p>
268     <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>
269     <p>Restart the DNS server:</p>
270     <pre># sudo service bind9 restart</pre>
271     <p>Afterwards, pinging excalibur.cakelampvm.com should work from both the
272       guest VM and the host PC.</p>
273     <h3>DNS Option B: Using an entirely new domain for the site</h3>
274     <p>This is a similar procedure to Option A, but we will create a totally new
275       config file for the new domain and add it to the bind directory.&nbsp; For
276       this example, we need to add the site "excalibur.tv" into the DNS.</p>
277     <h4>Quick approach: Use the feisty meow "add_domain" command.</h4>
278     <p> Connect to the cakelampvm via ssh as the developer user, e.g.: ssh
279       developer@cakelampvm.com </p>
280     <p>Run this command in a bash shell on the VM:</p>
281     <pre># add_domain excalibur.tv</pre>
282     <p>Done.</p>
283     <h4>Manual approach: Edit a new DNS config file</h4>
284     <p>Create a file called /etc/bind/excalibur.tv.conf for our new domain
285       excalibur.tv with these contents:</p>
286     <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># main domain for machine.<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>
287     The gnarly prefix stuff above the "excalibur.tv." listing establishes
288     configuration info for the new domain.&nbsp; This file relies on the
289     existing cakelampvm.com infrastructure in DNS, such as the "ns" host, which
290     is the domain's name server.&nbsp; However, the new domain does <span style="text-decoration: underline;">not</span>
291     live inside the cakelampvm.com domain.<br>
292     <p>Now that the config file is in place, edit "named.conf.local" to add the
293       new file by adding this bit of configuration at the end:</p>
294     <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>
295     <p>Restart the DNS server:</p>
296     <pre># sudo service bind9 restart</pre>
297     <p>Afterwards, pinging excalibur.tv should work from both the guest and the
298       host.</p>
299     <h3>Creating a New Apache site</h3>
300     <p>Start with the following template file for the new website, and modify it
301       for the appropriate host name:</p>
302     <pre>&lt;VirtualHost *:80&gt;<br>&nbsp;&nbsp;&nbsp; ServerName greatsite.cakelampvm.com<br>&nbsp;&nbsp;&nbsp; ServerAlias greatsite.cakelampvm.com *.greatsite.cakelampvm.com<br>&nbsp;&nbsp;&nbsp; DocumentRoot /var/www/greatsite<br>&nbsp;&nbsp;&nbsp; ErrorLog ${APACHE_LOG_DIR}/greatsite.cakelampvm.com-error.log<br>&nbsp;&nbsp;&nbsp; CustomLog ${APACHE_LOG_DIR}/greatsite.cakelampvm.com-access.log combined<br>&nbsp;&nbsp;&nbsp; Alias /statistics "/var/www/webwork.repository/webwork/maps_demo/webroot/statistics"<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>
303     <p>The above example is pre-modified for DNS Option A above, the
304       greatsite.cakelampvm.com name.&nbsp; Switching all of those to
305       "greatsite.tv" instead would support DNS option B.</p>
306     <p>Copy that file into /etc/apache/available-sites under an appropriate
307       name, which here we will call "greatsite.conf".</p>
308     <p>Tell apache to use the new file:</p>
309     <pre>a2ensite greatsite.conf</pre>
310     <p>Finally, restart apache to get it to begin serving the site:</p>
311     <pre>sudo service apache2 restart</pre>
312     <h3>Test the new web site</h3>
313     <p>Given the configuration above, your host PC should now be able to access
314       the new website.</p>
315     <p>To test this, first try pinging the hostname, e.g.: ping
316       greatsite.cakelampvm.com or ping greatsite.tv</p>
317     <p>Then, if there are responses to the ping, it means the DNS is
318       working.&nbsp; If there are no responses, check the instructions in the
319       above DNS option section.</p>
320     <p>Once the DNS is working, one can try browsing to the site at:
321       http://greatsite.cakelampvm.com or http://greatsite.tv (depending on the
322       DNS option chosen).</p>
323     <p>If the site is not showing up properly, try examining the apache logs for
324       error messages that can be corrected.&nbsp; The log files are stored in
325       /var/log/apache2 and are generally named after the website.</p>
326     <h2>Configuring the guest VM</h2>
327     <p>The guest VM should already be set up appropriately.&nbsp; These steps
328       are provided for reference and updates.</p>
329     <h3>Set up virtualbox guest additions for the VM</h3>
330     <p>** note for v001 of cakelampvm: the below steps are still needed on the
331       shipped image.</p>
332     <p>This procedure is needed if the guest provides an older or incompatible
333       version of the guest additions (which have already been installed on the
334       guest vm).&nbsp; It may also be necessary when a new version of the guest
335       additions becomes available.</p>
336     <ol>
337       <li>To install the guest additions, open the guest VM and have its window
338         in focus.</li>
339       <li>Choose the "Devices" menu and select "Insert Guest Additions CD
340         Image".&nbsp; This will mount the CD's ISO image on the VM.</li>
341       <li>On the guest VM, it may be necessary to mount the CD image that's now
342         available:<br>
343         sudo mount /dev/sr0 /media/cdrom</li>
344       <li>Since the VM currently has no windowing system installed, one must
345         start the Guest Additions install manually:<br>
346         cd /media/cdrom<br>
347         sudo sh VBoxLinuxAdditions.run</li>
348       <li>This should install the guest additions.</li>
349     </ol>
350     <h3>Set up network adapters on guest VM</h3>
351     <p>The network interfaces should already be configured on the guest within
352       the virtualbox configuration.&nbsp; This is available by clicking on the
353       VM in the virtualbox manager and selecting "Settings".&nbsp; These are the
354       configuration settings used:</p>
355     Adapter 1:<br>
356     &nbsp; Attached to: Host-only Adapter<br>
357     &nbsp; Name: vboxnet0&nbsp; <br>
358     <p>Adapter 2:<br>
359       &nbsp; Attached to: Nat Network<br>
360       &nbsp; Name: NatNetwork</p>
361     <p>On the guest VM itself, the network settings are specified in a file
362       called /etc/network/interfaces.&nbsp; Here are the current contents of
363       that file:</p>
364     <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>
365     <pre>auto enp0s8</pre>
366     <pre>iface enp0s8 inet dhcp</pre>
367     <p> </p>
368     <h2>Handy Techniques</h2>
369     <h3>Assorted Guides and Cheat-Sheets</h3>
370     <p>Cheat sheet for Vim: <a title="vim commands" href="https://vim.rtorr.com/">https://vim.rtorr.com/</a></p>
371     <p>Git branching model that seems to work well: <a title="release and patch process"
372         href="http://nvie.com/posts/a-successful-git-branching-model/">http://nvie.com/posts/a-successful-git-branching-model/</a></p>
373     <p><br>
374     </p>
375     <h3>Get the network address on the guest vm</h3>
376     <p>Run this command: ifconfig</p>
377     <p>In the results, look for "inet addr".&nbsp; There may be more than one,
378       if there are multiple network interfaces.</p>
379     <h3>How to cleanly reboot or shut down the guest VM</h3>
380     <p>When you've got the DNS and everything integrated, these commands will
381       manage the vm's state:</p>
382     <p>First, log into the guest VM: ssh developer@cakelampvm.com</p>
383     <p>Then, reboot the guest VM: sudo reboot</p>
384     <p>Or, halt the guest VM: sudo shutdown -h now</p>
385     <p>Using these commands is better than just cycling the power from the
386       virtualbox control panel.</p>
387     <h2>Notes on building the Cake Lamp VM</h2>
388     <p>This is all work that should already have been done.&nbsp; It is
389       mentioned here just as breadcrumbs for a future vm builder.</p>
390     <ul>
391       <li>Downloaded and installed virtualbox for host computer (where the vm
392         image will be built).</li>
393       <li>Downloaded ubuntu server 16.04 iso.
394         (https://www.ubuntu.com/download/server)</li>
395       <li>Created a new vm in virtualbox, telling it to start from the ubuntu
396         server iso.</li>
397       <li>Installed LAMP stack on guest VM.&nbsp; Some help here:
398         http://howtoubuntu.org/how-to-install-lamp-on-ubuntu</li>
399       <li>Configured CAKE on the guest VM.&nbsp; Useful link:
400         https://askubuntu.com/questions/628938/how-to-install-cakephp-in-ubuntu-14-04</li>
401       <li>Configured the two network adapters as needed (one for host-only
402         network and one for nat network).&nbsp; Here's some info about
403         virtualbox networking with two adapters similar to our setup:
404 https://askubuntu.com/questions/293816/in-virtualbox-how-do-i-set-up-host-only-virtual-machines-that-can-access-the-in<br>
405       </li>
406       <li>Installed and configured Samba service for the guest VM.&nbsp; The
407         main config file lives in "/etc/samba/smb.conf".&nbsp; Some pointers
408         here:
409 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>
410     </ul>
411     <p><span style="font-style: italic;"><br>
412       </span></p>
413     <p><span style="font-style: italic;"><br>
414       </span></p>
415     <p><span style="font-style: italic;"><br>
416       </span></p>
417     <p><span style="font-style: italic;">remaining work:</span></p>
418     <p>todo: arrange gritty details to back.</p>
419     <p>todo: toc goes after intro paragraph.</p>
420     <p><br>
421     </p>
422     <h6> </h6>
423     <h2><span style="text-decoration: underline;"><br>
424       </span></h2>
425     <p> </p>
426   </body>
427 </html>