+ <h3>Compacting the VM Disk Image</h3>
+ <p>To minimize the size used for the disk image, there are three major
+ steps.</p>
+ <p>1. While running the VM, run this command:</p>
+ <pre><span style="font-weight: bold;">sudo apt clean</span></pre>
+ <p>This throws away any cached data from the apt tool, which can be
+ substantial.</p>
+ <p>If there are other junk files you know of that can be removed, delete
+ those now also.</p>
+ <p>2. Reboot the VM to the gparted ISO image (available at the <a target="_blank"
+ title="great free partition editor" href="https://gparted.org/livecd.php">gparted
+ site</a>) and run the following command:</p>
+ <pre><span style="font-weight: bold;">sudo zerofree /dev/sda</span></pre>
+ <p>This sets all free space to the zero byte, enabling Virtualbox to free
+ that space in the next step.</p>
+ <p>3. Shut the vm down after zerofree is complete and run this command on
+ the host PC (this is the Linux version of the command):</p>
+ <pre><span style="font-weight: bold;">VBoxManage modifyhd --compact ~/cake_lamp_vm/cake-lamp-vm-hd.vdi</span></pre>
+ <p>Replace the <span style="font-family: monospace;">~/cake_lamp_vm</span>
+ path with the real VM storage path. This command compacts the root
+ (and only) partition of the VM.</p>
+ <p>After these steps are complete, the VM should be its minimal size.</p>
+ <h2>Adding a new website and domain on the guest VM</h2>
+ <p>Note: these instructions, even the quick approaches below, pale in
+ comparison to the ease of use of the "standup" command in feisty meow's
+ site avenger scripts. The standup command is detailed in the <a
+ target="_blank" title="useful commands" href="https://feistymeow.org/feisty_meow/documentation/feisty_meow_command_reference.txt">feisty
+ meow command reference</a> document. These instructions are for
+ situations when the domain or site is idiosyncratic in some way that
+ standup doesn't support.</p>
+ <p>To add a new website, you will first need to pick one of the DNS options
+ below (A or B) depending on how you want to name the site. If the
+ DNS name of the site is contained within another existing domain (e.g.,
+ "A.B.C" has subdomain A contained in domain B.C), use Option A. If
+ the DNS name is a so-called "Second Level Domain" (SLD), then it stands on
+ its own (e.g., "B.C" is an SLD).</p>
+ <p>Once the DNS option has been picked and implemented, continue to the next
+ section of "Creating a New Apache Site".</p>
+ <p>For either Option A or Option B, first connect to the cakelampvm via ssh
+ as the developer user, e.g.: ssh developer@cakelampvm.com </p>
+ <h3>DNS Option A: Adding a sub-domain in an existing domain</h3>
+ <p>Let us say a customer needs an application called "excalibur". It
+ will be a new subdomain within an existing domain, such as the
+ "cakelampvm.com" domain, meaning we want the VM to start answering
+ requests for "excalibur.cakelampvm.com".</p>
+ Note that this option requires the containing domain "cakelampvm.com" to
+ already exist before adding the subdomain; see DNS Option B below for
+ details on how to add a containing domain for the first time.
+ <h4>Quick approach: Use the feisty meow "add_domain" command.</h4>
+ <p>Run this command in a bash shell on the VM:</p>
+ <pre><span style="font-weight: bold;">add_domain excalibur.cakelampvm.com</span></pre>
+ <p>Done.</p>
+ <h4>Manual approach: Edit the bind9 configuration.</h4>
+ <p>Note: the manual approach is not compatible with later use of feisty
+ meow's "remove_domain".</p>
+ Execute the following command to edit the DNS file for the cakelampvm
+ domain:
+ <pre><span style="font-weight: bold;">sudo vi /etc/bind/cakelampvm.com.conf</span></pre>
+ <p>Add a stanza for the new site at the end of this file:</p>
+ <pre>excalibur.cakelampvm.com. IN A 10.28.42.20<br> IN HINFO "linux server" "ubuntu"</pre>
+ <p>Restart the DNS server:</p>
+ <pre><span style="font-weight: bold;">sudo service bind9 restart</span></pre>
+ <p>Afterwards, pinging excalibur.cakelampvm.com should work from both the
+ guest VM and the host PC.</p>
+ <h3>DNS Option B: Using an entirely new domain for the site</h3>
+ <p>This is a similar procedure to Option A, but we will create a totally new
+ config file for the new domain and add it to the bind directory. For
+ this example, we need to add the site "excalibur.tv" into the DNS.</p>
+ <h4>Quick approach: Use the feisty meow "add_domain" command.</h4>
+ Run this command in a bash shell on the VM:
+ <pre><span style="font-weight: bold;">add_domain excalibur.tv</span></pre>
+ <p>Done.</p>
+ <h4>Manual approach: Edit a new DNS config file</h4>
+ <p>Note: the manual approach is not compatible with later use of feisty
+ meow's "remove_domain".</p>
+ Create a file called /etc/bind/excalibur.tv.conf for our new domain
+ excalibur.tv with these contents:
+ <pre>$TTL 1W<br>@ IN SOA @ fred.cakelampvm.com. (<br> 2017100801 ; serial<br> 2H ; refresh<br> 8M ; retry<br> 14D ; expiry<br> 6H ) ; minimum<br><br> IN NS ns.cakelampvm.com.<br> IN MX 10 mail.cakelampvm.com.<br><br># new SLD for our excalibur site.<br>excalibur.tv. IN A 10.28.42.20<br> IN HINFO "linux server" "ubuntu"</pre>
+ The gnarly prefix stuff above the "excalibur.tv." listing establishes
+ configuration info for the new domain. This file relies on the
+ existing cakelampvm.com infrastructure in DNS, such as the "ns" host, which
+ is the domain's name server. However, the new domain does <span style="text-decoration: underline;">not</span>
+ live inside the cakelampvm.com domain.<br>
+ <p>Now that the config file is in place, edit "/etc/bind/named.conf.local"
+ to add the new file by adding this bit of configuration at the end:</p>
+ <pre>zone "excalibur.tv" in {<br> file "/etc/bind/excalibur.tv.conf";<br> type master;<br> allow-query { any; };<br>};</pre>
+ <p>Restart the DNS server:</p>
+ <pre><span style="font-weight: bold;">sudo service bind9 restart</span></pre>
+ <p>Afterwards, pinging excalibur.tv should work from both the guest and the
+ host.</p>
+ <h3>Creating a New Apache Site</h3>
+ <p>First, connect to the cakelampvm via ssh as the developer user, e.g.: ssh
+ developer@cakelampvm.com </p>
+ <h4>Quick approach: Use the feisty meow "add_apache_site" command.</h4>
+ <p>Run this command in a bash shell on the VM:</p>
+ <pre><span style="font-weight: bold;">add_apache_site excalibur excalibur.tv</span></pre>
+ <p>(The first parameter is the application name, the second is the domain
+ name.)</p>
+ <p>Done.</p>
+ <h4>Manual approach: Edit an Apache config file</h4>
+ <p>Note: the manual approach is not compatible with later use of feisty
+ meow's "remove_apache_site".</p>
+ <p>For Apache, the choice of DNS Option A or B, subdomain or SLD, does not
+ matter. The site configuration file just has to accurately specify
+ the domain in question.</p>
+ <p>Start with the following template file for the new website, and modify it
+ for the appropriate host name and "DocumentRoot" path:</p>
+ <pre><VirtualHost *:80><br> ServerName excalibur.tv
+ DocumentRoot /home/apps/excalibur<br> ErrorLog ${APACHE_LOG_DIR}/excalibur.tv-error.log<br> CustomLog ${APACHE_LOG_DIR}/excalibur.tv-access.log combined<br> Include /etc/apache2/conf-library/basic-options.conf<br> Include /etc/apache2/conf-library/rewrite-enabling.conf<br></VirtualHost></pre>
+ <p>The above example is appropriate for our excalibur app in the
+ excalibur.tv domain (using DNS Option B). Modifying the excalibur.tv
+ references in it (and the path in the DocumentRoot) is sufficient to
+ re-target it for any domain you want.</p>
+ <p>Copy the new site config file into "/etc/apache2/sites-available" with an
+ appropriate file name that includes the site's domain name. We will
+ call our config file "excalibur.tv.conf". If you developed the file
+ in your home folder, this would be the command to move it up to Apache:</p>
+ <pre><span style="font-weight: bold;">sudo cp ~/excalibur.tv.conf /etc/apache2/sites-available</span></pre>
+ <p>Then tell apache to use the new file:</p>
+ <pre><span style="font-weight: bold;">sudo a2ensite excalibur.tv<br># the '.conf' portion of the filename is unnecessary for this command.</span>
+</pre>
+ <p>Finally, restart apache to get it to begin serving the site:</p>
+ <pre><span style="font-weight: bold;">sudo service apache2 restart</span></pre>
+ <h3>Test the new web site</h3>
+ <p>Given the configuration above, your host PC should now be able to access
+ the new website on the domain "excalibur.tv".</p>
+ <p>To test this, first try pinging the new DNS name:</p>
+ <pre><span style="font-weight: bold;">ping excalibur.tv</span></pre>
+ <p>If there are responses to the ping <span style="font-weight: bold;">*and*</span>
+ the answer is 10.28.42.20, then it means the DNS is working.</p>
+ <p>If there are no responses or it's some other IP address talking back,
+ check the instructions in the above DNS sections.</p>
+ <p>Once the DNS is working, try browsing to the site at "<a title="it's excalibur, wilbur!"
+ href="http://excalibur.tv">http://excalibur.tv</a>". That should
+ at least bring up the configured site storage path, even if nothing is
+ being served from that folder yet.</p>
+ <p>If the new site is not showing up properly, try examining the apache logs
+ for any error messages that can be corrected. The log files are
+ stored in "/var/log/apache2" and are named after the website (if
+ configured through the above process).</p>