下载安装 nvm 通过 nvm 安装 node 环境
下载安装 MySQL
下载安装 nginx
安装 Yarn 和 Git
一, 安装 nvm 配置 node
1, 下载 nvm
curl -o- https://raw.githubusercontent.com/creationix/nvm/v0.33.11/install.sh | bash
在 Linux 系统下, 执行完上面脚本, 在控制台中执行 nvm 命令, 会显示 nvm: command not found, 需要在终端执行:
command -v nvm
之后关闭终端, 打开新的终端页, nvm 已经可以使用.
2, 安装 node
- # 查看 node 版本
- nvm ls-remote
- ## 下载最新稳定版
- nvm install --lts # Latest LTS: Carbon
参考这里 https://github.com/creationix/nvm
二, 安装 MySQL
1, 安装 MySQL
注意: MySQL 8 有兼容问题, 没有预留时间成本的项目不建议使用 MySQL 8, 建议使用 MySQL 5.7
浏览器访问 MySQL 官方给出的 yum 下载列表.
https://dev.mysql.com/downloads/repo/yum/
复制上图 1 的路径替换下面的路径:
wget https://dev.mysql.com/get/mysql80-community-release-el7-1.noarch.rpm
根据 output 和图 2 的内容作比较, 验证包完整性:
- md5sum mysql80-community-release-el7-1.noarch.rpm
- # output
- 739dc44566d739c5d7b893de96ee6848 mysql80-community-release-el7-1.noarch.rpm
安装:
- sudo rpm -ivh mysql80-community-release-el7-1.noarch.rpm
- sudo yum install MySQL-server
会弹出安装提示, 按'y'通过即可.
2, 启动 MySQL
使用以下命令来启动守护程序:
sudo systemctl start mysqld
上面的命令并不会有任何输出, 所以需要查看状态:
sudo systemctl status mysqld
如果 MySQL 已成功启动, 则输出应包含 Active:active(running), 最后一行应如下所示:
...... :Starting MySQL Server...
在安装过程中, 会为 MySQL root 用户生成临时密码. 使用以下命令在 mysqld.log 中找到它:
sudo grep 'temporary password' /var/log/mysqld.log
记住密码, 下一步需要使用:
- # output
- 2018-09-29T07:55:22.347160Z 5 [Note] [MY-010454] [Server] A temporary password is generated for root@localhost: 88XR/ea1kY)2
3, 配置 MySQL
MySQL 包含一个安全脚本, 用于更改远程 root 登录和示例用户等一些不太安全的默认选项.
使用此命令运行安全脚本.
sudo mysql_secure_installation
这将提示您输入默认的 root 密码. 输入后, 您将需要更改它.
- # Output
- The existing password for the user account root has expired. Please set a new password.
- New password:
输入一个包含至少一个大写字母, 一个小写字母, 一个数字和一个特殊字符的新 12 个字符的密码. 出现提示时重新输入.
您将收到有关新密码强度的反馈, 然后会立即提示您再次更改密码. 之前已经更改过密码, 就输入 No:
- # Output
- Estimated strength of the password: 100
- Change the password for root ? (Press y|Y for Yes, any other key for No) : No
接下来会有些安全配置需要选, 其中有是否禁止远程 root 用户登录, 这个看需求来决定是否需要否决, 其他的全部输入 y 同意即可.
4, 测试 MySQL
我们可以通过连接 mysqladmin 工具验证我们的安装并获取相关信息, mysqladmin 工具是一个允许您运行管理命令的客户端, 使用以下命令查看版本:
mysqladmin -u root -p version
输出结果如下, 说明安装成功
- mysqladmin Ver 8.0.12 for Linux on x86_64 (MySQL Community Server - GPL)
- Copyright (c) 2000, 2018, Oracle and/or its affiliates. All rights reserved.
- Oracle is a registered trademark of Oracle Corporation and/or its
- affiliates. Other names may be trademarks of their respective
- owners.
- Server version 8.0.12
- Protocol version 10
- Connection Localhost via UNIX socket
- UNIX socket /var/lib/MySQL/MySQL.sock
- Uptime: 23 min 49 sec
- Threads: 2 Questions: 12 Slow queries: 0 Opens: 126 Flush tables: 2 Open tables: 102 Queries per second avg: 0.008
参考这里
三, 安装 Nginx
1, 添加 Nginx Repository
- sudo yum install epel-release
- # update yum
- sudo yum update
2, 安装 Nginx
sudo yum install nginx
验证安装:
- sudo nginx -v
- nginx version: nginx/1.15.4
3, 启动 Nginx
sudo nginx
验证是否成功启动:
- curl -I 127.0.0.1
- # output
- HTTP/1.1 200 OK
- Server: nginx/1.13.8
在浏览器中打开 http://server_domain_name_or_IP / 会直接看到 Welcome to nginx!, 此时就证明现在 Nginx 处于工作状态.
NOTE: 如果浏览器打开没有显示 Welcome to nginx!, 则需要确认服务器的安全配置是否包含 80/443 端口.
希望在系统启动时启用 Nginx. 请输入以下命令:
sudo systemctl enable nginx
参考这里 和这里
四, 安装 Yarn 和 Git
安装 Yarn
配置 yum 的 yarm 远程仓库:
curl --silent --location https://dl.yarnpkg.com/rpm/yarn.repo | sudo tee /etc/yum.repos.d/yarn.repo
安装 Yarn:
sudo yum install yarn
运行命令来测试 Yarn 是否安装:
yarn --version
安装 Git
sudo yum install Git
Git --version
来源: https://juejin.im/post/5bff43a3e51d4507400b6038