要在 Apache 中修改域名,您需要更改您的虚拟主机配置。以下是步骤:
1. 打开配置文件:
- 一般存放在 `/etc/httpd/conf/httpd.conf` 或 `/etc/apache2/sites-available/your-site.conf`。
2. 找到虚拟主机配置:
- 搜索包含 `ServerName` 和 `ServerAlias` 的虚拟主机段落。
3. 更新域名:
- 修改 `ServerName` 为新的主域名。
- 如果有替代域名,更新或添加到 `ServerAlias`。
apache
ServerName www.new-domain.com
ServerAlias new-domain.com
DocumentRoot /var/www/your-site
# 其他配置...
4. 检查语法:
- 运行 `apachectl configtest` 或 `apache2ctl configtest` 以确保没有语法错误。
5. 启用站点(如适用):
- 如果在 `/sites-available/` 中修改,要使用 `a2ensite your-site.conf` 启用。
6. 重启 Apache 服务:
- 运行 `systemctl restart httpd` 或 `systemctl restart apache2`。
7. 更新 DNS 记录:
- 确保新的域名指向服务器的 IP 地址。
完成这些步骤后,您的 Apache 应该使用新域名服务。记得也要更新任何链接或资源文件中的域名。
查看详情
查看详情