CentOS 多域名配置的基本步骤如下:
1. 打开 Apache 的配置文件 `/etc/httpd/conf/httpd.conf`。
2. 在配置文件中添加以下内容:
ServerName www.example.com
DocumentRoot /var/www/html/example
ServerName www.another-example.com
DocumentRoot /var/www/html/another-example
其中 `www.example.com` 和 `www.another-example.com` 是你要设置的域名, `/var/www/html/example` 和 `/var/www/html/another-example` 是对应的网站根目录。
3. 保存并退出配置文件。
4. 创建网站根目录,并添加相应的网页文件:
mkdir /var/www/html/example
echo "Welcome to example.com" > /var/www/html/example/index.html
mkdir /var/www/html/another-example
echo "Welcome to another-example.com" > /var/www/html/another-example/index.html
5. 重启 Apache 服务:
systemctl restart httpd
完成以上步骤后,访问 `www.example.com` 和 `www.another-example.com` 就可以看到对应的网页内容了。
注意事项:
1. 如果有多个 IP 地址,可以在 `
2. 可以在 `
3. 如果有需要,还可以为每个站点单独创建配置文件。
查看详情
查看详情