How to install XMRig CPU miner in CentOS 7

by Daniel Pham
Published: Updated:

This article will show you how to install XMRig CPU miner in CentOS 7. This is probably an article about a topic that I rarely do.

What is XMRig CPU miner?

For those of you who don’t know what XMRig is. This is a tool used for mining XMR electronic currencies (or co-based XMR based algorithms).

You can read more about this tool here.

Install with the getpagespeed repository

Warning: I personally do not trust the XMRig package from the getpagespeed repository. It has been changed according to the owner of the repository. We cannot know if anything else runs in the background.

This is the first way (link) I found it when I started trying to install XMRig in CentOS 7. After I installed it and configured the program to run, I found that even though I set up the donate-level parameter, it’s worth it. The program will still automatically set 3%.

By default, XMRig source code sets 5% donate to the developer but you can set it to 1%.

And this means that the person behind the getpagespeed repository has taken 3% of the excavator’s results without permission.

So, in my opinion, it is not reliable. Will they change any more?

Install XMRig from the source repository

Below, I will guide you to install it from source, step by step.

Prepare CentOS 7 server

The operating system I use is CentOS 7.6.1810 64bit, 1 GB RAM, 4 CPU, 20 GB HDD.

You need to disable SELinux on your computer, turn off firewalld and reboot the machine before installing XMRig.

Compile XMRig

First, we need to install some support packages.

yum install nano git make cmake gcc gcc-c++ libstdc++-static libmicrohttpd-devel libuv-static openssl-devel -y

Next, we need to install EPEL repository package.

yum install epel-release -y

Clone XMRig from Github. This ensures that the source code is not changed by anyone other than its developer.

git clone

Move into the source directory and create the build directory.

cd xmrig
mkdir build
cd build

Run the following 2 commands in turn to compile XMRig.

cmake .. -DCMAKE_BUILD_TYPE=Release -DUV_LIBRARY=/usr/lib64/libuv.a

Come here. You have finished compile the program. Now you can run the command to mining immediately. But we still need to do something else.

Make XMRig run as a service

The disadvantage when you run the command in the terminal window is that if you exit that window, the command will also stop. That means the XMRig program will stop.

We need to make it run as a service in CentOS 7.

make xmrig run as a service in centos 7
Make XMRig run as a service in CentOS 7.

First, copy the executable file we compiled above into the bin directory. And so you can call it as a command in CentOS 7.

cp xmrig /usr/local/bin/xmrig

Next, create the file /etc/systemd/system/xmrig.service to declare the service for XMRig.

nano /etc/systemd/system/xmrig.service

Copy the content below into the file and save it.

Description=XMRig Daemon

ExecStart=/usr/local/bin/xmrig -c /etc/xmrig/config.json -l /var/log/xmrig/xmrig.log -B


Next, reload the CentOS daemon and enable the xmrig service.

systemctl daemon-reload
systemctl enable xmrig

We have now finished the XMRig setup running as a service. But we can’t start it right away, we still have work to do.

You look in the xmrig.service file to see there are two directories, one for config.json and one for the program log. We need to create 2 directories.

mkdir /etc/xmrig
mkdir /var/log/xmrig

Create config.json file for the program

XMRig has two ways to run the program, run it directly from the command line or declare information into the config.json file.

We choose the second way, which allows you to easily reset mining information.

If you do not know how to create this file, you can go to the following web link and change your information. Or you can copy my content below.

Create the new file /etc/xmrig/config.json.

nano /etc/xmrig/config.json

Copy the following content to the json file.

    "algo": "cryptonight",
    "api": {
        "port": 0,
        "access-token": null,
        "worker-id": null,
        "ipv6": false,
        "restricted": true
    "av": 0,
    "background": false,
    "colors": false,
    "cpu-affinity": null,
    "cpu-priority": 0,
    "donate-level": 1,
    "huge-pages": true,
    "hw-aes": null,
    "log-file": "/var/log/xmrig/xmrig.log",
    "max-cpu-usage": 90,
    "pools": [
            "url": "",
            "user": "your-xmr-wallet-address",
            "pass": "workername:your-email",
            "keepalive": true,
            "nicehash": false,
            "variant": -1,
            "tls": false,
            "tls-fingerprint": null
    "print-time": 60,
    "retries": 5,
    "retry-pause": 5,
    "safe": false,
    "syslog": false,
    "threads": null

Explain about json file

  • "algo": "cryptonight": You need to do this if you want to mining XMR. You can see more algorithms and their corresponding coins here. For example, if you want to mining AEON, you must select the cryptonight-lite algorithm.
  • "max-cpu-usage": 90: The% CPU setting you want to use. XMRig documents recommend 75%. That is, if your device has 4 CPUs, it will use up to 3 CPUs. You keep changing these numbers to suit you.
  • "url": "": The URL to the pool you want to mining. Here, I leave port 80 because it will easily pass through the firewall of most systems.
  • "user": "your-xmr-wallet-address": Your XMR wallet address. If you want to use the address on the exchanges, the exchanges require a Payment ID address. You can enter the address here according to the format: wallet-address.payment-id-address. Connect by 1 dot.
  • "pass": "workername:your-email": You can put any name for the workername, which is used to distinguish if you have multiple machines. Your email address to be able to login to the dashboard of the pool and edit the withdrawal information.


So I have guided you step by step to install and successfully set up XMRig CPU miner in CentOS 7. Hope this is a useful article for you who are planning to mine coin, despite its price. Currently very low and almost no income.

(This is an article from my old blog that has been inactive for a long time, I don’t want to throw it away so I will keep it and hope it helps someone).

0 0 votes
Article Rating

You may also like

Notify of
Oldest Most Voted
Inline Feedbacks
View all comments
3 years ago

CMake Error at /usr/share/cmake/Modules/FindPackageHandleStandardArgs.cmake:108 (message):
Could NOT find UV (missing: UV_INCLUDE_DIR)

4 years ago

For fixing make error use this
sudo yum update -y
sudo yum install -y centos-release-scl epel-release
sudo yum install -y cmake3 devtoolset-8-gcc* hwloc-devel libmicrohttpd-devel openssl openssl-devel make git screen wget

DevOps Lite is a personal blog specializing in technology with main topics about DevOps, DevSecOps, SRE and System Administrator. Articles are shared for free and contributed to the community.



Subscribe my Newsletter for new blog posts. Stay updated from your inbox!

© 2021-2024 – All rights reserved.

Please write sources “” when using articles from this website.

This website uses cookies to improve your experience. We'll assume you're ok with this, but you can opt-out if you wish. Accept Read More

Would love your thoughts, please comment.x

Adblock Detected

Please support us by disabling your AdBlocker extension from your browsers for our website.