博主分享免费Java教学视频,B站账号:Java刘哥
第一步、新建项目文件夹
在计算机根目录新建wwwroot文件夹,然后在wwwroot里新建video文件夹,在video里新建index.html,里面随便写点东西。待会儿,我们要通过在地址栏输入video.imooc.com来访问我们这个wwwroot文件夹下的video项目 顺便附图第二步、在sites-available里创建配置文件video.conf
sites-available在/etc/apache2/下,然后在sites-available文件夹内新建文件video.conf,粘贴以下代码- <VirtualHost *:80>
- # The ServerName directive sets the request scheme, hostname and port that
- # the server uses to identify itself. This is used when creating
- # redirection URLs. In the context of virtual hosts, the ServerName
- # specifies what hostname must appear in the request's Host: header to
- # match this virtual host. For the default virtual host (this file) this
- # value is not decisive as it is used as a last resort host regardless.
- # However, you must set it for any further virtual host explicitly.
- #ServerName www.example.com
- ServerName video.imooc.com
- ServerAdmin webmaster@localhost
- DocumentRoot /wwwroot/video
- # Available loglevels: trace8, ..., trace1, debug, info, notice, warn,
- # error, crit, alert, emerg.
- # It is also possible to configure the loglevel for particular
- # modules, e.g.
- #LogLevel info ssl:warn
- ErrorLog ${APACHE_LOG_DIR}/error.log
- CustomLog ${APACHE_LOG_DIR}/access.log combined
- <Directory /wwwroot/video>
- Options FollowSymLinks
- AllowOverride None
- Require all granted
- </Directory>
- # For most configuration files from conf-available/, which are
- # enabled or disabled at a global level, it is possible to
- # include a line for only one particular virtual host. For example the
- # following line enables the CGI configuration for this host only
- # after it has been globally disabled with "a2disconf".
- #Include conf-available/serve-cgi-bin.conf
- </VirtualHost>
- # vim: syntax=apache ts=4 sw=4 sts=4 sr noet
第三步、创建video.conf软链接到sites.enabled
sites-enabled同样是在apache2文件夹下,就是它来发挥作用。而刚才的sites-available是不起作用的,它的作用就是作为配置文件,备份的感觉。如果不想要那个虚拟主机配置了,只需要删除sites-enabled下的软连接就可以,不需要改sites-available的文件。下次又想要弄那个虚拟主机啦,只需要再创一个软链接就可以啦。如图第四步、修改hosts文件
hosts文件在etc目录下,找不到的话可以在根目录搜索 建议大家用vim打开编辑,并加入一行代码- 127.0.0.1 video.imooc.com
第五步、重启apache,在浏览器里预览效果
在所有操作完毕后重启apache,然后, 在浏览器地址栏输入:video.imooc.com ,效果如图最后附一下刚才操作的常用shell命令 1.在根目录新建wwwroot文件夹和三个子文件夹video,bbs,oa
- sudo mkdir -p /wwwroot/{video,bbs,oa}
- cd /wwwroot/
- ls或者ll
- cd video
- sudo vim index.html
- Esc 切换到命令模式
- :wq 保存并退出
- :%d 清除编辑器内容
- ggVG 全选复制
- x 删除
- u 撤销
- /aaaa 搜索aaaa
- yy 复制当前行
- sudo cp 000-default.conf video.conf
- sudo ln -s ../sites-available/video.conf video.conf
- sudo service apache2 restart
- sudo mv a a.txt
- sudo rm a.txt
更多文章 ubuntu14.04 下 mysql 存储目录迁移 ubuntu14.04下配置apache虚拟主机 ubuntu14.04 安装phpmyadmin 和配置 本文地址:http://liuyanzhao.com/1978.html 转载请注明
- 微信
- 交流学习,有偿服务
- 博客/Java交流群
- 资源分享,问题解决,技术交流。群号:590480292
2017年02月24日 16:29:23
不错呀!备案成功了!恭喜呀!
2017年02月24日 17:44:11
还没有啊,我是临时解析到香港主机
2017年02月26日 19:45:46
哦,还可以这样嘛?