These instructions explain how to manually install, enable, start, stop, and uninstall systemd services for X4-Server.
Note:
These instructions replace the previous automatic service setup. Since X4 7.5.0, the Linux installation packages (ZIP, DEB, RPM) no longer register the X4-Server as a system service and no longer contain service files. You can create these files yourself with the commands on this page.
The instructions apply to one service unit:
-
X4-Server
The commands work on most modern Linux distributions that use systemd (e.g. RHEL 8/9, Debian 11+/12+, Ubuntu 20.04+). The instructions assume that X4 is installed in /opt/X4, which is the default for the DEB and RPM packages. Run all commands as:
-
rootor withsudo
Prerequisites for ZIP installations
The DEB and RPM packages perform these steps during installation. If you installed X4 from the ZIP archive, run them once before you create the service. Replace <version> with your X4 version.
mkdir -p /opt/X4
unzip X4_Server_Linux-<version>.zip -d /opt/X4
getent passwd X4 >/dev/null || useradd -r -U -d /opt/X4 X4
grep -q '^X4_INSTALL_PATH=' /etc/environment || echo 'X4_INSTALL_PATH=/opt' >> /etc/environment
find /opt/X4 -name '*.sh' -exec chmod +x {} \;
chmod +x /opt/X4/jdk/bin/* /opt/X4/jdk/lib/jspawnhelper /opt/X4/apache-maven/bin/*
chown -R X4:X4 /opt/X4
Note: Without these steps, X4_INSTALL_PATH is not set in /etc/environment and the service cannot start.
Creating the service files
The service consists of two files:
-
/etc/default/X4-Server– environment file with the X4, Java and WildFly settings -
/etc/systemd/system/X4-Server.service– systemd unit file
Create the environment file: /etc/default/X4-Server
Create the environment file and adjust the memory settings (-Xms, -Xmx) to your system as needed.
Create the unit file: /etc/systemd/system/X4-Server.service
Note: If X4 is not installed in /opt/X4 (e.g. DEB with INSTALL_PATH, RPM with --prefix), replace /opt/X4 in WorkingDirectory, ExecStart, ExecStop and ExecReload with your installation directory.
Activating and starting the service
-
Reload
systemdto recognize the new unit files. -
Then enable the services to run automatically when the system starts. Optionally, you can start it immediately.
# Make systemd aware of new/changed unit file
systemctl daemon-reload
# Start X4-Server automatically at boot
systemctl enable X4-Server
# Start X4 Server now (optional)
systemctl start X4-Server
Checking the installation
Check the current status and the last log entries of the services:
systemctl status X4-Server --no-pager
journalctl -u X4-Server -b --no-pager | tail -n 50
Note:
If the service does not start, check the log output and the following files:
-
/etc/default/X4-Server -
/etc/environment(must containX4_INSTALL_PATH)
Uninstalling the service
Complete the following steps to remove the services and all service files before you uninstall the X4 package.
# Stop and disable X4-Server
systemctl stop X4-Server || true
systemctl disable X4-Server || true
# Remove the unit file and the environment file
rm -f /etc/systemd/system/X4-Server.service
rm -f /etc/systemd/X4-Server
# Make systemd forget the removed unit
systemctl daemon-reload
systemctl reset-failed
Note: The file name /etc/default/X4-Server is case-sensitive.
Troubleshooting tips
|
Action |
Command |
|---|---|
|
Reload system after every change to the unit file |
|
|
Show the unit definition that systemd uses |
|
|
Display recent log output |
|
|
Restart the service and check its status |
|
-
File permissions: the unit file and
/etc/default/X4-Servershould be owned byroot:rootwith mode0644. -
SELinux: if SELinux is active, adjust the labels if necessary (for example with
restorecon) or move the files to default paths. -
Network access: make sure the required ports are open (
firewalld,ufw,iptables). -
Message
cannot create /run/X4-Server/X4-Server.pid: Directory nonexistent: harmless; starting, restarting and stopping the service work regardless. -
Message
/X4/jdk/bin/java: not found:X4_INSTALL_PATHis missing from/etc/environment; see prerequisites.
Differences from the previous automatic installation
Up to X4 7.4, the DEB and RPM packages installed the service files, set ownership and permissions, ran systemctl daemon-reload, enabled the service and, on a fresh installation, started it. Since X4 7.5.0 the packages no longer do this. The commands on this page perform the same steps explicitly, can be adjusted to your need and can also be used in scripted deployments.
Appendix: Fast installation block
After you have created the service files (and, for ZIP installations, completed the prerequisites), you can enable and start the service with one command:
systemctl daemon-reload && systemctl enable --now X4-Server
The service then starts automatically at every boot.