Home  >  Article  >  Backend Development  >  PHP-mac下的配置及运行

PHP-mac下的配置及运行

WBOY
WBOYOriginal
2016-06-23 13:50:201018browse

忙中抽闲(这样说 好么?),最近,在看公司代码的小间隙,换换脑子,在学习php。

没想到,再配置php的时候遇到了,很多问题,我简单的贴一下自己的配置过程吧。


首先明确,我用的是mac 而且os中已经有php。

终端输入 php -v 查看一下php版本



可以看出 我的电脑是php5.4


ok 下面配置一下 Apache

终端输入 “sudo apachectl start” 启动了 apache

在浏览器中 输入 localhost  就发现  php可以运行了


ok这是系统自带的php,下面我们就开始自己编写一下php页面

打开/Library(资源库)/WebServer/Documents/ 新建一个index.php

编辑index.php(注意有权限问题,如何处理自己想想办法,很简单的)

只写 

这是要打印php的具体信息

ok,其实此时 php还无法运行这个文件,需要改一下一处配置

终端运行 sudo vi /etc/apache2/httpd.conf 打开apache的配置文件 

找到“#LoadModule php5_module libexec/apache2/libphp5.so”,把前面的#号去掉,保存(在命令行输入:w)并退出vi(在命令行输入:q)

ok,终端输入 sudo apachectl restart 重启一下apache

再浏览器中输入 localhost/index.php 

这下就真ok了。


以上是手工编写php,我们一般借助IDE。

当然PHP的IDE很多,我选择的是PHPStorm

也遇到一个问题,如果你用自己电脑带的php可能运行不出来

先下载 phpstorm http://www.jetbrains.com/phpstorm/

安装完成后,输入以下License进行破解:

User name

EMBRACE

License key

===== LICENSE BEGIN =====

43136-12042010

00002UsvSON704l"dILe1PVx3y4"B3

49AU6oSDJrsjE8nMOQh"8HTDJHIUUh

gd1BebYc5U"6OxDbVsALB4Eb10PW8"

===== LICENSE END =====


ok 打开新建工程 新建php

打开终端输入

curl -s http://php-osx.liip.ch/install.sh | bash -s 5.5

安装php5.5(不用本机php 因为缺少php-cig)

phpstorm->preferences->php->Interpreter 右边方框

点开之后 PHPhome



ok 这下全部配置完成


感谢一下

http://jingyan.baidu.com/article/fea4511a4e191cf7bb912511.html

http://blog.csdn.net/jdj_1027/article/details/7732578

http://blog.csdn.net/meegomeego/article/details/36020553



Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn