Virtual Private Hosting – How to Remove a Domain with Certbot SSL Certificate (on Ubuntu 16.04 with apache)

It used to be pretty easy to remove a domain from my Virtual Private Server – dissable the site in apache, delete the files, delete the underlying database, and remove the domain from my DNS manager. Done.

With SSL certificates now a standard part of hosting websites (see here), this is complicated by the removal of those certificates. I am extremely grateful to the EFF for providing a free way to get SSL certificates through certbot and letsencrypt. Adding domains with certbot is pretty easy, but changing the domains with certificates is not so easy. In fact, it’s pretty complicated and there aren’t great directions out there (which is why I put this guide together).

In this guide, I’ll show you how to remove a domain from a virtual private server (I use linode.com) along with removing the SSL certificate. I was hosting a domain and website for a friend, but that person decided they no longer needed the domain. Here’s how I removed it.

First, it’s always a good idea to back up the files associated with the domain, just in case. I use phpMyAdmin to manage my SQL databases. Log in to your phpMyAdmin site, find the database associated with your site, and select Export.

You shouldn’t need to change any options, just select “Go” and phpMyAdmin will export the entire database.

To download all the files associated with your site, you can zip them from an SSH terminal or download them via FTP. I use Filezilla. Find the folder that contains all the files for your website and download the whole thing.

Now that you have a backup of everything, it’s time to start unmounting.

First, you should dismount your site in apache.

sudo a2dissite [domain]

You also need to dismount the site with encryption, which is the same command, but with the following addition:

sudo a2dissite [domain]-le-ssl.conf

Then reload your apache2 configuration:

service apache2 reload.

If you’ve done everything correctly, when apache reloads, there won’t be any errors.

Next, delete the certificate associated with your domain in certbot. To delete the certificate associated with a specific domain, the command is:

certbot delete –cert-name [enter domain here]

That will delete the certificate associated with that domain.

You may also need to update your certificate profile by using the command:

certbot –apache

This will list all of the domains you have certificates for. You can then select all of the other domains on your server but drop the one you want to delete. That will create a new certificate with all of the domains minus the one you have deleted.

If you are wondering whether certbot has actually removed your domain, you can check by going to /etc/letsencrypt. You want to make sure that your domain is no longer showing up in either the /live,  /renewal, or /archive folders. If you still see it in there, it should be safe at this point to delete any folders with the name of the domain in it.

Next, you can delete the corresponding database. In phpMyAdmin, click on “Server: localhost” then click on “Databases.” Select the box next to the database you want to delete, then, at the bottom, click “Drop”. You’ll get a warning about destroying a database. Select OK and the database is gone.

We’re almost done. Now, delete the files for your site. You can do this with the rm command from the terminal or using your FTP client.

Now, you should delete the apache site files that are located in /etc/apache2/sites-available. These are the two that were dismounted earlier: [DOMAIN].conf and [DOMAIN]-le-ssl.conf.

You can restart the apache service one more time to make sure everything is working, but you should be good.

Finally, you can delete the domain from your DNS manager.

That should do it. The domain should now be gone, entirely, from your server.

Ubuntu Linux (KDE): “Chrome didn’t shut down correctly” error

Every so often, Chrome on my Linux based computers (one running Kubuntu and one running Linux Mint KDE) starts having a problem.  I like having Chrome save my tabs from my previous sessions so I can pick back up where I left off.  But for some reason, and I’m not exactly sure what that reason is, Google’s Chrome eventually starts giving me the following error message:

Chrome didn't shut down correctly error
Chrome didn’t shut down correctly error

The error says, “Chrome didn’t shut down correctly” followed by a button that says “Restore.”  By clicking on the Restore button, I’m able to get my tabs back, but it’s kind of annoying that I have to do that.  Also, there is no indication of what the problem is in the Chrome crash log (chrome://crashes), which means I really have no idea what causes this problem.  I tried a bunch of suggestions from various websites to get this error to go away and finally found one that works.  Here’s what you need to do.

First, click on Chrome’s Settings option:

Chrome settings menu
Chrome settings menu

In the tab that opens up, scroll to the bottom and select “Show advanced settings…”

Chrome advanced settings
Chrome advanced settings

Near the bottom of the advanced settings is the option you want: System.  There should be two buttons there.  The first one says, “Continue running background apps when Google Chrome is closed.”  I only get the “Chrome didn’t shut down correctly” error when that button is selected.

Continue running background apps when Google Chrome is closed
Continue running background apps when Google Chrome is closed

Uncheck the box next to that option, like this:

Continue running background apps when Google Chrome is closed
Continue running background apps when Google Chrome is closed

Now try restarting Google Chrome.  If whatever is causing this is the same problem for you as it is for me, it should have solved the problem.  If not, sorry.  Keep googling for an answer.   :(

Linux: Creating Maps on Linux with QGIS

For my job, I occasionally need to create maps to illustrate some concept or another.  For instance, it can be useful to see a the racial makeup of the US as a map color-coded to reflect the percent of the population that identifies as black in each state.  It provides a quick illustration of how people identifying as a certain race are distributed across the US.  Back when I used Windows, I had a hard time finding simple software that would create maps like this, but it seemed like there were more or at least cheaper options with Windows.  However, you can’t beat free, and that’s how much the software you’ll need for this tutorial costs!  I’m going to do this tutorial in three parts: 1) Getting ready; (2) Creating your map; (3) Preparing your map for printing/export.

Part 1: Getting Ready to Create a Map

  1. To begin with, you’ll need some software.  The software I’ll be using is called QGIS.  It’s free and is included in most Linux repositories (it’s included in the Ubuntu repositories; I run Kubuntu).  That makes it easy to install, either from Synaptic or from the terminal (e.g., sudo apt-get install qgis python-qgis).  QGIS runs on Windows and Mac as well, so this tutorial will probably work for those OSes, too.  So, step 1 is to install QGIS.
  2. You’re also going to need some shape or map files.  You can create your own, but you don’t want to do that as it takes forever and almost any common map you could want has already been created for you.  There are two great places to download maps: For maps related to the US, try the U.S. Census Bureau’s Tiger files website.  The shape file I’ll be using for this tutorial came from their website.  For a broader array of maps, try NaturalEarthData, which has lots and lots of maps to choose from.  Download the shapefile’s you think you’ll want, unzip them, and store them in a location where you can access them readily.
  3. Finally, if you’re adding data to your map, you’ll need that data, ideally in a spreadsheet.  There are lots of sources of data.  I tend to use a lot from Statistical Abstracts, which is now run by Proquest since it was defunded by the Census Bureau.  But you can use data from wherever.  The key, however, is to make sure it’s cleanly entered into a spreadsheet.

Part 2: Creating Your Map

  1. Once you have your software installed, you’ve download the necessary shape files, and you’ve got your data ready, it’s time to create your map.  First, open QGIS.  You’ll see a blank screen with lots of buttons and such. Lots to do here, but we’re going to keep this simple.QGIS-01
  2. The first thing you need to do is add your shapefile.  Assuming you have downloaded the shapefile and unzipped it, let’s import it into QGIS.  You’re going to add it as a layer.  Click on the add vector layer button:
    QGIS-02
  3. You’ll then need to find the map file you want to import using the “browse” button and click “open.”QGIS-03
  4. You should then see the map show up in QGIS.
  5. You’ll next need to make sure that you’ve properly prepared your data for importing into QGIS.  There are two things you need to check.  First, right-click on the map or shapefile you just imported and scroll down to “Open Attribute Table.”QGIS-04
  6. You’ll now seen a table with lots of information.  This table basically provides all the information to QGIS to tell it how to generate the map.  You’re going to link your data to this table.QGIS-17
  7. What you need to find is a variable in the table (one of the columns) with information that you can use to link your data file with this table.  You should probably use something like “GEOID” or “NAME”.
  8. By clicking on the header of any of the columns, the table will be sorted by that column.  Since I’m using states for my map, I clicked on the column header “NAME” so the states are sorted alphabetically.  I then checked the names of the states and the GEOID with those in my data file in a separate spreadsheet.  (Here’s a file with accurate names and GEOIDs.)  You’re checking these because this is how you’ll link your data to this table.  Make sure that you have the correct names or GEOIDs in your data file.  Whichever variable/column you choose to link the shapefile and your data file, it’s a good idea to use the same column header in your data file as exists in the shapefile attributes table.  As you can see, I’m using GEOIDs.  (Hint: Most GEOIDs in attribute files have zeros in front of small numbers, like “001” instead of “1”.  To link files, you should set your GEOID column in your spreadsheet software to “text” rather than “numbers” or those zeros will disapper and QGIS won’t link those records.)  Here’s how my data file looks in LibreOffice:QGIS-06
  9. Now, if you’re using LibreOffice, save your data file as a “.dbf” file.  That’s the file format that QGIS reads.
    QGIS-05
  10. Now you’re going to import your data file into QGIS.  Go back to QGIS and click on the same button you used to add a vector layer.  You’ll have to tell QGIS that you want to see “All Files” as it won’t show DBF files by default, but it can import them.QGIS-07
  11. Find your DBF file and select “Open.”  You’ll now see it in the list of layers.QGIS-08
  12. Now for the important part.   You’re going to link or join your data file with the the shapefile attribute table.  To do this, double-click on the shapefile in the layers box in QGIS and you’ll get a new window:QGIS-09
  13. Click on the “Joins” tab and you’ll see this:QGIS-10
  14. Now click on the green + icon and you’ll see this window:QGIS-11
  15. In the “Join layer” field, choose your data file you imported.  In the “Join field” field, choose the column header for the variable you are using in your data file to link to the attribute file.  In my case, it is GEOID.  In the “Target field,” choose the column header your linking your data file to in the attribute table.  In my case, it is GEOID.  Like this:QGIS-12
  16. Now hit OK on that window and then “OK” again on the properties window and your data file should be linked to the Attribute Table of the shapefile.  You can check that the join worked by right-clicking on your shapefile and opening up Attribute Table again.  You should see your data added to the end of the Attribute Table file.  (NOTE: QGIS is smart enough to know when there isn’t data for a row in the joined data and inserts NULL instead.  For instance, I didn’t import any data for Puerto Rico, so that is listed as NULL.  Also, if for some reason your data don’t get linked, it will insert NULL.  That’s usually a sign that you didn’t enter a value in correctly on your linking variable.)QGIS-13
  17. If your data are in the Attribute Table, you’ve succeeded with the hardest part of this project.  Now we just need to display that data on the map.  QGIS makes displaying data based on colors very easy.  Just below the shapefile you should see a box (it’s called a “group”).  That box is basically just a stand in for the current map that is being displayed.
    QGIS-14
  18. Double-click on that box and you’ll get a new “Layer Properties” window.  In that window, click on “Style.”QGIS-15
  19. If you want QGIS to do most of the work of coloring for you, look for the dropdown menu that says “Single Symbol.”  That is the current color of the map.  Click on that and choose, instead, “Graduated.”  The options in the window will now change.  “Graduated” means that the color coding will be based on the values of the variable you choose.  You can choose how many colors to display where it says “Classes.”  You can change the colors used where it says “Color ramp”.  You can choose the width of the intervals where it says “Mode.”  But, most importantly, we want to choose the variable that is going to be used for calculating the colors where it says “Column.”  Like I have below:
    (insert screen capture here)QGIS-18
  20. Once you’re ready, click “OK” and watch your map change to reflect color coded values based on your variable, like this:QGIS-16
  21. At this point, you’ve successfully created your map.  In Part 3 below I’ll show you how to prepare your map for exporting to an image file or for printing.

Part 3: Preparing Your Map for Printing/Exporting

  1.  It may seem like you’re done at this point, and you’re pretty close, as you’ve done the hard part.  But QGIS has an additional feature that makes creating maps even nicer – composing the finished map.  Yes, you could just take a screen capture of the map you created and that may be sufficient, but wouldn’t it be nice to have a legend?  And a title?  And, in my case, include Hawaii and Alaska all in the same image?  You can do all of that from the “Print Composer” feature of QGIS.  To open the Print Composer, click here:QGIS-19
  2. Once you click on the “Print Composer” button you’ll be asked to give your print a title.  Title it whatever you want, then you’ll see this screen:QGIS-20
  3. The first thing you’ll want to do is set your Composition size.  If you’re going to save your map as an SVG file, size won’t really matter.  But if you’re saving it as any other image file, you should probably go as big as possible.  This is done using the “Composition” tab on the right side of the screen.QGIS-21
  4. Next, you’re going to want to import the map you just created as the center piece of your print.  To do this, click on the “Add new Map” button:QGIS-22
  5. When you click on that button, you’ll then be able to draw a rectangle on your canvas (the white area) that will import onto the canvas whatever is showing in the main QGIS window.  So, make sure that whatever you want to import onto your canvas is showing in the other window, then drag your rectangle to import it.QGIS-23
  6. You’ll then want to switch to the primary selection tool, which is what you’ll use to interact with the different components of your map composition:
    (insert)QGIS-24
  7. By selecting one of the components of your map, you can also modify it’s properties on the right hand side under “Item Properties”:QGIS-25
  8. We now have the main part of our map.  But, in my case, I also want to include Alaska and Hawaii, as well as a legend.  To add Alaska and Hawaii, recenter the primary QGIS window over them one at a time and then import them the same way you imported the continental US.
  9. The next item I want to add is a legend.  To add a legend, click the icon at the top of the screen to do so:
    QGIS-26
  10. You can adjust the properties of the legend under the “Item Properties” tab on the right of the canvas.
  11. The final item you should add is a title.  This is done with the “Add new Label” button at the top of the screen:QGIS-29
  12. Like the other items, you can adjust your title under the “Item Properties” tab until you’re happy with it.
  13. Once you’ve got your map how you want it, it’s time to export it.  If you aren’t familiar with SVG files, they are really neat.  Basically, they can scale to any size without pixelating because of how they are stored (SVG stands for “scalable vector graphics”).  That’s probably the ideal format for exporting.  But you can also export the map in a variety of other formats.  Below is the final map exported as a PNG file.
    QGIS-28

 

Notes:

I drew on the following tutorials to create this one.

  • http://www.qgistutorials.com/en/docs/making_a_map.html

Linuxmint or Ubuntu: Crashplan backup using headless Synology NAS

If you’re using a Synology NAS box and would like to back up your files to offsite storage service Crashplan (which is relatively inexpensive), there is a relatively easy way to do this.  However, you need to think about the Crashplan software as having two components.  There is the backup engine, or the software that communicates with Crashplan’s servers and sends the files you want backed up to their servers.  Then there is the “head” or user interface which tells the engine what to back up and when.  If you’re backing up your Synology box, then the engine will go on there.  You can use any OS for the head, but I’m running Linuxmint and here is how I got it to work.

1) On your Synology box, first you need to download and install Java SE for embedded packages following these instructions.  Then you need to download and install the Crashplan package for Synology NAS following these instructions. Make sure you choose the correct version of Crashplan from the link above.  You don’t want to install CrashPlan Pro if you’re just running CrashPlan – it won’t work.

2) Once you’ve got both of those up and running on your Synology box, you should see something like this:

crashplan-01

crashplan-02

crashplan-03

3) The next step is to install CrashPlan on your desktop computer so you can control the engine on your Synology box (i.e., tell it what to backup and when).  First, download the CrashPlan software for your OS here.  Once you’ve downloaded the .tgz file, uncompress it to a folder (doesn’t really matter where; your’e desktop or home folder will work).  Then open a terminal and navigate to where you unpacked the CrashPlan files.  At the terminal, type:

sudo bash install.sh

You’ll then need to follow the prompts, but it should install the software on your computer.

4) Now is the tricky part.  If you follow the directions on CrashPlan’s website to connect the “head” to the “headless engine” it won’t work.  Their directions say to edit the file /usr/local/crashplan/conf/ui.properties by uncommenting the line #servicePort=4243 and changing it to servicePort=4200.  You then need to set up an SSH tunnel.  Here are their directions.  I tried a lot of variations of this and didn’t work.  But you know what did?  Editing a different line.  In that same file, uncomment the line that says #serviceHost=127.0.0.1 and change it to serviceHost=192.168.2.100 (i.e., the IP of your Synology box).  Save the file and close it.

5) You should now be able to open the CrashPlan GUI and control your Synology box remotely.

LinuxMint or Ubuntu: How to Automount Synology Shares

UPDATE:  As of Ubuntu 13.04, these directions no longer work.  I figured out a way to get this to work, however.  See the updated directions at the bottom of this post.

——————Old Directions————————————

If you’d like to share your network attached storage from a Synology file server with your Linuxmint or Ubuntu machine and have it appear as just another folder, you can set the Synology unit to automount on your computer.  These steps assume that you have already set up your Synology unit and are sharing at least one folder over the network.  It also assumes that you are already connected to the same local network as your Synology unit.

To set up the automount, do the following:

1) Install the package nfs-common, either using synaptic or the command line:

synology-01

(from the command line: sudo apt-get install nfs-common)

2) Open a console or terminal and type “ifconfig” to find out your IP address on your local network.

synology-02

 

Let’s assume your IP on the local network is 192.168.2.1 (as shown in the figure).

3) Open the Synology interface and then open the Control Panel:

synology-03

4) Click on “Shared Folder” which will show you a list of your shared folders.  Synology comes with the ability to share folders using the nfs protocol.  It is a secure protocol that requires you to add the IP address of the computer that is going to be allowed to access files on the Synology NAS.  Once you see the shared folders, select the folder you want to share, then click on “Privileges” and then “NFS Privileges”.

synology-04

 

5) In the next window, click on “Create” and then add the IP address of the computer with which you want to share that folder.  You should also decide what privileges you want to grant that computer.  If you grant it read/write privileges, that computer can modify files.  If you grant it the read privilege, that computer can only read files.

synology-05

6) Once you’ve done that, you should be able to access the shared folder over your network.  However, what we want to do is make any shared folders automatically mount over the network every time you start your computer.  To do so, you’ll need to do two more things.  First, create a folder on your computer to map the shared folder to.  An ideal location is in your home folder since you already have read/write privileges there.  So, for instance, if you are sharing photos over the network, create a folder in your home directory called “NASphotos” by doing the following from the terminal (or just create it in a file explorer): mkdir /home/user/NASphotos

7)  Next, you’ll need to edit your /etc/fstab file.  To do so, open a terminal and type: sudo kate /etc/fstab

(You could also use gedit or some other text program, like nano.)

8) This should open the /etc/fstab file in a text editing program.  You’ll need to add the following lines to your /etc/fstab file:

Any line that starts with the pound sign “#” is a comment line.  I like to add a comment line so I know what my command is doing.  Here’s the line I add:

# automount file synology

Next is the line that actually does the work:

     192.168.2.100:/volume1/photos /home/user/NASphotos nfs nouser,rsize=8192,wsize=8192,atime,auto,rw,dev,exec,suid 0 0

You’ll need to change the parts that are bolded.  The IP is the IP of your Synology unit on the network.  If you have a different name for your volume on your Synology unit, you’ll need to change “volume1” to whatever it is.  Replace “photos” with the name of the shared folder on your Synology unit.  Replace “user” with your username.  And replace “NASphotos” with whatever folder you created in step 6.

Save the file and close it.

8)  Now, assuming you’ve done everything correctly, type the following into a terminal to mount the shared folder: sudo mount -a

Your shared folder should now show up in your file explorer (e.g. Dolphin) and should do so every time you start your computer.  Depending on the privileges you granted yourself on the Synology NAS, you should be able to read and/or write whatever files you’ve stored on the Synology unit as if they were on your own computer.

 

——————————————New Directions—————————————

UPDATE: As of Ubuntu 13.04, the directions I gave above stopped working. After tinkering with the settings for a while, I found a way to make it work.  Follow all of the above steps.  However, when you edit the fstab file, try using the following format for each share you want to mount:

192.168.2.100:/volume1/photos /home/user/NASphotos nfs rw,hard,intr,nolock 0 0

This is working for now.  This was based on this article on the ubuntu help site.