win7:------------------------------------------------------------------------

NameVirtualHost *:80
<VirtualHost *:80>
  DocumentRoot "D:/wampserver/www/"
  ServerName localhost
</VirtualHost>

<VirtualHost *:80>
  ServerName www.member.com
  DocumentRoot "D:/wampserver/www/MemberShip/"
  <Directory "D:/wampserver/www/MemberShip/">
    DirectoryIndex index.php index.php3 index.html index.htm
    #重写需加以下第一行
    AllowOverride All
    Options Indexes FollowSymLinks
    Order Allow,Deny
    Allow from all
  </Directory>
</VirtualHost>


ubuntu:------------------------------------------------------------------------------在apache2.4中,虚拟主机的目录是通过/etc/apache2/sites-available中配置的,默认情况下,apache有一个默认的虚拟主机文件叫000-default.conf。我们将会复制000-default.conf文件内容到我们新的虚拟主机配置文件中。
sudo cp /etc/apache2/sites-available/000-default.conf /etc/apache2/sites-available/yiidemo.conf 

编辑该配置文件,用来指向刚才设定的目录。

sudo vim  /etc/apache2/sites-available/yiidemo.conf

编辑后的配置如下(删除了额外的注释):

(linux下注意,如果是复制粘贴以下内容,注意前面的空格需要替换,linux和windows下的编码不一样)

NameVirtualHost *:80
<VirtualHost *:80>
  DocumentRoot "/var/www/"
  ServerName localhost
</VirtualHost>
<VirtualHost *:80>
  ServerName www.member.com
  DocumentRoot "/var/www/MemberShip/"
  <Directory "/var/www/MemberShip/">
    DirectoryIndex index.php index.php3 index.html index.htm
    #重写需加以下第一行
    AllowOverride All
    Options Indexes FollowSymLinks
    Order Allow,Deny
    Allow from all
  </Directory>
</VirtualHost>

重启apache服务器:
sudo service apache2 restart

修改虚拟主机文件后,禁用默认的虚拟主机配置(000.default.conf),然后启用新的虚拟主机配置,如下所示。

sudo a2dissite -default.conf (**这一步不是必须的**)
sudo a2ensite  yiidemo.conf

这一步,将激活yiidemo.conf配置文件。他的作用是生产一份链接到/etc/apache2/sites-enabled/,为什么这样做呢,因为实际上apache2加载的就是该目录下所有的配置文件。而a2dissitea2ensite这两个动作,能更好的管理我们的虚拟主机。

sudo service apache2 restart  

配置虚拟主机,如果你是window系统,可以在C:\Windows\System32\drivers\etc找到host文件,如果你是linux系统可以在/etc/hosts找到host文件,编辑他们加上刚才配置的虚拟主机映射的IP地址。

192.168.*.* www.yiidemo.local  (**IP地址为apache服务器所在的主机地址**)

.htaccess文件:

RewriteEngine on

# if a directory or a file exists, use it directly
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d

RewriteRule ^(.*)$ /index.php/$1

XXX/config/main.php文件

'urlManager'=>array(
'urlFormat'=>'path',
'showScriptName' => false, //注意false不要用引号括上
'rules'=>array(
  'login/login/' => array('login/login/', 'urlSuffix'=>'.html', 'caseSensitive'=>false),

  ),

),

Linux + Apache + MySql+ Php 配置虚拟主机的更多相关文章

  1. WAMP Apache 2.5 配置虚拟主机

    1.在 Apache 的安装目录下 conf/httpd.conf 文件中搜索 hosts,去掉 Include 前面的 “#” 号后,即可启用虚拟主机. # Virtual hosts #Inclu ...

  2. linux上nginx上配置虚拟主机的相关配置

    1.配置主配置: nginx/conf/nginx.conf 2.虚拟主机配置:nginx/conf/extra/learn.weixin.com.conf 配置完后,重启服务器!

  3. Linux+Apache+MySQL+PHP配置教程

    有时我们只想搭建LAMP环境做个测试,并不在意目录的和配置是否规范,本教程正是为此想法而写能简单的就不复杂实现最快地搭建LAMP:操作系统为CentOS6.5. 1.安装Apache yum inst ...

  4. [Linux]Apache配置虚拟主机

    Apache 配置虚拟主机的方式很多,种类也很多,主要分为两类:   基于名称的虚拟主机 (每个 IP 多个站点) 基于 IP 的虚拟主机 (每个 IP 一个站点) 基于名称的虚拟主机:  www.2 ...

  5. Centos下安装配置LAMP(Linux+Apache+MySQL+PHP)

    Centos下安装配置LAMP(Linux+Apache+MySQL+PHP)   关于LAMP的各种知识,还请大家自行百度谷歌,在这里就不详细的介绍了,今天主要是介绍一下在Centos下安装,搭建一 ...

  6. lamp apache配置虚拟主机

    You don't have permission to access /index.php on this server

  7. linux配置虚拟主机

    linux 下怎么配置虚拟主机 linux 下怎么配置虚拟主机,在网上找到N个资料都是高手们随便说几句,都没怎么说清楚.问题:  我把域名(bs.jxiop.com)指向了 68.10.140.10 ...

  8. Apache配置虚拟主机后让其他电脑访问

    关于Apache配置虚拟主机后在局域网中让其他电脑访问 #test1# NameVirtualHost *:80         ServerName  www.t1.com     Document ...

  9. Linux配置虚拟主机后,只能访问到主页怎么办?

    Linux配置虚拟主机后,只能访问到主页怎么办? 今天配置了lamp后,添加了一个虚拟主机,配置http.conf后,增加虚拟主机,测试访问发现只有域名下能访问,ljt.com但是域名下所有的都访问不 ...

随机推荐

  1. java之NIO编程

    所谓行文如编程,随笔好比java文件,文章好比类,参考文献是import,那么目录就是方法定义. 本篇文章处在分析thrift的nonblocking server之前,因为后者要依赖该篇文章的知识. ...

  2. querySelector选择器

    querySelector选择器可以通过document和element来调用他们 用来代替getElementById var body=document.querySelector("b ...

  3. Linux中的搜索命令

    find find是最常见和最强大的查找命令,在磁盘中查找文件,用它找到任何你想找的文件,就是速度有点慢. find    path    -option    [    -print ]    [ ...

  4. PyQt5+python3的FindDialog

    import sys from PyQt5.QtWidgets import * from PyQt5.QtCore import Qt, pyqtSignal class FindDialog(QD ...

  5. crtmpserver的架构简介

    crtmpserver的架构简介 一.层 Layers . 机器层 Machine layer . 操作系统层 Operating System Layer   This layer is compo ...

  6. Socket 接收本地短连接并转发为长连接 多线程

    import java.io.IOException; import java.io.InputStream; import java.io.OutputStream; import java.io. ...

  7. 测试RegExp对象的属性

    //测试RegExp对象的属性function testRegExpProperty(){ var regexp = /abc/; //regexp.ignoreCase = true; //无效 c ...

  8. Input File 表单上传按钮美化

    HTML <div class="input-file-button"> 上传图片<input type="file" class=" ...

  9. PHPCMSV9 采集网址后,再采集内容,报错:“采集采集内容 没有找到网址列表,请先进行网址采集”

    解决方法:直接清除v9_collection_history 表里的内容.

  10. IEnumerable中的 Any方法

    IEnumerable类中的 Any方法,表示集合中有任何一元素满足条件,返回就true , 该方法有两个重载 1. 不带任何参数,表示集合中有元素 2. 参入一个 Func<TSource, ...