版本 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. Spring mvc Json 的正确返回姿势

    我们经常都需要封装统一JSON格式 例如以下形式 { “data”:“输出的数据”, “code”:“响应代码”, “msg”:“响应信息” } /** * Created by linli on 2 ...

  2. 解决下载经过GZip压缩后的网页乱码问题

    目前很多网站默认采用GZip压缩,如果不进行解压缩,下载后生成的html页面打开后会出现中文乱码 乱码前: string url = "http://quote.eastmoney.com/ ...

  3. Spark 在Hadoop HA下配置HistoryServer问题

    我的Spark机群是部署在Yarn上的,因为之前Yarn的部署只是简单的完全分布式,但是后来升级到HA模式,一个主NN,一个备NN,那么Spark HistoryServer的配置也需要相应的做修改, ...

  4. Linux环境下配置maven环境

    1.下载安装包并解压 安装包直接去apache官网下载:https://maven.apache.org/download.cgi 将安装包放在自己指定的目录:/home/software/apach ...

  5. SQL删除指定列的指定长度的字符

    update );

  6. Scala中的柯里化

    一.初识Currying柯里化   柯里化(Currying)技术 Christopher Strachey 以逻辑学家 Haskell Curry 命名的(尽管它是 Moses Schnfinkel ...

  7. docker构建tomcat镜像

    下载centos镜像 # docker pull daocloud.io/centos:7 [root@localhost ~]# docker pull daocloud.io/centos: : ...

  8. python之路——2

    王二学习python的笔记以及记录,如有雷同,那也没事,欢迎交流,wx:wyb199594 复习 1.编译型:一次性将全部的代码编译成二进制文件 c c++ 优点:运行效率高 缺点:开发速度慢,不能跨 ...

  9. [UE4]在AI Character中要获得AI的controller,需要使用Get AIController

  10. Java - 19 Java 异常处理

    Java 异常处理 异常是程序中的一些错误,但并不是所有的错误都是异常,并且错误有时候是可以避免的. 比如说,你的代码少了一个分号,那么运行出来结果是提示是错误java.lang.Error:如果你用 ...