版本 Ubuntu 16.04

1 . 首先找到Apapche配置文件夹  /etc/apache2/

apache2.conf conf-enabled magic mods-enabled sites-available
conf-available envvars mods-available ports.conf sites-enabled

该文件夹下有以上配置文件

apache2.conf : apache配置主文件  配置站点根目录 全局配置等

sites-available :配置虚拟主机

sites-enabled : 持有/etc/apache2/sites-available目录下文件的链接,当Apache重启后,该目录中包含的站点将会被激活。如果apache上配置了多个虚拟机,每个虚拟机的配置文件都放在sites-available下,那么对于虚拟主机的停用,启动就是非常方便了,操作某个虚拟主机就不用动配置文件了

2. 在sites-available下创建虚拟站点 (eko.conf)

root@ubuntu:/etc/apache2/sites-available# ls
-default.conf default-ssl.conf eko.conf

配置文件项

<VirtualHost *:>
# 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 eko.xiao.com
ServerAdmin webmaster@localhost
DocumentRoot /var/www/html/eko/public <Directory /var/www/html/eko/public>
Options Indexes FollowSymLinks MultiViews
AllowOverride All
Order allow,deny
allow from all
</Directory>
# 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>

3 . 创建软链接

sudo ln -s /etc/apache2/sites-available/example.conf  /etc/apache2/sites-enabled/example.conf 

在Ubuntu缺省安装的目录有与其他相比有一点不同。在ubuntu中module和 virtual host的配置都有两个目录,一个是available,一个是enabled,available目录是存放有效的内容,但不起作用,只有用ln 连到enabled过去才可以起作用。这样子对于开发以及调试都很方便

4 . 修改/etc /hosts 文件,加入当前主机的IP地址和需要设置的虚拟主机名

127.0.0.1   localhost
127.0.1.1 ubuntu
192.168.1.121 eko.test.com
# The following lines are desirable for IPv6 capable hosts
:: ip6-localhost ip6-loopback
fe00:: ip6-localnet
ff00:: ip6-mcastprefix
ff02:: ip6-allnodes
ff02:: ip6-allrouters

5.  重启apache

 /etc/init.d/apache2 restart

6 .  配置完成后将项目根目录 runtime 目录 public目录 权限设置为777

chmod -R 777 runtime
chmod -R 777 public/upload

  

[记录] Ubuntu 配置Apache虚拟站点的更多相关文章

  1. Ubuntu 配置Apache虚拟目录

    http://blog.csdn.net/spring21st/article/details/6589300 Ubuntu 配置Apache虚拟目录 http://blog.csdn.net/spr ...

  2. 配置Apache虚拟主机

    实验环境 一台最小化安装的CentOS 7.3虚拟机 配置基础环境 1. 安装apache yum install -y httpd 2. 建立虚拟主机的根目录 mkdir /var/wwwroot ...

  3. wamp开发环境配置之配置Apache虚拟主机

    网站建设人员在本地测试时,常常不是一个网站,那怎么能像输入域名一样在地址栏上面输入“域名”就能本地访问该网站呢?这里就要配置Apache虚拟主机了! 1.找到apache\conf\httpd.con ...

  4. mac下配置Apache虚拟域名方案,以及遇到的坑(转)

      1. 配置Apache虚拟域名 1.执行    sudo vi /etc/apache2/httpd.conf 开始配置httpd.conf 的文件; //配置listen 80端口(默认配置), ...

  5. mac下配置Apache虚拟域名方案,以及遇到的坑

      1. 配置Apache虚拟域名 1.执行    sudo vi /etc/apache2/httpd.conf 开始配置httpd.conf 的文件; //配置listen 80端口(默认配置), ...

  6. ubuntu配置apache和cgi

    ubuntu配置apache和cgi . 更新源并进行安装,否则后面的下载可能会不成功. sudo apt-get update sudo apt-get upgrade . 安装apache2服务 ...

  7. 配置LANMP环境(7)-- 配置nginx反向代理,与配置apache虚拟主机

    一.配置nginx反向代理 1.修改配置文件 vim /etc/nginx/nginx.conf 在35行http下添加一下内容: include /data/nginx/vhosts/*.conf; ...

  8. 配置IIS虚拟站点(5)

    开发完ASP.NET网站后,想要直接浏览,不通过开发环境,那么就需要配置IIS虚拟站点 1.开始菜单->控制面板->所有控制面板->管理工具->双击打开Internet信息服务 ...

  9. ubuntu配置apache的虚拟主机

    ubuntu中apache的配置文件分散在几个文件中,/etc/apache2/apache2.conf将它们组织起来.这样设计有很多好处,这里就不在赘述了.进入正题: 1)配置文件在/etc/apa ...

随机推荐

  1. Selenium+Python:下载文件(Firefox 和 Chrome)

    引自  https://blog.csdn.net/Momorrine/article/details/79794146 1.      环境 操作系统 Win10 IDE Eclipse (Oxyg ...

  2. Hard commits, soft commits and transaction logs

    “Hard commits are about durability, soft commits are about visibility“  Transaction Logs 首先介绍下solrcl ...

  3. Android Studio 增加函数注释模板

    此篇文章主要介绍如何在Android Studio中函数如何添加注释,使其和eclipse一样方便的添加注释 Android Studio默认函数注释为 /** * */ 下面方法将要改为如下格式 / ...

  4. pyqt信号和槽传递额外参数

    转载:fengyu09 环境:python2.7.8 —— pyqt 4.11.1 使用Pyqt编程过程中,经常会遇到给槽函数传递额外参数的情况.但是信号-槽机制只是指定信号如何连接到槽,信号定义的参 ...

  5. Consul之:服务健康监测

    服务注册 - 服务进程在注册中心注册自己的位置.它通常注册自己的主机和端口号,有时还有身份验证信息,协议,版本号,以及运行环境的详细资料. 服务发现 - 客户端应用进程向注册中心发起查询,来获取服务的 ...

  6. 数据仓库与ODS

    1. 引言 本篇主要讲述操作数据存储(ODS)系统产生的背景.定义.特点,以及它与数据仓库的区别.在前两篇,笔者介绍了什么是数据仓库?为什么需要数据仓库?数据仓库系统的体系结构是什么?因此可能在读者心 ...

  7. 百度地图 android SDKv2.2.0

    首先创建自己的KEY http://lbsyun.baidu.com/apiconsole/key 然后点击设置 参照官网文档点击下面连接 官网文档  http://developer.baidu.c ...

  8. win7颜色反转

    win7屏幕太亮,整天看电脑看的头疼 利用放大镜实现颜色反转 打开控制面板 //也可'开始'处直接输入输入放大镜进入 选择轻松访问 启用放大镜 选择设置 启用颜色反转 win+'+'增加放大镜的放大倍 ...

  9. studio之mac快捷键

    2. SouceTree忽略文件:  .gitignore文件编辑: 忽略指定文件:直接写文件名 忽略文件夹:直接写文件夹路径,例:target或者target/ -> 忽略target下的所有 ...

  10. C#语言集合

    switch 用法 int x = int.Parse(Console.ReadLine()); switch(x){ case 1: Console.WriteLine("这是1" ...