How to: Migrating school’s WeeWX report site to new domain

How to: Migrating school’s WeeWX report site to new domain

My old domain which was XE1GOX.com expired a few days ago, and since I still host the school’s weather station webpage I have to setup a new subdomain for it to keep it accesible to everyone.

Setting up the virtual host

First we need to setup the virtual host inside the server. We start by creating the folder inside which we will be hosting the site files:

$ sudo mkdir -p /var/www/cucei.moloko.dev/public_html

Now we change ownership of the directory from ROOT to our current user:

$ sudo chown -R $USER:$USER /var/www/cucei.moloko.dev/public_html

We should also modify our permissions a little bit to ensure that read access is permitted to the general web directory and all of the files and folders it contains so that pages can be served correctly:

$ sudo chmod -R 755 /var/www/cucei.moloko.dev/public_html

To save some keystrokes I copied the previous Apache config from xw.xe1gox.com to cucei.moloko.dev

$ sudo cp /etc/apache2/sites-available/wx.xe1gox.com.conf /etc/apache2/sites-available/cucei.moloko.dev.conf

Open the file with nano:

$ sudo nano /etc/apache2/sites-available/cucei.moloko.dev.conf

And we change the file paths. The configuration looks like this:

<VirtualHost *:80>
    
        ServerAdmin webmaster@localhost
        ServerName cucei.moloko.dev
        ServerAlias cucei.moloko.dev
        DocumentRoot /var/www/cucei.moloko.dev/public_html

        ErrorLog ${APACHE_LOG_DIR}/error.log
        CustomLog ${APACHE_LOG_DIR}/access.log combined

</VirtualHost>

Enable the site and restart apache:

$ sudo a2ensite cucei.moloko.dev.conf
$ sudo systemctl reload apache2

At this point the site’s already enabled but we don’t have any files to serve yet (weewx isn’t running at the time to generate them) so we head over the old site directory and copy the contents to the new directory:

$ cp -r /var/www/wx.xe1gox.com/public_html/* /var/www/cucei.moloko.dev/public_html

Enabling SSL and installing certificate from Let’sEncrypt

Taking advantage of how easy it is to enable SSL by issuing and installing certificates from Let’sEncrypt, I will enable it on the site.

We invoke certbot using the Apache plugin:

$ sudo certbot --apache -d cucei.moloko.dev

This runs certbot with the --apache plugin, using -d to specify the names you’d like the certificate to be valid for.

If that’s successful, certbot will ask how you’d like to configure your HTTPS settings:

Please choose whether or not to redirect HTTP traffic to HTTPS, removing HTTP access.
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
1: No redirect - Make no further changes to the webserver configuration.
2: Redirect - Make all requests redirect to secure HTTPS access. Choose this for
new sites, or if you're confident your site works on HTTPS. You can undo this
change by editing your web server's configuration.
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Select the appropriate number [1-2] then [enter] (press 'c' to cancel):

I choose 2 to always redirect to HTTPS. If everything goes well certbot will show the following:

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Congratulations! You have successfully enabled https://cucei.moloko.dev

You should test your configuration at:
https://www.ssllabs.com/ssltest/analyze.html?d=cucei.moloko.dev
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

We try going to https://cucei.moloko.dev/ and effectively the site’s running!

Configuring WeeWX website path

Up to this point the basic website has been created and enabled, now let’s go adjust the WeeWX configuration file to update the new path were the standard report generated should be placed.

Open the file with nano:

$ sudo nano /etc/weewx/weewx.conf

We look for the report configuration section and change the path for [StdReport]

##############################################################################

#   This section specifies what reports, using which skins, to generate.

[StdReport]

    # Where the skins reside, relative to WEEWX_ROOT
    SKIN_ROOT = /etc/weewx/skins

    # Where the generated reports should go, relative to WEEWX_ROOT
    HTML_ROOT = /var/www/cucei.moloko.dev/public_html

We start again the WeeWX service:

$ sudo /etc/init.d/weewx start

And open the log to check that it effectively starts with no problems and the interceptor module waits for data to arrive:

$ sudo tail -f /var/log/syslog

The weather station is currently offline, so we test the server by posting test data using Insomnia:

Server log output indicates the observation was received and processed:

weewx[13246]: reportengine: Found configuration file /etc/weewx/skins/Sofaskin/skin.conf for report 'StandardReport'
weewx[13246]: cheetahgenerator: using search list ['weewx.cheetahgenerator.Almanac', 'weewx.cheetahgenerator.Station', 'weewx.cheetahgenerator.Current', 'weewx.cheetahgenerator.Stats', 'weewx.cheetahgenerator.UnitInfo', 'weewx.cheetahgenerator.Extras']
weewx[13246]: restx: Wunderground-RF: Published record 2019-07-06 19:29:07 CDT (1562459347)
weewx[13246]: manager: Daily summary version is 2.0
weewx[13246]: cheetahgenerator: Generated 7 files for report StandardReport in 0.79 seconds
weewx[13246]: manager: Daily summary version is 2.0
weewx[13246]: imagegenerator: Generated 12 images for StandardReport in 0.35 seconds
weewx[13246]: copygenerator: copied 4 files to /var/www/cucei.moloko.dev/public_html
weewx[13246]: reportengine: Report 'SeasonsReport' not enabled. Skipping.
weewx[13246]: reportengine: Report 'SmartphoneReport' not enabled. Skipping.
weewx[13246]: reportengine: Report 'MobileReport' not enabled. Skipping.
weewx[13246]: reportengine: Running report 'FTP'
weewx[13246]: reportengine: Found configuration file /etc/weewx/skins/Ftp/skin.conf for report 'FTP'
weewx[13246]: ftpgenerator: FTP upload not requested. Skipped.
weewx[13246]: reportengine: Running report 'RSYNC'
weewx[13246]: reportengine: Found configuration file /etc/weewx/skins/Rsync/skin.conf for report 'RSYNC'
weewx[13246]: rsyncgenerator: rsync upload not requested. Skipped.
weewx[13246]: interceptor: MainThread: empty queue

That’s it, migration succesful from https://wx.xe1gox.com/ to https://cucei.moloko.dev/

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.