CentOS9安装node pnpm nginx

2024-05-20 15:08:25

一、yum方式

0. 官方地址:https://rpm.nodesource.com
1. curl -sL https://rpm.nodesource.com/setup_20.x | bash -
2. yum install -y nodejs
3. npm install -g pnpm

二、设置docker开机启动

设置开机启动
systemctl enable docker.service

关闭开机启动
systemctl disable docker.service

三、Docker nginx容器目录挂载

1. 先拉取nginx镜像
docker pull nginx

2. 查看是否拉取成功
docker images

3. 使用命令在源主机上新建文件夹
mkdir -p nginx/{conf,html,log}

4. 启动临时nginx
docker run -d --name nginx_test nginx

5. 拷贝需要挂载的文件
docker cp nginx_test:/etc/nginx/conf.d /home/nginx/conf
docker cp nginx_test:/etc/nginx/nginx.conf /home/nginx/conf/nginx.conf
docker cp nginx_test:/usr/share/nginx/html/index.html /home/nginx/html/index.html

6. 删除临时nginx
docker rm -f nginx_test

7、创建挂载的nginx
docker run -d -p 80:80 --name nginx \
-v /home/nginx/conf/conf.d:/etc/nginx/conf.d \
-v /home/nginx/conf/nginx.conf:/etc/nginx/nginx.conf \
-v /home/nginx/html/index.html:/usr/share/nginx/html/index.html \
-v /home/nginx/log:/var/log/nginx \
nginx
验证:访问机器ip地址:127.0.0.1