版本 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. pytest学习笔记

    From: https://blog.csdn.net/gaowg11/article/details/54910974 由于对测试框架了解比较少,所以最近看了下pytest测试框架,对学习心得做个记 ...

  2. 64位系统VBS调用32位COM组件

    64位系统VBS调用32位COM组件 标签: 32位, 64位, COM, COM组件, VB, VBS, VBScript 标题: 64位系统VBS调用32位COM组件作者: Demon链接: ht ...

  3. 推荐两个小工具MediaInfo 和 netpersec

    [转载请注明出处]:http://blog.csdn.net/longlong530 流媒体服开发的时候常用的两个工具, 1. MediaInfo     下载路径:(http://w.x.baidu ...

  4. bzoj4020: 未来程序·改

    只需写一个解释器 第一次预处理将输入进行分词,分割出 关键字,运算符,变量/函数名,整数常量,并对变量/函数名离散化以便处理 第二次预处理建语法树,每个节点存节点类型,变量定义表等信息 运行时在语法树 ...

  5. Java-Runoob-高级教程-实例-时间处理:03. Java 实例 - 获取年份、月份等

    ylbtech-Java-Runoob-高级教程-实例-时间处理:03. Java 实例 - 获取年份.月份等 1.返回顶部 1. Java 实例 - 获取年份.月份等  Java 实例 以下实例演示 ...

  6. 廖雪峰Java2面向对象编程-6Java核心类-2StringBuilder

    字符串操作过程中,每次用 + 拼接字符串,有以下问题: 每次循环都会创建新的对象 绝大部分都是临时对象.浪费内存 影响GC效率 String s = ""; for(int i=0 ...

  7. Ajax传参讲解

    客户端和服务器 1.请求:request 2.响应:response 服务器响应事件:onreadystatechange() send() 用于向后台传递参数: Ajax的请求方式 get:    ...

  8. jenkins+git 构建项目

    首先先参照了网上几篇文章 http://blog.csdn.net/kefengwang/article/details/54233584 https://www.liaoxuefeng.com/ar ...

  9. [UE4]控制台命令,生成机器人

    在关卡蓝图中: 运行游戏的手,按“·”键(键盘第二行第一个键,数字1前面的一个键)呼出控制台输入界面,输入“ce 事件名称 参数值”,然后回车. 可以添加一个Trigger Box作为机器人的出生点

  10. Android应用启动会白屏一下的解决办法

    设置透明样式,如下:<activity android:name="com.hongfans.cvi.ui.MainActivity" android:configChang ...