1b2f9b542a5cf2436c1c133cb454ed9373f9f415
[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     <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 running
33       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, not on
74         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 virtualbox control panel.</li>
80         <li>Double-click on the downloaded extensions package (in a file
81           explorer) and virtualbox should 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 result,
157       edit the Windows firewall settings and allow Virtualbox to use both
158       "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 (without the initial '#'
181       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>Using the guest VM's DNS services<a id="#dns-from-vm" name="#dns-from-vm"></a></h2>
193     <p>The cakelampvm has been set up to provide a DNS server which will answer
194       name lookup requests on any of the sites that the cakelampvm is hosting
195       for you.&nbsp; It will also serve as a general DNS server for any other
196       domains that need to be looked up.</p>
197     <p>To use the cakelampvm DNS, modify your host operating system network
198       configuration by adding or changing the DNS server to use the guest VM's
199       DNS service.&nbsp; The cakelampvm is available at the local IP address
200       10.28.42.20.&nbsp; (The DNS server can be tested with nslookup, dig and
201       other tools.)</p>
202     <p>Note that the cakelampvm DNS should be listed first, if one intends to
203       override any DNS names that actually exist out on the internet.&nbsp; We
204       have also found it most effective to have only the cakelampvm as your DNS
205       server, because a secondary DNS server can "take over" providing the name
206       lookups, and thus foul up DNS requests that should succeed for your
207       VM-hosted sites.</p>
208     <p>If your Host PC is running Windows, see the DNS configuration section
209       below that is tailored to that operating system.</p>
210     <p>Important Note: It behooves you to remember to switch back to a normal
211       DNS server configuration when you shut off the cakelampvm, or your machine
212       will not know the names of any sites on the internet any more!</p>
213     <p>Once the DNS server is properly set up (by whatever means necessary),
214       these ping commands should get answering responses (from 10.28.42.20) on
215       both the cakelampvm VM and on your host PC.&nbsp; Note: ping on Linux
216       keeps going forever, so hit control-C when you are tired of seeing the pings:</p>
217     <pre># ping cakelampvm.com</pre>
218     <pre># ping mapsdemo.cakelampvm.com</pre>
219     <p>Note that any other answer than 10.28.42.20 for the address is *bzzzt*
220       wrong, and means something needs to be fixed.</p>
221     <p>If these pings succeed (which hopefully they will!), then try accessing
222       the websites of each domain:</p>
223     <pre>(browse to) http://cakelampvm.com</pre>
224     <pre>(browse to) http://mapsdemo.cakelampvm.com</pre>
225     <p>These should show local sites on the VM rather than sites on the
226       internet.&nbsp; If you instead get failures to find the domains, or if the
227       "real internet" site comes up for cakelampvm.com (the page covered with
228       red X marks and complaining), then the DNS is not hooked up properly yet.</p>
229     <h4>Troubleshooting the DNS</h4>
230     <p>If your pings are getting the wrong answers and you're certain the DNS
231       settings on your Host PC are right, then you may need to flush your DNS
232       cache, and that might be sufficient.&nbsp; On Windows, the command for
233       flushing DNS is:</p>
234     <pre>&gt; ipconfig /flushdns</pre>
235     <p>and on Linux the flush DNS command can be many different things, but try
236       these two most common options:</p>
237     <pre># sudo service dns-clean restart&nbsp;&nbsp; # restarts the client side DNS cache.</pre>
238     <p>or</p>
239     <pre># sudo service nscd restart&nbsp;&nbsp; # restarts the nscd caching server.</pre>
240     After, this try the pings again.&nbsp; If they still fail, please go back
241     over your DNS configuration very carefully.&nbsp; The cakelampvm's DNS
242     feature *does* actually work, but operating systems sometimes do their best
243     to deny this.<br>
244     <h4>Troubleshooting the Apache Sites</h4>
245     <p>If your DNS pings and lookups are functioning properly, but you're just
246       not getting the right websites, then try clearing your browser's cache and
247       shutting the browser application down.&nbsp; Then, start the browser up
248       and try the address again.&nbsp; Often this cache dumping is enough to fix
249       the browser so that you start seeing the local website versions on
250       cakelampvm.com.</p>
251     <h3>Setting up DNS on Windows<a id="#windoze-dns" name="#windoze-dns"></a></h3>
252     <p>The ipconfig tool will provide helpful information about your current
253       networking and DNS configuration:</p>
254     <pre>ipconfig --all</pre>
255     <p>The DNS configuration on Windows is somewhat byzantine.&nbsp; The pipe
256       characters ('|') below are used to separate the menus or tabs or dialogs
257       to traverse.&nbsp; Follow this path to get to the DNS config:</p>
258     <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>
259     <p><br>
260     </p>
261     <p>{fill in rest}<br>
262     </p>
263     <p><br>
264     </p>
265     <h2>Editing files on the guest VM from the host<a id="#editing-files-on-vm"
266         name="#editing-files-on-vm"></a></h2>
267     <p>On the host computer, look for the guest vm as a networked computer
268       called cakelampvm.&nbsp; This should provide some network shares using
269       Microsoft SMB protocol, and they can be attached to using the "developer"
270       user and its password.</p>
271     <p>On windows, one may want to mount this network location as a drive letter
272       for easier access.</p>
273     <p>Currently, the root of all web servers is exposed as "www".&nbsp; Editing
274       the files in those folders requires ownership by the developer user.&nbsp;
275       The existing mapsdemo site is owned by a different user ("fred") rather
276       than developer, mostly as a test case.&nbsp; The "fred", "developer", and
277       "www-data" accounts on the VM have all been put into each others Unix
278       "groups" so that they can access each other's files, and thus you may not
279       notice any issues editing fred's files.</p>
280     <p>One should be able to create a new directory over the network also.&nbsp;
281       Try creating a junk folder in the "www" folder, and then deleting it
282       again.&nbsp; That should succeed, and this approach can be used to create
283       folders (from the Host PC) that are owned by the developer user (on the
284       VM).&nbsp; You should be able to create folders or copy files within the
285       developer's home folder also ("/home/developer").</p>
286     <p>If you run into any permission problems that prevent file access, either
287       remotely or within the VM itself, then try running this command to fix
288       them:</p>
289     <pre># revamp_cakelampvm</pre>
290     <p>Afterwards, the www folder and others should allow the developer user to
291       create new folders at will.</p>
292     <p>The revamp command above is also used to deliver new configuration to the
293       VM from the feisty meow script environment; running it after any update of
294       the feisty meow codebase is a good idea.</p>
295     <h2>Accessing files on the host PC from the guest VM<a id="#samba-shares" name="#samba-shares"></a></h2>
296     <p>If you want to share a folder from the host to the guest, perhaps for
297       driver updates or other conveniences, then make the share with these
298       steps:</p>
299     <ol>
300       <li>Create a folder on the host that is to be shared.</li>
301       <li>Right-click on the vm in virtualbox manager and choose "Settings".</li>
302       <li>In the "Shared Folders" tab of the settings, go to "Machine Folders".</li>
303       <li>Click the folder plus icon to create a new share.</li>
304       <li>Fill in the "Folder Path" on the host PC to the folder that will be
305         shared, and give it a name for the guest.&nbsp; We assume the folder
306         name will be "myshare".</li>
307       <li>On the guest vm, run the following commands to mount the share:<br>
308         <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>
309       </li>
310     </ol>
311     <h2>Adding a new website and domain on the guest VM</h2>
312     <p>Note: these instructions, even the quick approaches below, pale in
313       comparison to the ease of use of the "standup" command in feisty meow's
314       site avenger scripts.&nbsp; The standup command is detailed in the&nbsp;<a
315         title="useful commands" href="https://feistymeow.org/feisty_meow/documentation/feisty_meow_command_reference.txt">feisty
316         meow command reference</a> document.&nbsp; These instructions are for
317       situations when the domain or site is idiosyncratic in some way that
318       standup doesn't support.</p>
319     <p>To add a new website, you will first need to pick one of the DNS options
320       below (A or B) depending on how you want to name the site.&nbsp; If the
321       DNS name of the site is contained within another existing domain (e.g.,
322       "A.B.C" has subdomain A contained in domain B.C), use Option A.&nbsp; If
323       the DNS name is a so-called "Second Level Domain" (SLD), then it stands on
324       its own (e.g., "B.C" is an SLD).</p>
325     <p>Once the DNS option has been picked and implemented, continue to the next
326       section of "Creating a New Apache Site".</p>
327     <p>For either Option A or Option B, first connect to the cakelampvm via ssh
328       as the developer user, e.g.: ssh developer@cakelampvm.com </p>
329     <h3>DNS Option A: Adding a sub-domain in an existing domain</h3>
330     <p>Let us say a customer needs an application called "excalibur".&nbsp; It
331       will be a new subdomain within an existing domain, such as the
332       "cakelampvm.com" domain, meaning we want the VM to start answering
333       requests for "excalibur.cakelampvm.com".</p>
334     Note that this option requires the containing domain "cakelampvm.com" to
335     already exist before adding the subdomain; see DNS Option B below for
336     details on how to add a containing domain for the first time.
337     <h4>Quick approach: Use the feisty meow "add_domain" command.</h4>
338     <p>Run this command in a bash shell on the VM:</p>
339     <pre># add_domain excalibur.cakelampvm.com</pre>
340     <p>Done.</p>
341     <h4>Manual approach: Edit the bind9 configuration.</h4>
342     <p>Note: the manual approach is not compatible with later use of feisty
343       meow's "remove_domain".</p>
344     Execute the following command to edit the DNS file for the cakelampvm
345     domain:
346     <pre># sudo vi /etc/bind/cakelampvm.com.conf</pre>
347     <p>Add a stanza for the new site at the end of this file:</p>
348     <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>
349     <p>Restart the DNS server:</p>
350     <pre># sudo service bind9 restart</pre>
351     <p>Afterwards, pinging excalibur.cakelampvm.com should work from both the
352       guest VM and the host PC.</p>
353     <h3>DNS Option B: Using an entirely new domain for the site</h3>
354     <p>This is a similar procedure to Option A, but we will create a totally new
355       config file for the new domain and add it to the bind directory.&nbsp; For
356       this example, we need to add the site "excalibur.tv" into the DNS.</p>
357     <h4>Quick approach: Use the feisty meow "add_domain" command.</h4>
358     Run this command in a bash shell on the VM:
359     <pre># add_domain excalibur.tv</pre>
360     <p>Done.</p>
361     <h4>Manual approach: Edit a new DNS config file</h4>
362     <p>Note: the manual approach is not compatible with later use of feisty
363       meow's "remove_domain".</p>
364     Create a file called /etc/bind/excalibur.tv.conf for our new domain
365     excalibur.tv with these contents:
366     <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>
367     The gnarly prefix stuff above the "excalibur.tv." listing establishes
368     configuration info for the new domain.&nbsp; This file relies on the
369     existing cakelampvm.com infrastructure in DNS, such as the "ns" host, which
370     is the domain's name server.&nbsp; However, the new domain does <span style="text-decoration: underline;">not</span>
371     live inside the cakelampvm.com domain.<br>
372     <p>Now that the config file is in place, edit "/etc/bind/named.conf.local"
373       to add the new file by adding this bit of configuration at the end:</p>
374     <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>
375     <p>Restart the DNS server:</p>
376     <pre># sudo service bind9 restart</pre>
377     <p>Afterwards, pinging excalibur.tv should work from both the guest and the
378       host.</p>
379     <h3>Creating a New Apache site</h3>
380     <p>First, connect to the cakelampvm via ssh as the developer user, e.g.: ssh
381       developer@cakelampvm.com </p>
382     <h4>Quick approach: Use the feisty meow "add_apache_site" command.</h4>
383     <p>Run this command in a bash shell on the VM:</p>
384     <pre># add_apache_site excalibur excalibur.tv</pre>
385     <p>(The first parameter is the application name, the second is the domain
386       name.)</p>
387     <p>Done.</p>
388     <h4>Manual approach: Edit an Apache config file</h4>
389     <p>Note: the manual approach is not compatible with later use of feisty
390       meow's "remove_apache_site".</p>
391     <p>For Apache, the choice of DNS Option A or B, subdomain or SLD does not
392       matter.&nbsp; The site configuration file just has to accurately specify
393       the domain in question.</p>
394     <p>Start with the following template file for the new website, and modify it
395       for the appropriate host name:</p>
396     <pre>&lt;VirtualHost *:80&gt;<br>&nbsp;&nbsp;&nbsp; ServerName excalibur.tv
397 &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>
398     <p>The above example is appropriate for our excalibur app in the
399       excalibur.tv domain (using DNS Option B).&nbsp; Modifying the excalibur.tv
400       references in it is sufficient to retarget it for any domain you want.</p>
401     <p>Copy the new site config file into "/etc/apache2/sites-available" with an
402       appropriate file name that includes the site's domain name.&nbsp; We will
403       call our config file "excalibur.tv.conf".&nbsp; If you developed the file
404       in your home folder, this would be the command to move it up to Apache:</p>
405     <pre># sudo cp ~/excalibur.tv.conf /etc/apache2/sites-available</pre>
406     <p>Then tell apache to use the new file:</p>
407     <pre># sudo a2ensite excalibur.tv  # the '.conf' portion of the filename is unnecessary for this command.
408 </pre>
409     <p>Finally, restart apache to get it to begin serving the site:</p>
410     <pre># sudo service apache2 restart</pre>
411     <h3>Test the new web site</h3>
412     <p>Given the configuration above, your host PC should now be able to access
413       the new website on the domain "excalibur.tv".</p>
414     <p>To test this, first try pinging the new DNS name:</p>
415     <pre># ping excalibur.tv</pre>
416     <p>If there are responses to the ping *and* the answer is 10.28.42.20, then
417       it means the DNS is working.&nbsp; If there are no responses or it's some
418       other IP address talking back, check the instructions in the above DNS
419       sections.</p>
420     <p>Once the DNS is working, try browsing to the site at "http://excalibur.tv".&nbsp;
421       That should at least bring up the configured site storage path, even if
422       nothing is being served from that folder yet.</p>
423     <p>If the new site is not showing up properly, try examining the apache logs
424       for error messages that can be corrected.&nbsp; The log files are stored
425       in "/var/log/apache2" and are named after the website (if configured as
426       shown above).</p>
427     <h2>Handy Techniques</h2>
428     <h3>Assorted Guides and Cheat-Sheets</h3>
429     <p>Cheat sheet for Vim: <a title="vim commands" href="https://vim.rtorr.com/">https://vim.rtorr.com/</a></p>
430     <p>Git branching model that seems to work well: <a title="release and patch process"
431         href="http://nvie.com/posts/a-successful-git-branching-model/">http://nvie.com/posts/a-successful-git-branching-model/</a></p>
432     <h3>Get the network address on the guest vm</h3>
433     <p>Run this command: ifconfig</p>
434     <p>In the results, look for "inet addr".&nbsp; There may be more than one,
435       if there are multiple network interfaces.</p>
436     <h3>How to cleanly reboot or shut down the guest VM</h3>
437     <p>When you've got the DNS and everything integrated, these commands will
438       manage the vm's state:</p>
439     <p>First, log into the guest VM: ssh developer@cakelampvm.com</p>
440     <p>Then, reboot the guest VM: sudo reboot</p>
441     <p>Or, halt the guest VM: sudo shutdown -h now</p>
442     <p>Using these commands is better than just cycling the power from the
443       virtualbox control panel.</p>
444     <p><br>
445     </p>
446     <p><br>
447     </p>
448     <p><br>
449     </p>
450     <h1>Gritty Details</h1>
451     <p>This is the lowest level of plumbing for your VM.&nbsp; Hopefully you
452       will not need to engage with this section.&nbsp; The most useful area here
453       is the one below about the "virtualbox guest additions", which you will
454       probably need at some future point.&nbsp; Oracle releases updates to the
455       guest additions fairly regularly.</p>
456     <h2>Configuring the guest VM</h2>
457     <p>The guest VM should already be set up appropriately.&nbsp; 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).&nbsp; It may also be necessary when a new version of the guest
463     additions becomes available.
464     <ol>
465       <li>To install the guest additions, open the guest VM and have its window
466         in focus.</li>
467       <li>Choose the "Devices" menu and select "Insert Guest Additions CD
468         Image".&nbsp; 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
470         available:<br>
471         <pre># sudo mount /dev/sr0 /media/cdrom</pre>
472       </li>
473       <li>Since the VM currently has no windowing system installed, one must
474         start the Guest Additions install manually:<br>
475         <pre># cd /media/cdrom<br># sudo sh VBoxLinuxAdditions.run</pre>
476       </li>
477       <li>This should install the guest additions.</li>
478     </ol>
479     <h3>Set up network adapters on guest VM</h3>
480     <p>The network interfaces should already be configured on the guest within
481       the virtualbox configuration.&nbsp; This is available by clicking on the
482       VM in the virtualbox manager and selecting "Settings".&nbsp; These are the
483       configuration settings used:</p>
484     Adapter 1:<br>
485     &nbsp; Attached to: Host-only Adapter<br>
486     &nbsp; Name: vboxnet0&nbsp; <br>
487     <p>Adapter 2:<br>
488       &nbsp; Attached to: Nat Network<br>
489       &nbsp; Name: NatNetwork</p>
490     <p>On the guest VM itself, the network settings are specified in a file
491       called /etc/network/interfaces.&nbsp; Here are the current contents of
492       that file:</p>
493     <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>
494     <pre>auto enp0s8</pre>
495     <pre>iface enp0s8 inet dhcp</pre>
496     <p> </p>
497     <h2>Notes on building the Cake Lamp VM</h2>
498     <p>This is all work that should already have been done.&nbsp; It is
499       mentioned here just as breadcrumbs for a future vm builder.</p>
500     <ul>
501       <li>Downloaded and installed virtualbox for host computer (where the vm
502         image will be built).</li>
503       <li>Downloaded ubuntu server 16.04 iso.
504         (https://www.ubuntu.com/download/server)</li>
505       <li>Created a new vm in virtualbox, telling it to start from the ubuntu
506         server iso.</li>
507       <li>Installed LAMP stack on guest VM.&nbsp; Some help here:
508         http://howtoubuntu.org/how-to-install-lamp-on-ubuntu</li>
509       <li>Configured CAKE on the guest VM.&nbsp; Useful link:
510         https://askubuntu.com/questions/628938/how-to-install-cakephp-in-ubuntu-14-04</li>
511       <li>Configured the two network adapters as needed (one for host-only
512         network and one for nat network).&nbsp; Here's some info about
513         virtualbox networking with two adapters similar to our setup:
514 https://askubuntu.com/questions/293816/in-virtualbox-how-do-i-set-up-host-only-virtual-machines-that-can-access-the-in<br>
515       </li>
516       <li>Installed and configured Samba service for the guest VM.&nbsp; The
517         main config file lives in "/etc/samba/smb.conf".&nbsp; Some pointers
518         here:
519 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>
520     </ul>
521     <p><br>
522     </p>
523     <ul>
524     </ul>
525     <h6> </h6>
526     <p> </p>
527   </body>
528 </html>