华为云服务器使用 Huawei Cloud EulerOS 2.0 是基于 CentOS 和 openEuler 的定制化操作系统,适用于企业级云计算环境。如果你刚刚购买了华为云 ECS(弹性云服务器),并选择了 Huawei Cloud EulerOS 2.0 作为操作系统,以下是一个详细的入门和使用教程,帮助你快速上手配置和管理该系统。
🧾 一、登录到 Huawei Cloud EulerOS 2.0
1. 获取公网 IP 地址
- 登录 华为云控制台
- 进入【弹性云服务器】页面,找到你的服务器实例,记录其公网 IP。
2. 使用 SSH 登录服务器(Linux/macOS)
ssh root@你的公网IP
或使用密钥登录:
ssh -i /path/to/private_key root@你的公网IP
3. Windows 用户推荐工具:
- Xshell
- PuTTY
- Windows Terminal / PowerShell + OpenSSH
⚙️ 二、初始设置建议
1. 创建普通用户(可选但推荐)
adduser your_username
passwd your_username
添加 sudo 权限:
usermod -aG wheel your_username
2. 禁用 root 登录(提高安全性)
编辑 SSH 配置文件:
sudo vi /etc/ssh/sshd_config
修改:
PermitRootLogin no
重启 sshd:
sudo systemctl restart sshd
🔐 三、安装常用软件包
Huawei Cloud EulerOS 2.0 基于 yum/dnf 包管理系统(类似 CentOS/RHEL):
更新系统
sudo yum update -y
安装常用工具
sudo yum install -y vim net-tools wget curl git unzip zip epel-release
🌐 四、配置防火墙(firewalld)
默认 firewalld 已启用,需根据需要开放端口。
查看状态
sudo systemctl status firewalld
开放指定端口(如80、443、8080等)
sudo firewall-cmd --permanent --add-port=80/tcp
sudo firewall-cmd --reload
查看已开放的端口
sudo firewall-cmd --list-all
📦 五、安装 Web 服务示例(Nginx + PHP + MySQL)
1. 安装 Nginx
sudo yum install -y nginx
sudo systemctl start nginx
sudo systemctl enable nginx
访问 http://你的公网IP 测试是否看到欢迎页。
2. 安装 MariaDB(MySQL 替代)
sudo yum install -y mariadb-server mariadb
sudo systemctl start mariadb
sudo systemctl enable mariadb
sudo mysql_secure_installation
3. 安装 PHP(以 PHP 7.4 为例)
sudo yum install -y https://dl.fedoraproject.org/pub/epel/epel-release-latest-7.noarch.rpm
sudo yum install -y http://rpms.remirepo.net/enterprise/remi-release-7.rpm
sudo yum install -y php php-fpm php-mysqlnd php-gd php-xml php-mbstring
启动 PHP-FPM:
sudo systemctl start php-fpm
sudo systemctl enable php-fpm
配置 Nginx 支持 PHP:
sudo vi /etc/nginx/conf.d/default.conf
确保包含如下内容:
location ~ .php$ {
include fastcgi_params;
fastcgi_pass unix:/run/php-fpm/www.sock;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
}
重启服务:
sudo systemctl restart nginx php-fpm
📁 六、上传文件到服务器的方法
方法 1:使用 scp(本地 → 服务器)
scp -i 私钥文件 本地文件路径 root@公网IP:/目标路径
方法 2:使用 FTP/SFTP 工具(如 FileZilla)
☁️ 七、与华为云集成的功能
1. 安装云监控插件(CES Agent)
华为云提供监控插件,用于增强性能监控能力。
参考官方文档安装:
https://support.huaweicloud.com/usermanual-ces/zh-cn_topic_0085634459.html
2. 自动备份 & 快照
通过控制台设置自动快照策略,保障数据安全。
📚 八、参考资料 & 文档
-
华为云 EulerOS 官方说明:
https://support.huaweicloud.com/os-ecshelp/ecs_01_0025.html
-
openEuler 官方文档(兼容性强):
https://www.openeuler.org/zh/
-
华为云帮助中心:
https://support.huaweicloud.com/
✅ 总结
| 操作 | 命令 |
|---|---|
| 更新系统 | yum update -y |
| 安装软件 | yum install 包名 |
| 启动服务 | systemctl start 服务名 |
| 设置开机自启 | systemctl enable 服务名 |
| 防火墙开放端口 | firewall-cmd --permanent --add-port=端口/tcp |
如果你有具体的用途(如部署网站、搭建数据库、运行 Java 应用等),可以告诉我,我可以为你提供更详细的配置方案!
CLOUD技术博