Table of Contents
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 -yNext, we need to install EPEL repository package.
yum install epel-release -yClone XMRig from Github. This ensures that the source code is not changed by anyone other than its developer.
git clone https://github.com/xmrig/xmrig.gitMove into the source directory and create the build directory.
cd xmrig
mkdir build
cd buildRun the following 2 commands in turn to compile XMRig.
cmake .. -DCMAKE_BUILD_TYPE=Release -DUV_LIBRARY=/usr/lib64/libuv.a
makeCome 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.

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/xmrigNext, create the file /etc/systemd/system/xmrig.service to declare the service for XMRig.
nano /etc/systemd/system/xmrig.serviceCopy the content below into the file and save it.
[Unit]
Description=XMRig Daemon
After=network.target
[Service]
Type=forking
GuessMainPID=no
ExecStart=/usr/local/bin/xmrig -c /etc/xmrig/config.json -l /var/log/xmrig/xmrig.log -B
Restart=always
User=root
[Install]
WantedBy=multi-user.targetNext, reload the CentOS daemon and enable the xmrig service.
systemctl daemon-reload
systemctl enable xmrigWe 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/xmrigCreate 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.jsonCopy 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": "pool.supportxmr.com:80",
"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 thecryptonight-litealgorithm."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": "pool.supportxmr.com:80": 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.
Conclusion
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).
CMake Error at /usr/share/cmake/Modules/FindPackageHandleStandardArgs.cmake:108 (message):
Could NOT find UV (missing: UV_INCLUDE_DIR)
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