# OpenCloudOS Server 8 配环境 (January 22, 2023)

因为<font style="color:rgba(0, 0, 0, 0.9);">OpenCloudOS的yum源的问题，所以最好先安装这个包</font>

```bash
yum install epel-release -y
```

然后安装一个`htop`和`screen`

```bash
yum clean all
yum update
yum install htop
yum install screen
```

安装`Node.js`

```bash
yum install nodejs
```

安装`python3.11`

```bash
./configure --enable-optimizations --with-lto --enable-bolt
make
make install
```

配置`pip`镜像源

```bash
pip config set global.index-url https://mirrors.cloud.tencent.com/pypi/simple
```

配置`npm`镜像源

```bash
npm install -g nrm
```

用`nrm`换源

```bash
[root@VM-16-16-opencloudos ~]# nrm ls

  npm ---------- https://registry.npmjs.org/
  yarn --------- https://registry.yarnpkg.com/
  tencent ------ https://mirrors.cloud.tencent.com/npm/
  cnpm --------- https://r.cnpmjs.org/
  taobao ------- https://registry.npmmirror.com/
  npmMirror ---- https://skimdb.npmjs.com/registry/

[root@VM-16-16-opencloudos ~]# nrm use tencent

   Registry has been set to: https://mirrors.cloud.tencent.com/npm/

```

安装python时遇到常见问题的解决方案

```diff
  Some possibly relevant errors from pip install:
      error: subprocess-exited-with-error
-     ModuleNotFoundError: No module named '_ctypes'
      error: metadata-generation-failed
 
  Error installing poetry.
```

需要安装一个库

```bash
yum install libffi-devel -y
```

重新安装，在`make`一步出现了这样的报错

```plain
The necessary bits to build these optional modules were not found:
_bz2                  _dbm                  _gdbm
_hashlib              _lzma                 _ssl
_tkinter              _uuid                 nis
readline
To find the necessary bits, look in setup.py in detect_modules() for the module's name.


The following modules found by detect_modules() in setup.py have not
been built, they are *disabled* by configure:
_sqlite3


Could not build the ssl module!
Python requires a OpenSSL 1.1.1 or newer
```

参考网上的文章，要安装这些依赖

```bash
yum groupinstall "Development Tools"
yum install zlib-devel bzip2-devel ncurses-devel sqlite-devel readline-devel tk-devel gdbm-devel libpcap-devel xz-devel uuid-devel
yum install sqlite*
yum install -y zlib openssl-devel sqlite-devel bzip2-devel libffi libffi-devel gcc gcc-c++
```

在`~/swapfiles`下创建3GB的`swap`

```bash
dd if=/dev/zero of=./swap-1024x3000000 bs=1024 count=3000000
chmod -R 0600 ./swap-1024x3000000
mkswap ./swap-1024x3000000
swapon ./swap-1024x3000000
echo "/root/swapfiles/swap-1024x3000000 swap swap defaults 0 0" >> /etc/fstab
```

配置`JupyterLab`密码

```bash
jupyter server --generate-config
jupyter server password
```

安装`gh`

```bash
yum install yum-utils
yum-config-manager --add-repo https://cli.github.com/packages/rpm/gh-cli.repo
yum install gh
```