- Download WSL then enable WSL2
- There are several distros:
- CentOS-WSL (by mishamosher) : CentOS based on qcow2 image
- FedoraWSL (by yosukes-dev) : Fedora on WSL
- RHWSL (by yosukes-dev) : RedHat UBI on WSL
- Download and execute the included exe file
Add USER
.
adduser USER
Set passwd for USER
. Type in the password twice to confirm it.
passwd USER
Add USER
to GROUP
.
usermod -aG GROUP USER
Grant sudo
privileges to USER
by adding the user to the wheel
group
usermod -aG wheel USER
Add USER
to sudoers file
echo "USER ALL=(ALL) NOPASSWD:ALL" | sudo tee /etc/sudoers.d/USER
echo "USER ALL=(ALL) NOPASSWD:/var/www/,/usr/bin/" | sudo tee /etc/sudoers.d/USER
Switch to another USER
su USER
yum -y update
yum -y groupinstall "Development Tools"
yum -y install gcc openssl-devel bzip2-devel libffi-devel wget epel-release
# Upgrade Git to latest version
yum -y remove git*
yum -y install https://packages.endpointdev.com/rhel/7/os/x86_64/endpoint-repo.x86_64.rpm
yum -y install git
# Change default branch name to main
git config --global init.defaultBranch main
# install Python 3.8
sudo yum -y install centos-release-scl-rh
sudo yum -y install rh-python38
sudo yum -y install rh-python38-python-devel rh-python38-python-tkinter rh-python38-python-numpy rh-python38-python-jinja2 rh-python38-python-scipy
# reference: https://access.redhat.com/solutions/527703
source scl_source enable rh-python38
echo "source scl_source enable rh-python38" >> ~/.bashrc
https://nablacfd.github.io/2019/01/27/Notes-of-installing-slurm-in-Ubuntu-WSL/
Not tested yet
https://www.jenkins.io/doc/book/installing/linux/#red-hat-centos
Requires enabling systemctl.
sudo wget -O /etc/yum.repos.d/jenkins.repo \
https://pkg.jenkins.io/redhat-stable/jenkins.repo
sudo rpm --import https://pkg.jenkins.io/redhat-stable/jenkins.io.key
sudo yum upgrade
# Add required dependencies for the jenkins package
sudo yum install java-11-openjdk
sudo yum install jenkins
sudo systemctl daemon-reload
https://stackoverflow.com/questions/61110603/how-to-set-up-working-x11-forwarding-on-wsl2
Both Windows and CentOS requires configuration. CentOS 7 was used.
Windows Setup:
-
Install Xming and execute it.
-
From Windows Defender Firewall -> Advanced Setting -> Inbound Rules, double click on oPublic inbound rules to open up their properties.
-
Under General Tab, select Allow the connection.
Create a new rule to restrict TCP 6000 connection to X11 on WSL2
-
Under Actions menu, click New Rule...
-
You will be asked to select Rule Type. Select Port.
-
For Protocol and Ports, select TCP and specific local port 6000
-
Proceed with default or desired options and give this rule a name, for example: "TCP 6000 for X11 on WSL"
-
Edit properties of this newly create rule ("TCP 6000 for X11 on WSL"). Under Scope tab Remote IP address panel, select Theses IP addresses then Add IP address 172.16.0.0/12.
-
Launch Xming with
-ac
option."C:\Program Files (x86)\Xming\Xming.exe" :0 -clipboard -multiwindow -ac
CentOS Setup:
-
Install
xrdp
sudo yum -y install xrdp
-
Enable systemctl and start
xrdp
sudo systemctl start xrdp
-
Setup
.bashrc
to automatically setDISPLAY
:echo "export DISPLAY=$(cd /mnt/c && route.exe print | grep 0.0.0.0 | head -1 | awk '{print $4}'):0.0" >> ~/.bashrc
systemctl
is disabled by default in WSL2. There are multiple workarouds however.
Here is an example of wrapping systemctl
with Python2 but does not work for those services explicitly require systemd.
https://superuser.com/questions/1556609/how-to-enable-systemd-on-wsl2-ubuntu-20-and-centos-8
sudo mv /usr/bin/systemctl /usr/bin/systemctl.old
sudo curl https://raw.githubusercontent.com/gdraheim/docker-systemctl-replacement/master/files/docker/systemctl.py > /usr/bin/systemctl
sudo chmod +x /usr/bin/systemctl