PLC Tutorial 1: OpenPLC Installation on Linux, From git clone to a Running Soft PLC

Share:
PLC Tutorials
PLC Tutorial 1: OpenPLC Installation on Linux, From git clone to a Running Soft PLC

OpenPLC turns an ordinary Ubuntu PC into a soft PLC that you program in ladder logic and control from a browser. We install it from scratch, start it, log in and check the default settings before any program is written.

Ubuntu 24.04 install.sh linux Port 8080 Modbus 502 Real Screenshots

Install the free OpenPLC runtime on Ubuntu, start it and log in to its web dashboard. Every screenshot comes from a real install we ran for this lesson, with the commands, timings and default ports.

Hello everyone, today we are going to do an OpenPLC installation on Linux and start the first lesson of our PLC Tutorials series.
openplc installation on linux
Quick Answer

How do you do an OpenPLC installation on Linux?

OpenPLC installation on Linux takes one script: clone the OpenPLC_v3 repository and run ./install.sh linux, which builds the compiler, protocol libraries and runtime. On our 2 core Ubuntu 24.04 test machine it finished in about 4 to 6 minutes. Then start the runtime, open localhost:8080 in a browser and log in with openplc and openplc.

  1. sudo apt update and install git.
  2. git clone https://github.com/thiagoralves/OpenPLC_v3
  3. cd OpenPLC_v3 and run ./install.sh linux
  4. Start it with the openplc service or ./start_openplc.sh
  5. Open localhost:8080 and log in as openplc / openplc.
  6. Change the default password under Users.

What Is OpenPLC and Why Install It on Linux?

OpenPLC is a free, open source soft PLC that runs IEC 61131 3 programs on a normal computer, and an OpenPLC installation on Linux gives you a working controller with a browser dashboard. You can practise ladder logic, test Modbus and run real programs without buying hardware.

Key Facts
  • One command builds everything: ./install.sh linux.
  • Web dashboard on port 8080, default login openplc / openplc.
  • Modbus TCP server on port 502 is enabled by default.
  • Our install on Ubuntu 24.04 took about 4 to 6 minutes.

PLC Tutorials series: this is lesson 1. The series continues lesson by lesson, from the first ladder program to timers, counters, analog scaling, PID and Modbus, and every lesson is tested on the runtime you install today.

If PLCs are new to you, read what a PLC is first. A soft PLC does the same job in software, and our list of free PLC programming software compares it with other free options.

Advertisement

What Do You Need Before You Start?

For an OpenPLC installation on Linux you need a 64 bit Ubuntu or Debian based PC or virtual machine, an internet connection and a user with sudo rights. We tested on Ubuntu 24.04 with 2 CPU cores, and the script pulled its own build tools.

ItemWhat we usedNote
Operating systemUbuntu 24.04Debian based distros use apt
CPU2 coresMore cores build faster
Accesssudo or rootScript installs packages
NetworkInternetgit and apt downloads
BrowserAny modern browserDashboard on port 8080

The installer adds build tools such as gcc, cmake, bison and flex, plus sqlite3 and a Python virtual environment for the web server. You do not need to install them by hand first.

Do You Know?

The OpenPLC webserver is a Python Flask app. When you upload a program, it calls the MatIEC compiler to turn Structured Text into C code and then builds a fresh runtime binary.

How Does the OpenPLC Runtime Work on a PC?

The runtime is a C++ program that scans your PLC logic in a loop, while a web server lets you upload programs and start or stop the PLC. Field signals come in through a hardware layer, and SCADA or HMI software reads data over Modbus TCP, EtherNet/IP or the S7 protocol.

openplc installation on linux architecture diagram with webserver compiler and protocol ports
Diagram by Instrumentation Blog showing the OpenPLC runtime on Linux: browser and editor feed the webserver, iec2c and g++ build the PLC core, and protocol servers listen on their ports.

Your .st file goes to the webserver, iec2c converts it to C, and g++ links it into the runtime. The PLC core then reads inputs, solves the logic and writes outputs every scan, the same cycle explained in how the PLC scan cycle works.

Quick Tip

The hardware layer decides where inputs and outputs come from. A fresh install uses the blank Linux layer, so the PLC runs but nothing is wired to it yet.

OpenPLC Installation on Linux Step by Step

The whole OpenPLC installation on Linux is a clone and one script, followed by a start command. Run the commands below in a terminal, one line at a time.

1
Update packages
sudo apt update, then sudo apt install git if git is missing.
2
Clone the runtime
git clone https://github.com/thiagoralves/OpenPLC_v3
3
Run the installer
cd OpenPLC_v3, then ./install.sh linux. Keep the terminal open.
4
Wait for success
The log must end with Compilation finished successfully!
5
Start the runtime
sudo systemctl start openplc, or ./start_openplc.sh from the folder.
6
Open the dashboard
Browse to http://localhost:8080 on the same PC.

The script builds the MatIEC compiler, the ST optimizer, the glue generator, OpenDNP3, libmodbus and snap7, then compiles a blank program as a self test. It also writes everything it prints into install_log.txt in the same folder, which is the first file to read if anything fails.

terminal with openplc install log success and start script running webserver on port 8080
Screenshot by Instrumentation Blog from our OpenPLC install: the end of install_log.txt and ./start_openplc.sh bringing up the webserver on port 8080.

In linux mode the script also creates and enables a systemd service called openplc, so the runtime starts by itself after a reboot. On a container or WSL without systemd you see a harmless "System has not been booted with systemd" line, and you start the runtime with ./start_openplc.sh instead.

The start script runs the Flask webserver from a Python virtual environment inside the folder. The log above shows it listening on port 8080 for the dashboard and on port 8443 over HTTPS for the REST API.

Advertisement

How to Log In to the OpenPLC Dashboard

Open http://localhost:8080 and log in with username openplc and password openplc. From another computer on the same network, use the PC IP address followed by :8080.

openplc webserver login page on port 8080 after installation
Screenshot by Instrumentation Blog from the OpenPLC Webserver login page after a fresh install, with the release date printed under the login box.

After login you land on the Dashboard with the Blank Program loaded and the status Stopped. Press Start PLC in the left menu, and the runtime log fills with the protocol servers coming up.

openplc dashboard with blank program running and runtime logs
Screenshot by Instrumentation Blog from the OpenPLC Dashboard after Start PLC, with the Blank Program running and the runtime log listing Modbus on 502 and EtherNet/IP on 44818.

Read the runtime log line by line once. It tells you which servers started, which ports they use and whether slave devices were configured, and you will use it again in every later lesson.

Do You Know?

Ports below 1024, such as Modbus port 502, can only be opened by a privileged process on Linux. That is one reason the OpenPLC service runs as root.

Which Default Settings Should You Check First?

Check the Settings page right after the OpenPLC installation on Linux, because it decides which protocols listen on the network. On our fresh install Modbus, S7 and EtherNet/IP were on, while DNP3, persistent storage and start in RUN mode were off.

openplc settings page with modbus server port 502 enabled
Screenshot by Instrumentation Blog from the OpenPLC Settings page with the default protocol options: Modbus on port 502, S7 enabled, DNP3 off and EtherNet/IP on port 44818.
SettingDefaultWhen to change
Modbus serverOn, port 502Keep on for monitoring and HMI
S7 protocolOnTurn off if unused
DNP3 serverOff, port 20000Only for DNP3 masters
EtherNet/IPOn, port 44818Turn off if unused
Persistent storageOff, 10Turn on for retained values
Start in RUN modeOffTurn on for unattended PCs
Slave polling and timeout100 ms, 1000 msTune for slow RTU devices

Leave Modbus on: the Monitoring page reads live values through it, and our later lessons depend on that. If the Modbus server is off, Monitoring only shows a message asking you to enable it.

Turn on Start OpenPLC in RUN mode only on a PC that must resume control after a power cut. For a learning machine, starting in Stop is safer because you decide when the program runs.

How Do OpenPLC Addresses Map to Modbus?

OpenPLC maps every located variable to a fixed Modbus address, so an HMI or SCADA package can read and write it without extra setup. Bits use byte x 8 + bit, and words use their own number, with %MW offset by 1024.

openplc modbus address map table with coil and holding register examples
Diagram by Instrumentation Blog showing the OpenPLC to Modbus address map for %IX, %QX, %IW, %QW and %MW, with the solved examples %QX2.5 as coil 21 and %MW10 as holding register 1034.
Coil = byte x 8 + bit
%QX2.5: 2 x 8 + 5 = coil 21
Holding register = 1024 + n
%MW10: 1024 + 10 = register 1034

These are zero based protocol addresses, the numbers a Modbus client sends on the wire. Some HMI packages show them with a 1 based or 40001 style offset, which the Modbus register map guide explains, along with the Modbus function codes used to read each table.

Use the calculator to convert any OpenPLC bit or memory word before you configure a client.

OpenPLC Modbus Address Calculator
Modbus addresses
%IX2.5 is discrete input 21, %QX2.5 is coil 21 and %MW10 is holding register 1034.

For a wider view of PLC addressing schemes, see PLC memory addressing.

Advertisement

Siemens and Allen Bradley Equivalents

Siemens and Allen Bradley do not offer a Linux soft PLC for learning; their programming tools run on Windows. Siemens uses TIA Portal with PLCSIM to simulate S7 CPUs, and Rockwell uses Studio 5000 with an emulator for Logix controllers.

Why learn on OpenPLC first
  • Free, open source and runs on Linux
  • IEC 61131 3 languages: LD, FBD, ST, IL and SFC
  • Real Modbus TCP server for HMI practice
What it does not replace
  • Vendor specific instructions and diagnostics
  • Certified safety PLCs
  • Hardware configuration of real racks and cards

The ladder logic you learn here carries over, because all three follow the same IEC 61131 3 programming languages ideas. When you move to vendor hardware, compare families in S7 1200 vs S7 1500 and types of Allen Bradley PLCs.

Common Installation Problems and Fixes

Most failed attempts at an OpenPLC installation on Linux come from a blocked package manager, a missing build tool or a port already in use. Follow this flowchart and read install_log.txt before running the script again.

flowchart of openplc install steps from git clone to first login
Diagram by Instrumentation Blog showing a flowchart of the OpenPLC install: update Ubuntu, clone, run install.sh, check for success, start the runtime, open port 8080, log in and change the password.
SymptomLikely causeFix
Could not get lock on dpkgAnother apt process runningWait for it, run install.sh again
Error compiling MatIECBuild tools missingCheck apt output in the log
localhost:8080 does not openRuntime not startedStart the service or script
Address already in useOld runtime still runningStop it, then start again
Monitoring asks for ModbusModbus server disabledEnable it in Settings
Myth: OpenPLC needs special PLC hardware.
Fact: It runs on a normal Linux PC; hardware layers for boards are optional.
Myth: The systemd error means the install failed.
Fact: Only the service step failed; the log still ends with a successful compile.
Myth: The default login is fine on a plant network.
Fact: Anyone who knows openplc / openplc can upload a program, so change it at once.
  • install_log.txt ends with Compilation finished successfully!
  • Dashboard opens on port 8080.
  • After Start PLC the status reads Running.
  • Modbus server is enabled on port 502.
  • Default password changed under Users.
Quick Tip

Run only one apt task at a time. A second apt command during install.sh locks dpkg and the installer skips its package step.

Treat the dashboard like any PLC engineering port: keep it off the internet, change the password and segment the network, as covered in PLC remote access security and cybersecurity standards for PLCs.

PDF
Security Issues on the OpenPLC Project and Corresponding Solutions (PDF)
Thesis on OpenPLC runtime security, default accounts, HTTP access and hardening

The video below shows an OpenPLC installation on Linux step by step. Pause it after the installer finishes and compare your log with ours.

Next you will write programs in ladder logic, so revise ladder logic for beginners and the PLC programming languages. Then test yourself with our PLC objective quiz.

OpenPLC Installation on Linux FAQ

How long does OpenPLC installation on Linux take on a normal PC?

On our 2 core Ubuntu 24.04 machine the script finished in about 4 to 6 minutes. Most of that time goes into compiling OpenDNP3 and the other libraries.

A faster CPU shortens it, and a slow internet link lengthens the package step.

What is the default username and password for the OpenPLC runtime?

The default login is username openplc and password openplc. You enter it on the login page at port 8080 after the runtime starts.

Change it under Users right after the first login, because anyone with these details can upload, start and stop a program.

Which port does the OpenPLC web dashboard use after installation?

The dashboard listens on port 8080, so you open http://localhost:8080 on the same PC. From another computer on the same network, use the PC IP address with :8080.

The runtime also serves a separate REST API over HTTPS on port 8443.

How do I start OpenPLC automatically when Linux boots?

In linux mode the installer creates and enables a systemd service named openplc, so it starts at boot. Check it with sudo systemctl status openplc.

To also run the program at boot, tick Start OpenPLC in RUN mode in Settings.

Why does the OpenPLC Monitoring page ask me to enable Modbus?

The Monitoring page reads live values through the runtime Modbus server. If the Modbus server is disabled in Settings, the page shows that message instead of the live table.

Enable the server on port 502, save the changes, and open Monitoring again.

Can I install OpenPLC on Windows or Raspberry Pi instead of Linux?

Yes, the same install.sh has options for Windows, Raspberry Pi and Docker. The steps after installation, the web dashboard and the default login stay the same on each platform.

A later lesson in this series covers the Raspberry Pi hardware layer in detail.

Advertisement

Related Articles

External References

What We Learn Today

  • OpenPLC installation on Linux is a git clone and one script, ./install.sh linux, which builds the compiler, protocol libraries and the runtime itself.
  • The dashboard runs on port 8080 with the default login openplc and openplc, and that password should be changed right after the first login.
  • OpenPLC maps bits to Modbus as byte x 8 + bit, so %QX2.5 is coil 21, and %MW words start at holding register 1024.
Advertisement
I hope you like above blog. There is no cost associated in sharing the article in your social media. Thanks for reading!! Happy Learning!!
Sunayana Gadepatil, author at Instrumentation Blog
Author · instrumentationblog.in
Ms. Sunayana Gadepatil is an instrumentation professional, technical writer, and the author behind Instrumentation Blog. With a strong interest in industrial instrumentation, process measurement, and automation, she specializes in simplifying complex technical concepts into clear, practical, and easy to understand insights. Through her articles, Ms. Sunayana shares valuable knowledge on flow, pressure, level, temperature, control systems, and industrial automation for engineers, students, technicians, and industry professionals.
Technically reviewed on

Leave a Reply

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

Support free learning

Help keep every guide, calculator and tool 100% free

Hosting, software and hours of research go into every article. Even a small contribution helps us publish more in-depth guides for students, technicians and engineers.

  • No paywalls
  • No sign up
  • Free for everyone