{"id":2668,"date":"2018-01-17T10:40:59","date_gmt":"2018-01-17T18:40:59","guid":{"rendered":"http:\/\/www.wellgolly.com\/?p=2668"},"modified":"2018-05-03T06:38:29","modified_gmt":"2018-05-03T13:38:29","slug":"notes-on-creating-a-droplet","status":"publish","type":"post","link":"https:\/\/www.wellgolly.com\/?p=2668","title":{"rendered":"Notes on creating a droplet"},"content":{"rendered":"<p>I created a new Digital Ocean droplet and mostly followed the tutorials to get things up and running. A couple of things that I need to do to get the environment the way it is on other machines.<\/p>\n<p>I had a bit of trouble with using Public Key Authorization. I think that I was selecting the key by triple clicking until everything was highlighted and then copying. I believe that I got a line feed a the end of the key that was messing up my login attempts. Carefully highlighting just the key seems to have done the trick.<\/p>\n<p>I also was stymied for a while when my site didn\u2019t display. First, since I turned on the firewall I needed to add either www (sudo ufw allow www) or Apache (sudo ufw allow Apache) to the rules. And then verify with sudo ufw status.<\/p>\n<p>When I created the droplet, I destroyed the previous one so I needed to find the DNS records and change the IP address. Unlike other services, DO puts that in Networking. <\/p>\n<p>I need to copy my .bash_profile file over to my home directory and add the line<br \/>\n<code class=\"preserve-code-formatting\">. ~\/.bash_profile<\/code> to my .profile file.<\/p>\n<p>Reload the profile with <code class=\"preserve-code-formatting\">source ~\/.profile<\/code><\/p>\n<p>I also want all of the files in the www directory to be created with the admin group. That way, no matter who created them, I\u2019ll be able to edit them.<\/p>\n<p><em>You can change the default group for all files created in a particular directory by setting the setgid flag on the directory (chmod g+s _dir_). New files in the directory will then be created with the group of the directory (set using chgrp &lt;group> &lt;dir>). This applies to any program that creates files in the directory.<\/em> <a href='https:\/\/stackoverflow.com\/questions\/1321168\/bash-scripting-how-to-set-the-group-that-new-files-will-be-created-with#1322706'>mark4o<\/a><\/p>\n<p>The default location for web files is \/var\/www, which is different than the setup on my older machines. (probably because the default location varies across distributions and over time). I put a symlink to it in the root.  <code class=\"preserve-code-formatting\">sudo ln -s \/var\/www\/ www<\/code><\/p>\n<p>I don\u2019t want people to be able to view the directories, especially the images directory, so I disabled that ability by removing the word <em>Indexes<\/em> from the option line.<\/p>\n<p><pre><code class=\"preserve-code-formatting\">\n&lt;Directory \/var\/www\/&gt;\n&nbsp;&nbsp;Options Indexes FollowSymLinks\n&nbsp;&nbsp;AllowOverride None\n&nbsp;&nbsp;Require all granted\n&lt;\/Directory&gt;\n<\/code><\/pre><\/p>\n<p>I covered this in earlier posts, but it doesn\u2019t hurt to repeat it. I make a few modifications to the apache config file to keep people from seeing things on the server. I added these lines after the section on .htaccess.<\/p>\n<p><pre><code class=\"preserve-code-formatting\">\n# We don&#039;t want people to see .inc files\n&lt;Files&nbsp;&nbsp;~ &quot;\\.inc$&quot;&gt;\n&nbsp;&nbsp;Order allow,deny\n&nbsp;&nbsp;Deny from all\n&lt;\/Files&gt;\n\n# Do not allow .git version control files to be viewed\n&lt;Directorymatch &quot;^\/.*\/\\.git+\/&quot;&gt;\n&nbsp;&nbsp;Order deny,allow\n&nbsp;&nbsp;Deny from all\n&lt;\/Directorymatch&gt;\n\n# We don&#039;t want people to see .svn files, mainly in Wordpress installs\n&lt;Directorymatch &quot;^\/.*\/\\.svn+\/&quot;&gt;\n&nbsp;&nbsp;Order deny,allow\n&nbsp;&nbsp;Deny from all\n&lt;\/Directorymatch&gt;<\/code><\/pre><\/p>\n<p>On my older servers I have lots of sites and their names end in .com, .net, etc. but on this version of Apache, the <code class=\"preserve-code-formatting\">a2ensite<\/code> requires files to end in .conf.<\/p>\n<p>I also had some trouble with the https code that was added to the site by certbot. I took them out after reviewing the output of <code class=\"preserve-code-formatting\">sudo journalctl -xe<\/code>.<\/p>\n<p>To install the certbot certificate I went to the page for my <a href='https:\/\/certbot.eff.org\/#ubuntuxenial-apache'>setup<\/a> and followed the directions. I have a .com and .org version of this site and allow access using www and without so I need the certificate to work for all four of these. Rather than getting four certificates, I got one for the name I will use most, the .org,  and then added the ones for www and .com.<\/p>\n<p>Unfortunately, at the moment there is a security vulnerability so the normal method does not work.<\/p>\n<p>Instead I had to stop Apache and run<br \/>\n<pre><code class=\"preserve-code-formatting\">\nsudo certbot --authenticator webroot --webroot-path \/var\/www\/ACOV\/ --installer apache2 -d example.org\n\nsudo certbot certonly --cert-name example.org -d example.com,www.example.org,www.example.com\n\nservice apache2 restart\n<\/code><\/pre><\/p>\n<p>I had some problems at first because I had not set up the DNS records at Digital Ocean correctly. I typed the whole domain into the add a record field, when I should have just typed www. It added <em>www.example.com.examp<\/em> instead of <em>www.example.org<\/em>. After I fixed that it created the certificates and I checked them. <\/p>\n<p>Unfortunately, something else is not right because Apache is not serving up the SSL connection. I\u2019ll update the post when I figure it out.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>I created a new Digital Ocean droplet and mostly followed the tutorials to get things up and running. A couple of things that I need to do to get the environment the way it is on other machines. I had a bit of trouble with using Public Key Authorization. I think that I was selecting &hellip; <a href=\"https:\/\/www.wellgolly.com\/?p=2668\" class=\"more-link\">Continue reading <span class=\"screen-reader-text\">Notes on creating a droplet<\/span><\/a><\/p>\n","protected":false},"author":6,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[16],"tags":[],"class_list":["post-2668","post","type-post","status-publish","format-standard","hentry","category-computers"],"_links":{"self":[{"href":"https:\/\/www.wellgolly.com\/index.php?rest_route=\/wp\/v2\/posts\/2668","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.wellgolly.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.wellgolly.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.wellgolly.com\/index.php?rest_route=\/wp\/v2\/users\/6"}],"replies":[{"embeddable":true,"href":"https:\/\/www.wellgolly.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=2668"}],"version-history":[{"count":0,"href":"https:\/\/www.wellgolly.com\/index.php?rest_route=\/wp\/v2\/posts\/2668\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.wellgolly.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=2668"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.wellgolly.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=2668"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.wellgolly.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=2668"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}