centos安装node18
curl -fsSL https://rpm.nodesource.com/setup_18.x | sudo bash - sudo yum install -y nodejs node --version npm --version
如果装不上,直接放弃!
用docker运行即可:
dockerfile:
# 使用官方Node.js 18镜像 FROM node:18 # 设置工作目录 WORKDIR /app # 暴露容器的端口号 EXPOSE 3000 # 运行项目 CMD ["node", "/app/server/index.mjs"]
docker-compose.yml:
version : '3' services: mysql: container_name: mysql image: docker.m.daocloud.io/mysql:5.7 build: context: ./mysql ports: - "13306:3306" volumes: - ./mysql/conf/my.cnf:/etc/mysql/my.cnf - ./mysql/logs:/logs - ./mysql/data:/var/lib/mysql - ./mysql/init-sql/:/docker-entrypoint-initdb.d command: [ '--character-set-server=utf8mb4', '--collation-server=utf8mb4_general_ci', '--max_allowed_packet=128M', '--innodb-buffer-pool-size=256M', '--default-time-zone=+08:00' ] environment: MYSQL_USER: 'xxx' MYSQL_PASSWORD: 'xxx' MYSQL_DATABASE: 'xxx' MYSQL_ROOT_PASSWORD: 'xxx' restart: always redis: image: docker.m.daocloud.io/redis restart: always hostname: redis container_name: redis ports: - 16379:6379 command: redis-server /etc/redis/redis.conf environment: TZ: Asia/Shanghai volumes: - ./redis/redis.conf:/etc/redis/redis.conf - ./redis/data:/data - ./redis/logs:/logs porsche-api: hostname: porsche-api container_name: porsche-api image: porsche-api build: context: porsche-api dockerfile: Dockerfile ports: - "9000:8000" extra_hosts: - "host.docker.internal:host-gateway" logging: driver: "json-file" options: max-size: "100m" max-file: "10" restart: always bulgari-allegra-nuxt: hostname: bulgari-allegra-nuxt container_name: bulgari-allegra-nuxt image: node:18 build: context: bulgari-allegra-nuxt dockerfile: Dockerfile volumes: - /root/bulgari-allegra-nuxt/:/app ports: - "3000:3000" extra_hosts: - "host.docker.internal:host-gateway" logging: driver: "json-file" options: max-size: "100m" max-file: "10" restart: always
============ 欢迎各位老板打赏~ ===========
与本文相关的文章
- · vue/react/node/vite/npm/yarn build自动更新版本号
- · CentOS 安装Docker-CE
- · centos yum安装Python3.8(史上最简单)
- · centos安装chrome+chromedriver
- · CentOS下使用tcpdump网络抓包用
- · centos 7安装kubectl
- · 整理 node-sass 安装失败的原因及解决办法
- · CentOS在线安装RabbitMQ3.7
- · Hadoop学习教程(二) —- CentOS下安装JDK
- · CentOS下VMware用桥接模式,静态ip上外网
- · CentOS 6.x 一键安装PPTP VPN脚本
- · centos lamp一键安装包 下载