Mac OS X中使用XAMPP

XAMPP(Apache+MySQL+PHP+PERL)是一个功能强大的建站集成软件包。支持Windows、Linux、Solaris、Mac OS X 等多种操作系统下安装使用,支持多语言。对于刚接触PHP后台开发的同学来说,省了很多事情,可以快速建立自己的服务器。

下载地址

XAMPP选择OS X系统最好下载最新的版本。

  • 下载后按照提示安装完成后,开启的界面应该是这样的。
Mac OS X中使用XAMPP_第1张图片

配置虚拟主机

  • 在终端运行vim /Applications/XAMPP/etc/httpd.conf,打开XAMPP Apche的配置文件
  • 找到#Include /private/etc/apache2/extra/httpd-vhosts.conf,去掉前面的“#”。
    找到下面内容:

    AllowOverride none
    Require all denied

改为:


    AllowOverride none
#    Require all denied
     Require all granted

保存并退出。

  • 在终端运行 vi /Applications/XAMPP/etc/extra/httpd-vhosts.conf打开配置虚拟主机文件httpd-vhost.conf,配置虚拟主机。注释掉默认的两个虚拟主机。添加自己的虚拟主机:
#
# VirtualHost example:
# Almost any Apache directive may go into a VirtualHost container.
# The first VirtualHost section is used for all requests that do not
# match a ServerName or ServerAlias in any  block.
#
#
#    ServerAdmin [email protected]
#    DocumentRoot "/Applications/XAMPP/xamppfiles/docs/dummy-host.example.com"
#    ServerName dummy-host.example.com
#    ServerAlias www.dummy-host.example.com
#    ErrorLog "logs/dummy-host.example.com-error_log"
#    CustomLog "logs/dummy-host.example.com-access_log" common
#

#
#    ServerAdmin [email protected]
#    DocumentRoot "/Applications/XAMPP/xamppfiles/docs/dummy-host2.example.com"
#    ServerName dummy-host2.example.com
#    ErrorLog "logs/dummy-host2.example.com-error_log"
#    CustomLog "logs/dummy-host2.example.com-access_log" common
#



# This is not needed but seriously recommended
    ServerAdmin [email protected]
# Path to your folder
    DocumentRoot "/Users/aimoke/Documents/MyPHPWorkspace/dev"
# This line is your host name (example.dev if you prefere)
    ServerName local.design.com
# You can add another server name using ServerAlias
    ServerAlias zhuo.dev
# For the error file, exactly like you did
    ErrorLog "/private/var/log/apache2/sites-error_log"
    CustomLog "/private/var/log/apache2/sites-access_log" common
# A little bonus that remove the server signature from http requests
    ServerSignature Off
# Here are options neeeded to authorizations and I added some classical options
 
    Options -Indexes +FollowSymLinks +MultiViews
    AllowOverride all
    Require all granted
 

保存并退出,并重启Apache。这里的ServerAdminDocumentRoot,ServerName可以根据自己的实际情况进行修改。但是ServerName要和下一步骤hosts中对应起来。

  • 运行sudo vi /etc/hosts,打开hosts配置文件,加入127.0.0.1 local.design.com,这样就可以配置完成 XAMPPlocal.design.com虚拟主机了。

其实XAMPP的配置和Mac OS X中配置Apache基本一样。但是需要注意的是不要和系统自带的Apache同时开启。

你可能感兴趣的:(Mac OS X中使用XAMPP)