Compiled uWebSockets.js binaries and instructions for those running on Centos7
This repository is made for all the WHM admins and cPanel fans out there who want to installed uWebSockets.
Getting uWS to run on Centos 7 is not easy even for seasoned cPanel users. Although Centos 7 is a matured and robust OS normally used for running WHM and cPanel, it often contains dated dependencies that are just not quite enough to allow a proper install of uWS. I went through this struggle and would like to give some tips on how it can be done. Before we begin, I would like to say that you must be a system admin with WHM and terminal access in order for this tutorial to work.
uWebSockets is a powerful implementation of websockets for Node.js back-ends. I am very grateful to the author for the ever-improving code. Unfortunately, the binaries provided by default do not suffice and I have faced similar issues like these before:
Can't run uWebSockets on CentOS 7 with glibc-2.17
How enable c99 mode in gcc with terminal
GLIBC_2.18 not found (uws_linux_x64_72.node)
In other words, you happily install uWS and when you run your first program, nothing works out and you may end up getting stuck for days. When I solved this issue, figuring it out was not easy but I am here to make this process easier for myself and others in the future.
Disclaimer: You understand and accept all risks as your own when performing any procedure in this document. You acknowledge that you have backups of your system in case of any complications. The author shall not be responsible for any loss/damage due to this repository.
Before you follow the Installation Guide, you will obviously need an installation of NodeJS and NPM. Don't have those? Follow these instructions.
yum install ea-nodejs10
ln -s /opt/cpanel/ea-nodejs10/bin/npm /usr/local/sbin/npm
ln -s /opt/cpanel/ea-nodejs10/bin/node /usr/local/sbin/node
ln -s /opt/cpanel/ea-nodejs10/bin/npm /usr/sbin/npm
ln -s /opt/cpanel/ea-nodejs10/bin/node /usr/sbin/node
node -v
and check NPM by running npm -v
to see the version installed.For convenience, I have compiled a binary of uWebsockets.js (at the moment v18) in this repository that will work on Centos 7, if that is all you want. For those who want to build their own binary and install, follow these instructions:
git clone --recursive https://github.com/uNetworking/uWebSockets.js.git
cd uWebSockets.js
// Change from
build("clang", "clang++", "-static-libstdc++ -static-libgcc -s", OS, "x64");
// To this
build("gcc", "g++", "-static-libstdc++ -static-libgcc -s", OS, "x64");
make
command. If no errors, you should find the compiled binary in uWebSockets.js/dist/uws.js
sudo yum install centos-release-scl
sudo yum-config-manager --enable rhel-server-rhscl-7-rpms
sudo yum install devtoolset-7
scl enable devtoolset-7 bash
gcc --version
node_modules
folder and start coding away.uWebSockets Official Repository
Introduction to uWebSockets
Install Dev Toolset 7 (for newer GCC compiler)