写个总结笔记,让以后的自己知道怎么部署。

首先apache的版本是2.4.7,然后系统是Ubuntu 14.04.1 LTS。(因为好像配置文件和目录有差异)

首先进到apache2目录下,

我们要探讨的主要是sites-available和sites-enabled根据字面意思,前一个是网站可用的,后一个是网站可用的,然后我们还知道了,sites-enabled里面的文件是sites-available里面文件的软链接,所以我们主要改site-available的文件,打开site-available有两个文件,但我们只需要000-default.conf文件,打开cat文件,代码如下:

<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 seothert it for any further virtual host explicitly.
#ServerName www.example.com ServerAdmin webmaster@localhost
DocumentRoot /var/www/ # 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>

这就是网址配置文件了,而我们要修改的只有被注释掉的ServerName 域名,DocumentRoot 路径这两个部分,去掉注释剩下。

<VirtualHost *:80>
ServerName #这里是域名地址
ServerAdmin webmaster@localhost
DocumentRoot /var/www/ #这里是路径
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
</VirtualHost>

可以直接添加在下面,重启apache就成了。但是上面的优先级要更高,访问自己的域名会跳转到你设置的路径,直接访问ip还是会到第一个设置的路径,你也可以选择删除。

还有另外一种改法就是新建一个文件,xxx.conf然后内容一样,

<VirtualHost *:80>
ServerName #这里是域名地址
ServerAdmin webmaster@localhost
DocumentRoot /var/www/ #这里是路径
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
</VirtualHost>

在创建软链接 ln -s ../sites-avaiable/xxx.conf ../sites-enable/xxx.conf

这样子也可以实现,但是优先级还是000-default.conf高。

好了,就是这么简单。

apache部署多域名,同个ip部署多个网站的更多相关文章

  1. Apache Hadoop 2.9.2 完全分布式部署

    Apache Hadoop 2.9.2 完全分布式部署(HDFS) 作者:尹正杰 版权声明:原创作品,谢绝转载!否则将追究法律责任. 一.环境准备 1>.操作平台 [root@node101.y ...

  2. Apache Spark技术实战之6 --Standalone部署模式下的临时文件清理

    问题导读 1.在Standalone部署模式下,Spark运行过程中会创建哪些临时性目录及文件? 2.在Standalone部署模式下分为几种模式? 3.在client模式和cluster模式下有什么 ...

  3. vue history 模式打包部署在域名的二级目录的配置指南

    最近在做项目,需要把项目部署在域名下的二级目录,并且是在用vue-router的history 模式. 我们都知道vue-router 的两种前端基本访问模式 hash 和history .hash ...

  4. 解决阿里云ECS下kubeadm部署k8s无法指定公网IP

    背景 一般情况下,"kubeadm"部署集群时指定"--apiserver-advertise-address=<public_ip>"参数,即可在 ...

  5. 解决 Vue 部署在域名子路由 问题

    我们先看下官方说明 默认情况下,Vue CLI 会假设你的应用是被部署在一个域名的根路径上,例如 https://www.my-app.com/ .如果应用被部署在一个子路径上,你就需要用这个选项指定 ...

  6. 通过阿里云域名动态解析 IP 地址

    这两天在家里用树莓派折腾了一个家用服务器,主要用来做 mac 的 Time Machine ,还有就是当做下载机和 nas ,想着平时上班时间家里没人用网络,空着也是空着,就可以利用空闲带宽下个美剧啥 ...

  7. GitLab私有化部署 - CI/CD - 持续集成/交付/部署 - 源代码托管 & 自动化部署

    预期目标 源代码管理 借助GitLab实现源代码托管,私有化部署版本,创建项目,创建用户组,分配权限,项目的签入/牵出等. 自动化部署 源代码产生变更时(如签入),自动化编译并发布到指定服务器中部署, ...

  8. CentOS下Apache配置多域名或者多端口映射

    CentOS下Apache默认网站根目录为/var/www/html,假如我默认存了一个CI项目在html文件夹里,同时服务器的外网IP为ExampleIp,因为使用的是MVC框架,Apache需开启 ...

  9. IIS、nginx、apache只允许域名访问配置

    您开启WAF后,攻击者只能看到WAF的IP,不能看到您的IP,攻击者通过域名访问您的网站时,就会根据规则拦截. 但是如果您的网站可以输入IP地址直接访问,是无法达到防御效果的.比如(http://42 ...

  10. IIS与Apache禁止IP地址直接访问网站

    一.IIS 防止恶意域名指向解决方法 首先单击"开始"-"设置"-"控制面板"-"管理工具",找到"Inter ...

随机推荐

  1. [翻译]CURAND Libaray--Host API--(1)

    原文来自:cuda curand toolkit document Translated by xingoo 如果有错误请联系:xinghl90@gmail.com 2Host API简述 使用hos ...

  2. 数据结构5: 链表(单链表)的基本操作及C语言实现

    逻辑结构上一个挨一个的数据,在实际存储时,并没有像顺序表那样也相互紧挨着.恰恰相反,数据随机分布在内存中的各个位置,这种存储结构称为线性表的链式存储. 由于分散存储,为了能够体现出数据元素之间的逻辑关 ...

  3. react 中文文档案例二 (头像时间)

    import React from 'react'; import ReactDOM from 'react-dom'; function formatDate(date) { return date ...

  4. innodb的读写参数优化

    (1)    读取参数,global buffer pool以及 local buffer Innodb_buffer_pool_size,理论上越大越好,建议服务器50%~80%,实际为数据大小80 ...

  5. Docker 使用samba 共享文件

    Docker 使用samba 共享文件   docker run -it --name samba \ -p 139:139 -p 445:445 \ -v /home/develop/code/de ...

  6. find命令使用

    find命令 find [PATH] [option] [action] 参数: 1.与时间相关参数 -atime -ctime -mtime 以mtime为例: -mtime n:n为数字,意义为在 ...

  7. AnnotationConfigApplicationContext

    package com.test; import java.io.IOException; import java.io.InputStream; import java.net.URL; impor ...

  8. Tomcat分析-启动过程

    Server是Tomcat最顶层的容器 Service用于提供服务 Connector用于处理连接相关的事情,并提供Socket与request和response的转换 Container用于封装和管 ...

  9. centos7安装与卸载软件

    安装 yum install 服务名 查看服务名 rpm -qa |grep -i aerospike 或者 yum list installed | grep aerospike 卸载 yum re ...

  10. Java学习笔记day06_自定义类_ArrayList

    1.自定义类class 使用类的形式, 对现实中的事物进行描述. 类是引用数据类型. 事物: 方法,变量. 方法:事物具备的功能. 变量:事物的属性. 格式: public class 类名{ //属 ...