序:这次项目主要是为了给微信客户端添加一个地址,在微信公众号里面添加一个可以访问的app下载页面,说起来很简单,但总不能为了这么小的一个网站新建一个web服务器吧!

现在开始配置,首先必须确认已经在Linux上搭建好了LAMP环境,并且有一个站点可以正常访问,以我的apache-ubuntu为例,默认目录是:/var/www/html/

来先明确这个新的站点该放在哪儿,我绝不建议继续放到默认目录下一个目录,应该放在www下面,我这么做的,

sudo mkdir /var/www/sunjob-app        //新建一个站点目录

没错,我的新小网站的目录就在这个sunjob-app下面吧

接下来先别着急去配置文件,去域名购买站点修改解析,我的是万网,添加域名解析,如图:

注意把记录类型修改为cname,不是图中的A,记录就是域名前缀,默认是www,我修改成了app,那么最终访问时候的请求地址就是:app.ygdiy.com(注意前缀变了)

域名解析结束,保存!

回到ubuntu服务器,开始配置这个域名解析的新站点:

cd /etc/apache2/sites-available/            //进入可获取站点配置目录下

//vim新建并修改一个配置文件,我直接命名成了新站点,但注意后缀是.conf,因为在apache.conf中默认是include "*.conf"文件的

//而nginx中nginx.conf配置了“include sites-enable/*”所以所有文件都会被加载,apache只加载.conf后缀的

vim ./app.ygdiy.conf

修改配置文件代码如下:

# 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 app.ygdiy.comServerAdmin webmaster@localhostDocumentRoot /var/www/sunjob-app# 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:warnErrorLog ${APACHE_LOG_DIR}/error.logCustomLog ${APACHE_LOG_DIR}/access.log combinedOptions Indexes FollowSymLinks MultiViewsAllowOverride allOrder allow,denyallow from all# 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

保存退出到bash中,把站点链接到enable中:

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

配置ok了,注意配置文件中,DocumentRoot 必须是存在并且可以访问的目录,因为新站点存放在这里头,被apache提供给用户访问

另外,servername,设置成刚刚解析的新域名名字,cname的那个,注意了哟

重启apache

sudo service apache2 restart

最后把新网站的文件拷贝到/var/www/sunjob-app/下,你们拷贝到自己命名配置的目录下即可,浏览器输入站点新域名即可访问了,最后献上我的效果图,晚安

转载于:https://blog.51cto.com/12883930/1922873

apache配置多个站点相关推荐

  1. 模块目录下site.php,使用apache配置为每个站点指定PHP包含目录

    我最近切换到fastcgi,现在我有一个问题,设置以前在.htaccess中设置的php include路径为: php_value include_path "[INCLUDE PATH] ...

  2. centos7虚拟机apache 配置多站点。

    1.需求如下 2.了解apache 默认配置文件, 网站默认部署到那个文件夹 默认网站主页存放目录 /var/www **主配置文件:/etc/httpd/conf/httpd.conf ** Apa ...

  3. apache配置CA证书通过https通信

    Apache Httpd 2.2 实现https加密通讯 实际生产中CA证书一般是向一些专业认证的国际机构来进行申请的.我们会模拟使用OpenSSL生成的证书,来实现Apache的安全加密通讯,这与实 ...

  4. Apache配置(转载)

    Apache配置 http://grid.tsinghua.edu.cn/home/liulk/publish/computer/ApacheConfig.html Linux Apache Web ...

  5. nginx 多php项目配置文件,nginx 配置文件配置多个站点

    nginx环境下配置多个站点 一.找到nginx的配置文件 一般会在/etc/nginx/nginx.conf 二.修改配置文件我的配置文件如下,其中server 包括的内容是一个对象 一个网站对应一 ...

  6. Nginx-一个IP配置多个站点

    对于Nginx,一个IP上配置多个站点还是很常见的.尤其是在开发环境上,更是如此. 下面在我的阿里云上简单的实现这样一个需求: 在一个IP上通过对端口区分来配置多个站点. 环境 初始化 目录一览 配置 ...

  7. Ubuntu 网络应用服务器 Apache 配置基础

    配置文件 官方发布的 Apache 的主配置文件是 httpd.conf, 服务器还会读取一个包含 MIME 文件类型的文件,其文件名由 TypesConfig 指令确定,默认值是mime.types ...

  8. Apache 配置文件管理

    1. Apache配置系统 从整体来看apache的配置系统包括三个部分: (1) 配置文件:比如 httpd.conf   .htaccess (2) 配置指令:在配置文件 httpd.conf  ...

  9. Apache配置错误AH00558:无法可靠地确定服务器的标准域名

    Common Apache Errors 常见的Apache错误 This tutorial series explains how to troubleshoot and fix some of t ...

最新文章

  1. html5 ar开发,HTML5 WebAR开发
  2. 百度推送 android7.1,【SDK版本更新】Android SDK 5.7.1
  3. 深信服5月26日笔试
  4. mac os 安装 pkg-config
  5. 计算机课数学,这4个专业,对数学要求很高,数学不好的慎选!
  6. 谷歌:CNN击败Transformer,有望成为预训练界新霸主!LeCun却沉默了...
  7. 1-2.Win10系统利用Pycharm社区版安装Django搭建一个简单Python Web项目的步骤之二
  8. RSA加密、解密、签名、校验签名
  9. Kylin Cube构建优化
  10. Prometheus自动发现Exporter实现方案(一看就懂)
  11. authware链接html文件,authorware是什么软件?
  12. PMP考试通关宝典-敏捷专题
  13. 你专属的程序员春节“大礼包”
  14. 适合初学者的PASCAL VOC2012数据集的下载及简单讲解
  15. 74cms 5.0.1版本文件包含漏洞复现
  16. vue开发钉钉微应用鉴权失败
  17. 通用代码:发送短信并显示倒计时
  18. 如何在React.js文件中设置标签的背景图片
  19. docker安装mosquitto2.0.14问题
  20. 你关心的问题都在这!爱奇艺用户留存预测挑战赛Baseline上线

热门文章

  1. JS 判断变量类型(判断数据类型、typeof)
  2. python 文件按行读写
  3. HWM和delete,drop,truncate的关系
  4. weak password
  5. 认清业务、技术与软件系统的价值链
  6. DevExpress中获取GridControl排序之后的List
  7. 说说说vue.js中的组
  8. Ajax提交打开新窗口,浏览器拦截处理;以及跨域问题
  9. 深入php面向对象和模式
  10. (转)Enterprise Architect 7.0入门教程