天天看點

mac搭建php開發環境mac搭建php開發環境準備工具配置多站點測試

mac搭建php開發環境

準備工具

  • phpstorm: 下載下傳位址 http://www.520xiazai.com/soft/PhpStorm-2017.1.4-for-mac.html
  • xampp 下載下傳位址 http://dlsw.baidu.com/sw-search-sp/soft/30/25759/xampp-osx-7.0.2-1-installer.1454409575.dmg

配置多站點

  • 一 配置 httpd.conf 檔案,打開vhost開關

點選 xampp -> Manage Servers -> Apache Web Server -> Configure

-> Open Conf File

打開 httpd.conf

将這一行 #Include etc/extra/httpd-vhosts.conf 最前變的 # 去掉

  • 二 配置 httpd-vhosts.conf 檔案,添加站點目錄

點選 xampp -> Welcome -> Open Application Folder 打開程式主目錄

打開 etc -> extra -> httpd-vhosts.conf 檔案

添加以下内容:

#開始了vhost後localhost失效,是以重新添加localhost
<VirtualHost *:80>
    DocumentRoot "//Applications/XAMPP/xamppfiles/htdocs"
    ServerName localhost

    <Directory "/Applications/XAMPP/xamppfiles/htdocs">
     AllowOverride All
         Options Indexes FollowSymLinks
     Require all granted
    </Directory>

 ErrorLog "logs/dummy-host.example.com-error_log"
 CustomLog "logs/dummy-host.example.com-access_log" common
</VirtualHost>

#增加自己的目錄
<VirtualHost *:80>
    DocumentRoot "/Users/workspaces/www"
    ServerName www.udou.com

    <Directory "/Users/workspaces/www">
     AllowOverride All
         Options Indexes FollowSymLinks
     Require all granted
    </Directory>

</VirtualHost>
           
  • 三 添加hosts
#打開hosts檔案
sudo vim /etc/hosts
           

增加host

127.0.0.1 www.udou.com

測試

打開浏覽器

輸入 localhost

輸入 www.udou.com