在Ubuntu 14.04 LTS系统中设置Apache虚拟主机
来源:互联网 发布:淘宝模特签约合同范本 编辑:程序博客网 时间:2024/05/29 14:00
在这个教程中,我会使用Ubuntu 14.04 LTS,并搭建1个测试网站命名目录为“tianmao .我的虚拟机IP192.168.1.128。你可以根据你的需要更改虚拟域名。前提是有了虚拟机的静态ip,
sudo mkdir -p /var/www/tianmao
创建一个静态html访问文件,写些东西并访问
sudo touch index.html
创建虚拟主机配置文件
默认情况下,apache有一个默认的虚拟主机文件叫000-default.conf。我们将会复制000-default.conf文件内容到我们新的虚拟主机配置文件中。
sudo cp /etc/apache2/sites-available/000-default.conf /etc/apache2/sites-available/tianmao.conf
确保虚拟主机配置文件末尾包含.conf扩展名。修改tianmao.conf文件以符合需求。
sudo vi /etc/apache2/sites-available/tianmao.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 #ServerAdmin webmaster@unixmen1.local ServerName www.tianmao.com #ServerAlias www.unixmen1.local DocumentRoot /var/www/tianmao # 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 # 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>
修改虚拟主机文件后,禁用默认的虚拟主机配置(000.default.conf),然后启用新的虚拟主机配置,如下
sudo a2dissite 000-default.conf
sudo a2ensite tianmao.conf
重启apache服务器
sudo service apache2 restart
编辑/etc/hosts文件,
sudo vi /etc/hosts
192.168.1.250 www.tianmao.com
0 0
- 在Ubuntu 14.04 LTS系统中设置Apache虚拟主机
- 在Ubuntu 14.04 LTS系统中设置Apache虚拟主机
- 在Ubuntu 14.04 LTS系统中设置Apache虚拟主机
- 在Ubuntu 14.04 LTS系统中设置Apache虚拟主机
- 在Ubuntu 14.04 LTS系统中设置Apache虚拟主机
- Ubuntu 14.04 LTS Apache2 设置虚拟主机
- 如何设置Apache虚拟主机在Ubuntu12.04 LTS
- 如何在Ubuntu 14.04 LTS之上设置Nginx Server Blocks(即虚拟主机)
- ubuntu 14.04设置Apache虚拟主机的方法
- ubuntu 14.04设置Apache虚拟主机的方法
- ubuntu下设置apache虚拟主机
- ubuntu系统下在apache2.4服务器上设置虚拟主机
- Apache服务器中设置虚拟主机
- Ubuntu 14.04 LTS中怎样解决系统设置残缺的问题
- 在Apache中配置虚拟主机
- ubuntu 14.04 LTS sunpinyin设置
- Ubuntu 14.04 LTS 别名设置
- 05. ubuntu 16.04 LTS 系统常用设置
- HDU 2222 AC自动机
- cropper本地预览 裁剪,上传到服务器
- Redis安装详细教程
- 正则表达式
- 使用Visual Studio 2013进行单元测试
- 在Ubuntu 14.04 LTS系统中设置Apache虚拟主机
- 从技术经理的角度算一算,如何可以多快好省的做个App(一)
- 为dialog添加单选列表控件
- 刷题记录 2015.11.14
- QEMU+busybox 网络和用户配置的几个注意点
- Spark修炼之道(基础篇)——Linux大数据开发基础:第四节:Linux文件系统(二)
- 杭电1856More is better
- 个人收集的一些库、工具、技术介绍
- C语言、C++内存对齐问题详解