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