mac mysql javascript_在Mac下配置php开发环境:Apache+php+MySql

/private/etc/apache2/httpd.conf

一、启动Apache

sudo apachectl start

sudo apachectl -v   可以查看到Apache的版本信息

此时在浏览器中输入http://localhost,会出现It works!的页面

sudo apachectl restart 重启Apache

二、运行PHP

1、找到Apache的配置文件,在目录/etc/apache2/下,打开Finder,选择"前往"-"前往文件夹",输入"/etc/apache2/",找到其中的"httpd.conf"文件,选择用文稿打开进行编辑,点按Command+F,搜索#LoadModule php5_module libexec/apache2/libphp5.so,如图

d1a0d05f4916df22447795a2b9ce3cd5.png

把蓝色那一行的#号去掉,然后保存,如果出现文本锁定,无法解锁的情况,解决办法有两种

a)选中该文件,右击后选择"显示简介",点击右下角的小锁的图标,输入电脑密码解锁,然后选择左边的+号键,选择自己当前电脑登陆的用户,将权限设置为读与写,如果还是不行,将其上一级文件夹权限同样再修改一次。

b)将该文件复制到桌面,进行修改,修改后再复制到原来的文件夹替换之前的文件即可。

2、重启Apache,在终端输入  sudo apachectl restart

3、在终端输入  sudo cp /Library/WebServer/Documents/index.html.en /Library/WebServer/Documents/info.php

即在Apache的根目录下复制index.html.en文件并重命名为info.php。

4、打开info.php,在It works后面加上<?php phpinfo(); ?>,然后再次重启Apache,在浏览器中输入http://localhost/info.php,会出现一个显示php信息的页面,如图所示。

6cf76b738d5b6be2eca51537c707d4e5.png

Mac下配置Apache时遇到的Forbidden

You don't have permission to access /HelloMac.htm on this server.

OS X升级到Yosemite之后,自带的Apache也从2.2升级到了2.4,访问权限的配置上有所不同。

以配置alise别名目录为例,把/Users/redraiment/workspace/映射到http://localhost/workspace/,在2.2版本中配置信息如下:

Alias /workspace "/Users/redraiment/workspace/"

AllowOverride All

Options Indexes MultiViews FollowSymLinks ExecCGI

Order allow,deny

Allow from all

DirectoryIndex index.html index.php

升级到2.4版本之后:Order allow,deny和Allow from all要改成Require all granted,如下所示:

Alias /workspace "/Users/redraiment/workspace/"

AllowOverride All

Options Indexes MultiViews FollowSymLinks ExecCGI

Require all granted

DirectoryIndex index.html index.php

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值