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. 从mysql向HBase+Phoenix迁移数据的心得总结

    * 转载请注明出处 - yosql473 - 格物致知,经世致用 mysql -> HBase + Phoenix 1.总体方案有哪些? 1)通过Sqoop直接从服务器(JDBC方式)抽取数据到 ...

  2. 『高性能模型』Roofline Model与深度学习模型的性能分析

    转载自知乎:Roofline Model与深度学习模型的性能分析 在真实世界中,任何模型(例如 VGG / MobileNet 等)都必须依赖于具体的计算平台(例如CPU / GPU / ASIC 等 ...

  3. python标准库总的random函数用法

    Python标准库中的random函数,可以生成随机浮点数.整数.字符串,甚至帮助你随机选择列表序列中的一个元素,打乱一组数据等.random中的一些重要函数的用法:1 ).random() 返回0& ...

  4. 搭建k8s(一)

    安装VMWare VMWare官网地址 点击下载-->WorkStation Pro-->点击linux免费试用版 下载安装完成后,创建一个虚拟机,去centos官网找到centos7is ...

  5. PAT 1132 Cut Integer

    1132 Cut Integer (20 分)   Cutting an integer means to cut a K digits lone integer Z into two integer ...

  6. nodeJs安装Vue-cli

    1,安装nodejs安装包,注意安装的路径 2,安装完成node,node有自带的npm,可以直接在cmd中,找到nodeJs安装的路径下,进行命令行全局安装vue-cli.(npm install ...

  7. spiflash

    1.SPI Flash (即SPI Nor Flash)是Nor Flash的一种:2.NOR Flash根据数据传输的位数可以分为并行(Parallel)NOR Flash和串行(SPI)NOR F ...

  8. Cognos集成至portal平台查看报表报错RSV-BBP-0022

    1. 问题描述 绝对密切性请求“asynchWait_Request”失败,所请求的会话不存在. 2. 问题分析 Session会话传递失败. 3. 解决方案 将cognos所在服务器地址IP添加进I ...

  9. js删除数组中元素 delete 和splice的区别

    例如我有一个数组: var array = ["aa","dd","cc","aa"] ,我想删除这个数组的“dd”元素 ...

  10. 干货!一篇文章集合所有Linux基础命令

    1 文件{ls -rtl # 按时间倒叙列出所有目录和文件 ll -rttouch file # 创建空白文件rm -rf 目录名 # 不提示删除非空目录(-r:递归删除 -f强制)dos2unix ...