在 CentOS 上“更换域名”通常涉及 系统主机名(hostname) 或 网站/服务绑定的域名。下面分情况说明:
hostnamectl
或
hostname
hostname newdomain.com
hostnamectl set-hostname newdomain.com
/etc/hostsvi /etc/hosts
修改为:
127.0.0.1 localhost newdomain.com
reboot
或重新 SSH 登录即可生效。
编辑配置文件:
vi /etc/nginx/conf.d/your-site.conf
修改:
server_name olddomain.com;
为:
server_name newdomain.com;
重载 Nginx:
nginx -t
systemctl reload nginx
vi /etc/httpd/conf.d/your-site.conf
修改:
ServerName newdomain.com
重启 Apache:
systemctl restart httpd
更换域名后,需要:
certbot --nginx -d newdomain.com
| 场景 | 命令 |
|---|---|
| 改主机名 | hostnamectl set-hostname xxx |
| 改网站域名 | 改 Nginx/Apache 配置 |
| 改 DNS | 域名控制台 |
| 验证 | ping newdomain.com |
如果你能说明 具体是哪种“域名”(主机名?网站?邮件?Docker?),我可以给你更精确的命令。