Installing WeeWx on Centos 8 – The Basics

I’ve long been a weather nerd, and some years ago I finally invested in a personal weather station with all the sensors you could want. Temperature and humidity? Of course! Wind speed and direction? Absolutely! I even have a rain gauge, though I wouldn’t want to brag. And, once all of these items were acquired, my wife and I decided to sell our house; We’ve been very happy in our apartment these past 4 years, but apartment living and accurate weather monitoring are not the easiest of friends.

But, I’m getting a head of myself. Lets get started at the beginning: This post is about taking a ‘Minimal’ install of Centos 8 and getting WeeWX 4.1.1 running on it. I did a net-install of Centos 8 onto a VM, running in KVM. I selected ‘Minimal’ as the package selection and I then built up the system with just the packages I needed for success.

During installation, I set a password for root, and I also setup a non-administrator account so I can connect to the machine via ssh.

Depending on the final goal of your system, you’ll need to make sane choices for security. My WeeWX machine lives on my internal network, behind a firewall, and is not setup to allow any remote access to it. This keeps my risk at a lower level, and we’ll discuss in future posts how I make the station available for me to check when I’m not at home. If you’re final goal differs, you’ll need to adjust security accordingly.

Something I do on all of my Linux machines though, is disable the root user from logging in over SSH.

(I prefer to use ‘vi’ as my text editor, but use your preffered)

vi /etc/ssh/sshd_config

For me, line 46 says: PermitRootLogin without-password

You can also set, yes (not recommended) or no. The option ‘without-password’ means that root is allowed to SSH into the system only with pre-shared SSH keys.

Once you’ve made the appropriate change, restart the sshd service.

systemctl restart sshd

If you’re accessing the machine via ssh when you restart the service, your session will be maintained.

With that done, you’ll need to always use the other user created at install, and not root, to ssh into the system; Or, setup root login via SSH with shared keys.

Next step is to get some packages installed that WeeWX will need.

yum install epel-release -y

This makes available some additional packages that Centos do not directly provide.

Then, we install the packages needed for WeeWX. There is a number of Python packages, which makes sense considering WeeWX is written in Python, and then we’re also installing the Apache web server, MariaDB database server, and some development tools to allow us to install ephem, which there is no package for.

dnf install tar python3 python3-configobj python3-cheetah python3-pillow python3-pyusb python3-pyusb python3-PyMySQL wget policycoreutils-python-utils mariadb-server gcc python36-devel httpd python3-pyserial -y

Next, install ephem, which allows WeeWX to calculate almanac data like moon phase, etc.

pip3 install ephem

Now, we’re ready to get WeeWX itself installed. I prefer to use the package direct from WeeWX, instead of a RPM built for Centos. I find this helps make updates easier, and makes sure the standard documentation aligns with my system. The Debian and Red Hat focused packages change the default locations for a number of files to adhere to how those systems are designed, instead of adhering to how WeeWX prefers to be installed. Both methods work well, but this is how I prefer to do the install.

Head over to the WeeWX downloads page, and get the link for the current version of WeeWX. For me, it was version 4.1.1.

wget [weewx Link]
tar zxvf [weewx File Name]
cd WeeWX-X.X.X
python3 ./ build
python3 ./ install

With that done, WeeWX is installed. Congratulations! You can expect absolutely nothing at all to now happen on it’s own.

Before I run WeeWx for the first time, I like to do a bit of prep to get things running in a more safe and ‘Centos-like’ way.

Firstly, I use a symlink to take the default ‘public_html’ folder that WeeWx uses as a destination for the webpage outputs, and redirect that to the default source Apache uses for serving webpages on Centos, /var/www/html.

rm -rfv /var/www/html
touch /home/WeeWX/public_html
ln -s /home/WeeWX/public_html /var/www/html

Then, to allow that to work properly without disabling a layer of security in Centos, Security-Enhanced Linux, we let SELinux know that we’re now serving pages from this new spot.

chcon -Rv --type=httpd_sys_content_t /home/WeeWX/public_html

Then, let’s start up the Apache web server, and enable it to start on each boot.

systemctl enable --now httpd

If you’d like to be able to access the site from beyond the actual machine WeeWx is running on, you’ll need to allow the http service through the firewall.

firewall-cmd --zone=public --add-service=http --permanent
firewall-cmd --reload

For me, I am only able to talk to this machine from within my local network and not from the public internet. Making the WeeWx website viewable outside your local network is beyond the scope of this HowTo.

Next up, you have a choice. WeeWx can store data in either SQLite, or MySQL/MariaDB. If you’re not sure what you need, skip this step and allow Weewx to create and use SQLite. The WeeWx Wiki has a good article on the topic. Personally, I store my data in MySQL. And this next section is how I prep the MariaDB server on the WeeWx Machine.

We installed MariaDB earlier in the group of packages we grabbed, so we need only enable and start it now.

systemctl enable --now mariadb

After that it’s good practice to secure your installation.


Next, we need to build a blank database for WeeWx to populate. First, we log into the database using the password you hopefully set in the previous step.

mysql -u root -p

Next we create a user, and grant it access to it.

CREATE USER 'WeeWX'@'localhost' IDENTIFIED BY '[yourpasswordhere]';
GRANT select, update, create, delete, insert, drop ON WeeWX.* TO WeeWX@localhost;

Now, we need to tell WeeWx to load data into MySQL, not SQLite, and what user and password to use for MySQL. To do that, open your weewx.conf file:

vi /home/weewx/weewx.conf

In that file, look for the section called ‘DataBindings’, and then make sure you have the correct settings for ‘database’, ‘table_name’, ‘manager’, and ‘schema’. By default, the system is setup for SQLite, so you’ll need to make sure you’re telling the system to use your database, and not the SQLite database.

        # The database must match one of the sections in [Databases].
        # This is likely to be the only option you would want to change.
        database = archive_mysql
        # The name of the table within the database
        table_name = archive
        # The manager handles aggregation of data for historical summaries
        manager = weewx.manager.DaySummaryManager
        # The schema defines the structure of the database.
        # It is *only* used when the database is created.
        schema = schemas.wview_extended.schema

In the same weewx.conf file look for [Database Types], and enter the username and password you created in the previous steps.

    # Defaults for MySQL databases
        driver = weedb.mysql
        # The host where the database is located
        host = localhost
        # The user name for logging in to the host
        user = weewx
        # The password for the user name (quotes guard against parsing errors)
        password = [yourpasswordhere]

Next up, we have WeeWx talk to our database and create the schema it needs. This is how WeeWx defines the data fields it will populate with data, and it couldn’t be more simple to accomplish. WeeWx has very kindly provided a small app to handle this, and many different database tasks.

wee_database --create

I did say it was easy.

Though I should mention that wee_database, and other similar executables, live in /home/weewx/bin/. When I am managing this system I normally goto /home/weewx, and run things from there. So, for me, I’d execute the above command like this.

bin/wee_database --create

With that done, you’re ready to actually configure WeeWx.


This will step you through a wizard that will ask about your location, elevation and weather station information.

If you’re in the planning stages of your WeeWx system you can select ‘Simulator’ as the station type and WeeWx will generate data to enter into your system so you can see things work, plan you visualizations, etc.

Once you’ve completed that wizard, you’re finally ready to start weewx and let it run.

As a test, run the command to launch it and let it run for 10 minutes. That will be enough time for it to gather some data and generate the various web outputs. To do this, for this testing phase, simply run the weewxd command.

bin/weewxd --config /home/weewx/weewx.conf

After 10 minutes, open a web browser and take a look at the weewx default website you’ve generated.


After that is working, you can stop the weewx process (by pressing ‘control+c’)and get your machine setup to run it automatically.

First step is to create the systemd service file you need to tell your system about WeeWx, and how to run it.

vi /etc/systemd/system/weewx.service

The file I use is very similiar to the one found in /home/weewx/util/systemd, but tweaked slightly.

# systemd configuration for weewx

Description=weewx weather system

ExecStart=/home/weewx/bin/weewxd --daemon --pidfile=/home/weewx/ /home/weewx/weewx.conf
ExecReload=/bin/kill -HUP $MAINPID


Then, we tell Centos to enable that service on boot and we get it started.

systemctl enable --now weewx

I usually then also take a look at the system log to make sure it’s running as I expect it. On Centos 8, we use journalctl for that and the ‘-f’ operator tells the output to keep updating our display as new messages come in.

journalctl -f

Lookin’ good? Great. Hit ‘Control+c’ to drop out of the journal.

What a ride! WeeWx is up and running. I like to do a reboot just to make sure everything comes up properly on boot and then you’re off and running.

I have some more posts coming to talking about how I setup a software defined radio (SDR) to grab weather data from some cheap Acurite sensors. Which is how I was able to get some reasonably accurate weather data while living in our apartment.

Leave a Reply

Your email address will not be published.

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