1.修改/private/etc/hosts 文件,建议用编辑器打开
最后一行加入你的网站名称(自定义),参考如下:
127.0.0.1 www.MyObj.com
 
2.修改/private/etc/apache2/httpd.conf 文件,建议用编辑器打开
查找“httpd-vhosts.conf”,找到如下代码:
#Include conf/extra/httpd-vhosts.conf
 
去掉最前面的#,并保存(保存的时候需要输入密码)
 
3.修改/private/etc/apache2/extra/httpd-vhosts.conf文件  ,建议用编辑器打开
滚动到最下面,看到如下2段类似的代码:
<VirtualHost *:80>
    ServerAdmin webmaster@dummy-host.example.com
    DocumentRoot "/usr/docs/dummy-host.example.com"
    ServerName dummy-host.example.com
    ServerAlias www.dummy-host.example.com
    ErrorLog "/private/var/log/apache2/dummy-host.example.com-error_log"
    CustomLog "/private/var/log/apache2/dummy-host.example.com-access_log" common
</VirtualHost>
 
<VirtualHost *:80>
    ServerAdmin webmaster@dummy-host2.example.com
    DocumentRoot "/usr/docs/dummy-host2.example.com"
    ServerName dummy-host2.example.com
    ErrorLog "/private/var/log/apache2/dummy-host2.example.com-error_log"
    CustomLog "/private/var/log/apache2/dummy-host2.example.com-access_log" common
</VirtualHost>
 
修改后如下,其实只是复制一段,然后修改了“DocumentRoot”(文件夹地址)和“ServerName”(访问域名,需要与第一步的设置吻合) 第一段是新增的自定的域名,第二,第三段是为了保证localhost,127.0.0.1的方式仍然可以登陆(其实也是自定的方式,只不过把域名特地写成习惯的localhost和127.0.0.1)
<VirtualHost *:80>
    ServerAdmin webmaster@dummy-host.example.com
    DocumentRoot "/Library/WebServer/Documents/MyObj"
    ServerName www.MyObj.com
    ServerAlias www.dummy-host.example.com
    ErrorLog "/private/var/log/apache2/dummy-host.example.com-error_log"
    CustomLog "/private/var/log/apache2/dummy-host.example.com-access_log" common
</VirtualHost>
 
<VirtualHost *:80>
    ServerAdmin webmaster@dummy-host.example.com
    DocumentRoot "/Library/WebServer/Documents"
    ServerName localhost
    ServerAlias www.dummy-host.example.com
    ErrorLog "/private/var/log/apache2/dummy-host.example.com-error_log"
    CustomLog "/private/var/log/apache2/dummy-host.example.com-access_log" common
</VirtualHost>
 
<VirtualHost *:80>
    ServerAdmin webmaster@dummy-host2.example.com
    DocumentRoot "/Library/WebServer/Documents"
    ServerName 127.0.0.1
    ErrorLog "/private/var/log/apache2/dummy-host2.example.com-error_log"
    CustomLog "/private/var/log/apache2/dummy-host2.example.com-access_log" common
</VirtualHost>
 
4.重启apache即可,终端命令:sudo apachectl restart
 
5.如果还要新增域名,将重复第1和第3步,
 
mamp配置多站点(mamp是mac下的一个php环境配置集成app,具体可以百度)
1.跟内置共用hosts 文件,所以添加的域名同样写到这个文件里面,参考上面的做法即可;
2.另外2份文件在/Applications/MAMP/conf 文件夹中,按照上面的方式进行修改即可,修改完毕后,重置。
3.备注:
奇怪的是,启动内置PHP的时候,也能访问mamp新建的域名,但是文件不是mamp下的文件,还是内置文件下的文件。相同的,启动mamp也能使用内置PHP新建的域名,但是访问的文件不是内置PHP的。这个很奇怪,还需要继续深究?????可能跟共用hosts文件有关。

mac 内置PHP配置多站点的更多相关文章

  1. 使用Karabiner为Mac内置键盘、HHKB进行映射

    使用Karabiner为Mac内置键盘.HHKB进行映射 Table of Contents 1. 引言 2. 什么是Karabiner和配置方法的基本说明 3. 内置键盘设置 4. HHKB设置 5 ...

  2. 一个禁用mac内置键盘的方法

    一个禁用mac内置键盘的方法 强大的 karabiner, 非常好用. 可以直接在有外接键盘连接的情况下, 禁用掉内置键盘 另外一个方法是启用mac的 鼠标键, 感觉用处不是很大, 修饰健并没有被禁用 ...

  3. mac内置的FTP工具

    在 Mac OS X 系统下,有不少优秀的 FTP 工具,如 Cyberduck.Transmit,但是你是否知道除了这些第三方应用,系统已经为你准备好了一个内置的 FTP 工具?/ M: e0 J% ...

  4. 内置Jetty配置JSP支持过程中的常见报错

    目录 1. 常见报错及解决 1.1 JSP support not configured 1.2 JSTL标签解析 1.3 JSP编译 1.4 JSP实现依赖 1.5 EL表达式支持 2. 小结 1. ...

  5. solr5.5 基于内置jetty配置 Ubuntu

    下载地址:http://archive.apache.org/dist/lucene/solr/ 在你的目录下直接解压 tar -zxvf xxxxxx.tgz 现在就可以直接开启solr了bin/s ...

  6. springboot内置tomcat配置虚拟路径

    在Springboot中默认的静态资源路径有:classpath:/METAINF/resources/,classpath:/resources/,classpath:/static/,classp ...

  7. Spring —— 三种配置数据源的方式:spring内置、c3p0、dbcp

    01.Spring内置数据源配置Class:DriverManagerDataSource全限定名:org.springframework.jdbc.datasource.DriverManagerD ...

  8. 【摸鱼神器】UCode Cms管理系统 内置超好用的代码生成器 解决多表连接痛点

    一.序言 UCode Cms管理系统是面向企业级应用软件开发的脚手架.当前版本1.3.4.快速体验: git clone https://gitee.com/decsa/demo-cms.git (一 ...

  9. EXT心得--并非所有的items配置对象都属于EXT的内置类

    之前我对EXT的items中未指明xtype的配置对象有一个错误的认识--即虽然某个items未指明它下面的某个组件的xtype,但这个组件肯定属性EXT的某个类.然而今天在查看actioncolum ...

随机推荐

  1. postman(十一):添加cookie

    有些接口在调用时,需要提供权限,如下 这个时候可以通过添加cookie的方式跳过验证 为了更方便地获取cookie等信息,可以在chrome中安装一个插件:Postman Interceptor,配合 ...

  2. Fragment调用startActivityForResult导致的回调Activity无法获取正确的requestId的问题

    今天遇到了一个问题 从Fragment内调用了startActivityForResult方法设置了requestId是1 但是在Activity内的onActivityResult的回调内 获得的r ...

  3. ZJOI2019Day2AFO记

    题目读下来感觉,,,怎么看上去模型都这么简单全是套路题的样子.先想了下T3应该会50,是个计算几何,50够了..于是先写了40(10分等下再来写)这样就花掉了一个小时.....过去看T1,直接高斯消元 ...

  4. sudo命令

    su命令 switch user的缩写, 意为切换至指定用户执行命令 常用选项 -c<指令>或--command=<指令>:执行完指定的指令后,即恢复原来的身份: -f或——f ...

  5. win10安装配置nodejs

    下载node 官网下载node 接下来在命令提示符里(win+R)输入node -v和npm -v,如图所示,表示安装完成.   测试,   配置node 在nodejs文件目录下,新建文件夹node ...

  6. .gitconfig

    [user] name = 1111 email = 111@111.com[credential] helper = store

  7. servlet进行用户名和密码校验

    效果截图: 链接:https://pan.baidu.com/s/1eR051bUPerpEM3TDLtq9Xw 提取码:rjpy

  8. python之路-----python操作 mysql

    ========================pymysql============================ 一.pymysql 基础 安装命令:pip3 install pymysql - ...

  9. c++面试题一

    c++面试题 1.是不是一个父类写了一个virtual函数,如果子类覆盖他的函数不加virtual, 也能实现多态? virtual 修饰符会被隐形继承的. private也被集成,只事派生类没有访问 ...

  10. git hub 的使用步骤

    1:准备环境 ①电脑已安装git ②注册github账号 一:使用git控制台进行本地操作 ①打开 GitBash ②填写用户名和邮箱作为标识 分别输入以下命令: git config  --glob ...