Only the author or the admin can edit this post.
1.安装ubuntu
1-1.重装ubuntu的时候,先不要启用ssh,之前可能在/Users/***/.ssh/known_hosts文件里留下了该ip的内容,删除相关的行,
再用ssh root@ip登陆,即会提示输入密码
1-2.启用公私钥登陆,禁用密码登陆
1-2-1.#AuthorizedKeysFile .ssh/authorized_keys .ssh/authorized_keys2
-> #AuthorizedKeysFile .ssh/PublicKeyCredential.key
1-3.服务器登不上的情况:
1-3-1.官方vnc
1-4.mac 2 server 公钥贴到服务器上默认的指定.key文件里
1-5.
#PubkeyAuthentication yes
PasswordAuthentication no
Port ???
#AuthorizedKeysFile .ssh/authorized_keys .ssh/authorized_keys2
pc2server: 公钥放这里 .ssh/authorized_keys
1-6.server 2 github:
1-6-1.在服务器上创建公私钥: ssh-keygen -t ed25519 -C "**@qq.com"
1-6-2.将公钥内容复制到github上添加新的ssh key
1-6-3.将私钥添加到 SSH 代理:
1-6-3-1:eval "$(ssh-agent -s)" # 启动 SSH 代理
# 将私钥添加到 SSH 代理
1-6-3-2-1:ssh-add ~/.ssh/id_ed25519 # 如果你使用的是 Ed25519 密钥
1-6-3-2-2:ssh-add ~/.ssh/id_rsa# 如果你使用的是 RSA 密钥
2.安装apache
2-1.sudo apt update: 更新系统软件包列表
sudo apt install apache2: 安装 Apache
sudo systemctl start apache2: 启动 Apache 服务
sudo systemctl enable apache2: 设置 Apache 开机自启
sudo systemctl status apache2: 验证 Apache 是否安装成功
3.安装1panel
3-1.curl -sSL https://resource.fit2cloud.com/1panel/package/quick_start.sh -o quick_start.sh: 下载安装脚本
bash quick_start.sh: 运行安装脚本
3-2.设置端口,默认41821-> 新端口号
设置1Panel端口 (默认是 41821): 新端口号
[1Panel Log]: 您设置的端口是: 新端口号
[1Panel Log]: 正在打开防火墙端口 新端口号
Rules updated
Rules updated (v6)
Firewall not enabled (skipping reload)
3-3.设置1Panel安全入口 (默认是 ***):
3-4.设置1Panel面板用户 (默认是 ***):
[1Panel Log]: 设置1Panel面板密码,设置后按回车键继续 (默认是 ***):
4.安装mongodb
4-1.导入 MongoDB 官方 GPG 密钥:
wget -qO - https://www.mongodb.org/static/pgp/server-6.0.asc | sudo apt-key add -
4-2.创建 MongoDB 软件源列表文件:
echo "deb [ arch=amd64,arm64 ] https://repo.mongodb.org/apt/ubuntu jammy/mongodb-org/6.0 multiverse" | sudo tee /etc/apt/sources.list.d/mongodb-org-6.0.list
tip: 这里的 focal 对应 Ubuntu 20.04,如果是其他版本的 Ubuntu,需要相应替换(如 bionic 对应 Ubuntu 18.04)。
Ubuntu 版本 代号
18.04 bionic
20.04 focal
22.04 jammy
23.04 lunar
23.10 mantic
4-3.更新本地软件包索引: sudo apt update
4-4.安装 MongoDB: sudo apt install -y mongodb-org
安装过程中可能会提示重启,可选择其中一个packagekit.service, 或者 systemd-resolved.service:
之后手动的话,命令:
sudo systemctl restart packagekit.service
sudo systemctl restart systemd-resolved.service
4-5.启动并设置 MongoDB 开机自启:
# 启动 MongoDB 服务
sudo systemctl start mongod
# 设置 MongoDB 开机自启
sudo systemctl enable mongod
4-6.验证 MongoDB 是否安装成功:
4-6-1.检查服务状态: sudo systemctl status mongod
4-6-2.使用 MongoDB 客户端连接: mongosh
4-7.可选:卸载 MongoDB:
# 停止 MongoDB 服务
sudo systemctl stop mongod
# 移除 MongoDB 软件包
sudo apt purge mongodb-org*
# 删除数据目录和配置文件
sudo rm -r /var/log/mongodb
sudo rm -r /var/lib/mongodb
4-8.改端口:
4-8-1.停止 MongoDB 服务: sudo systemctl stop mongod
4-8-2.编辑 MongoDB 配置文件: sudo nano /etc/mongod.conf
net:
port: 27018
bindIp: 127.0.0.1
4-8-3.检查防火墙设置: sudo ufw allow 27018
4-8-4.启动 MongoDB 服务:
# 启动 MongoDB 服务
sudo systemctl start mongod
# 检查 MongoDB 服务状态
sudo systemctl status mongod
4-8-5.验证端口修改是否成功:
sudo ss -tuln | grep ***(新配的端口号)
4-9.Mongo Compass连不上, 提示: TLS/SSL is disabled. If possible, enable TLS/SSL to avoid security vulnerabilities.
// ? 服务端启用 TLS/SSL: sudo nano /etc/mongod.conf
https://github.com/acmesh-official/acme.sh
4-9-1.MongoNetworkError: connect ECONNREFUSED: bindIp: 0.0.0.0 # 若要允许所有 IP 访问;若只想本地访问,可设为 127.0.0.1
4-9-2.MongoServerError: Authentication failed.: 修正指定的库的用户名密码设置
5.安装acme.sh
5-1.安装 acme.sh:
curl https://get.acme.sh | sh -s [email protected]
或者
wget -O - https://get.acme.sh | sh -s [email protected]
5-2.生成证书:
acme.sh --issue --apache -d winnie-online.win -d *.winnie-online.win -> wtest here
* 遇到报错:
Cannot get domain token entry *.winnie-online.win for http-01
[Fri Feb 21 14:13:47 HKT 2025] Supported validation types are: dns-01 , but you specified: http-01
5-2-1.确认 DNS 提供商支持及配置相关 API 凭证:
cloudflare:
export CF_Email="[email protected]"
export CF_Key="your_cloudflare_api_key"
5-2-2.使用 acme.sh 命令生成证书:
acme.sh --issue --apache --dns dns_cf -d example.com -d www.example.com
export CF_Email="[email protected]"
export CF_Key="your_cloudflare_api_key"
acme.sh --issue --apache --dns dns_cf -d winnie-online.win -d www.winnie-online.win
5-2-3.后续操作:
sudo systemctl restart apache2
5-2-4.查看已安装的证书信息:
acme.sh --info -d example.com
acme.sh --info -d winnie-online.win
6.安装pm2
6-1.安装 Node.js 和 npm:
# 添加 NodeSource 仓库
curl -fsSL https://deb.nodesource.com/setup_18.x | sudo -E bash -
# 安装 Node.js 和 npm
sudo apt-get install -y nodejs
6-2.使用 npm 安装 PM2:
sudo npm install -g pm2
6-3.验证 PM2 安装:
pm2 --version
6-4.设置 PM2 开机自启:
pm2 startup
6-5.保存当前应用列表: pm2 save
6-6.使用示例:
# 创建一个简单的 Node.js 应用文件
echo "const http = require('http'); const server = http.createServer((req, res) => { res.end('Hello, World!'); }); server.listen(3000, () => { console.log('Server is running on port 3000'); });" > app.js
# 使用 PM2 启动应用程序
pm2 start app.js --name my-app
7.git拉仓库下来
7-1.clone
7-2.安装yarn
7-3.yarn install
7-4.添加.env.local文件
7-5.yarn run build
7-6.pm2 start npm --name "my-app" -- start
8.域名的绑定:
8-1.之前绑过其他的ip,到cloudflare,dns管理那里修改ip
// 8-2.改域名绑定配置: /etc/apache2/sites-enabled: /var/www/html -> /var/www/winnie-world/my-app
8-2.配置反向代理:
8-2-1.启用proxy:
sudo a2enmod proxy proxy_http
sudo systemctl restart apache2
8-2-2.反向代理内容:
sudo nano /etc/apache2/sites-available/yourdomain.com.conf
8-2-3.apache抽风,果断换nginx,嘻嘻嘻