在hosts中添加域名
# Copyright (c) 2014-2016, racaljk.
# https://github.com/racaljk/hosts
# Last updated: 2016-10-20
# This work is licensed under a CC BY-NC-SA 4.0 International License.
# https://creativecommons.org/licenses/by-nc-sa/4.0/
# Localhost (DO NOT REMOVE)
127.0.0.1 localhost
127.0.0.1 blog.cet4free.cn
::1 localhost ip6-localhost ip6-loopback
编辑httpd.conf文件
输入命令:
vi /etc/apache2/httpd.conf
将Include /private/etc/apache2/extra/httpd-vhosts.conf这行前的注释符号#去掉。
# Virtual hosts
Include /private/etc/apache2/extra/httpd-vhosts.conf
# Local access to the Apache HTTP Server Manual
#Include /private/etc/apache2/extra/httpd-manual.conf
# Distributed authoring and versioning (WebDAV)
#Include /private/etc/apache2/extra/httpd-dav.conf
# Various default settings
#Include /private/etc/apache2/extra/httpd-default.conf
编辑httpd-vhosts.conf文件
输入命令:
vi /etc/apache/extra/httpd-vhosts.conf
在文件后面追加如下网站配置
<VirtualHost *:80>
#ServerAdmin webmaster@dummy-host.example.com
DocumentRoot "/blog.cet4free.cn/"
ServerName blog.cet4free.com
ErrorLog "/private/var/log/apache2/dummy-host2.example.comblog.cet4free.cn-error_log"
#CustomLog "/private/var/log/apache2/blog.cet4free.cn-access_log" common
</VirtualHost>
重启apache服务器
sudo apachectl restart
测试服务器配置
在浏览器中输入:
http://blog.cet4free.cn
查看网站。
网友评论