XAMPP常见问题

FAQ Alan 9年前 (2015-06-12) 4440次浏览 0个评论 扫描二维码

Mac OS下使用XAMPP的PHP

在terminal中输入which php查看显示的路径如果是/usr/bin/php则说明使用的是系统php,想要修改成XAMPP的PHP,临时修改,直接在terminal中执行

export PATH="/Applications/XAMPP/xamppfiles/bin:$PATH"

这时再输入which php,会发现已经更改为/Applications/XAMPP/xamppfiles/bin/php了,但这只是临时的方法,一旦关闭terminal就会失效。

另一种永久生效的方法是

sudo nano ~/.bash_profile
export PATH="/Applications/XAMPP/xamppfiles/bin:$PATH" //添加这段内容并保存

然后执行.bash_profile,重启terminal,再次运行which php时会发现显示的还是/Applications/XAMPP/xamppfiles/bin/php

如何在XAMPP上配置多站点?

XAMPP中默认的网站根目录在D:\xampp\htdocs下(以安装在D盘下为例),默认站点访问地址是http://localhost,这些实际上都可以通过配置来进行更改,这里以配置多站点来解释这个问题以及其它相关配置。

打开主配置文件D:\xampp\apache\conf\httpd.conf,取消Include conf/extra/httpd-vhosts.conf前面的注释即#,这样就可以像Linux一样进行多站点的配置。

打开D:\xampp\apache\conf\extra\httpd-vhosts.conf,删除NameVirtualHost *:80前面的#,然后在该文件最下面添加


    DocumentRoot "d:/site1"
    ServerName site1.local.com

    DocumentRoot "d:/site2"
    ServerName site2.local.com

...

根据具体情况可添加多个站点,当然要保证站点可以访问还需要修改host文件,C:\Windows\System32\Drivers\etc\hosts

127.0.0.1			site1.local.com
127.0.0.1			site2.local.com
...

这样多站点就配置好了,不过在这时如果访问http://site1.local.com,会出现如下报错:

Access forbidden!

You don't have permission to access the requested directory. There is either no index document or the directory is read-protected.

If you think this is a server error, please contact the webmaster.

Error 403

192.168.1.1
Apache/2.4.10 (Win32) OpenSSL/1.0.1h PHP/5.4.34

这是因为还缺少一步配置,没有设置访问权限,打开D:\xampp\apache\conf\httpd.conf,添加

<Directory "d:/site1">
Require all granted
Options Indexes FollowSymLinks MultiViews
AllowOverride all
Order Allow,Deny
Allow from all

...

这时重启一下Apache就大功告成了

Uncaught exception ‘PDOException’

以下错误出现在Mac环境下的Xampp中,报错是关于Magento的

Fatal error: Uncaught exception ‘PDOException’ with message ‘SQLSTATE[HY000] [2002] No such file or directory’ in /Applications/XAMPP/xamppfiles/htdocs/magento/lib/Zend/Db/Adapter/Pdo/Abstract.php:129

这一问题的解决方案是打开Terminal,创建一个软链接,具体指令如下:

sudo mkdir /var/mysql
cd /var/mysql
sudo ln -s /Applications/XAMPP/xamppfiles/var/mysql/mysql.sock
喜欢 (0)
[]
分享 (0)
发表我的评论
取消评论

表情 贴图 加粗 删除线 居中 斜体 签到

Hi,您需要填写昵称和邮箱!

  • 昵称 (必填)
  • 邮箱 (必填)
  • 网址