在Mac 系统上使用MAMP搭建PHP开发环境

时间:2022-01-13 13:51:21

1.下载MAMP套件

下载地址为https://www.mamp.info/en/

2.安装此.dmg文件

3.配置apache虚拟主机

(1)在/Applications/MAMP/conf/apache中找到httpd.conf文件

在此文件中找到

# Virtual hosts

Include /Applications/MAMP/conf/apache/extra/httpd-vhosts.conf

去除前面的#

(2)在/Applications/MAMP/conf/apache/extra中找到httpd-vhosts.conf文件,配置虚拟主机如下代码:

<VirtualHost *:80>
    ServerAdmin localhost
    DocumentRoot "/Applications/MAMP/htdocs/"
    ServerName localhost
    ErrorLog "logs/localhost-error_log"
    CustomLog "logs/localhost-access_log" common
    DirectoryIndex index.html index.htm index.php
    <Directory />
        Options FollowSymLinks
        #不允许别人修改我们的页面
        AllowOverride None
        #设置访问权限
        order deny,allow
        Allow from all
    </Directory>
</VirtualHost>

(3)配置/etc/hosts文件如下:

127.0.0.1       localhost
255.255.255.255 broadcasthost
::1             localhost

127.0.0.1       www.test.com
127.0.0.1       local.erp.com

4.测试:

在浏览器中输入localhost:8888/index.php