Rumah >pembangunan bahagian belakang >tutorial php >mac搭建PHP环境
1.先安装好各种插件,第一个是命令行工具,打开终端之后,输入xcode-select –install,同意之后进行安装。第二个是HomeBrew,终端输入ruby -e "$(curl -fsSL https://raw.github.com/Homebrew/homebrew/go/install)"
第三个安装autoconf,输入brew install autoconf
2.开始在Mac中导入PHP的包。
终端输入./buildconf --force
./configure--prefix=/usr/local/php7 --with-apxs2=/usr/sbin/apxs --enable-fpm--with-fpm-user=www --with-fpm-group=www --with-mysqli --with-pdo-mysql--with-iconv-dir --with-freetype-dir --with-jpeg-dir --with-png-dir --with-zlib--with-libxml-dir=/usr --enable-xml --disable-rpath --enable-bcmath--enable-shmop --enable-sysvsem --enable-inline-optimization --with-curl --enable-mbregex--enable-mbstring --with-mcrypt --enable-ftp --with-gd --enable-gd-native-ttf--with-openssl --with-mhash --enable-pcntl --enable-sockets --with-xmlrpc--enable-zip --enable-soap --without-pear --with-gettext --disable-fileinfo--enable-maintainer-zts
3.解决错误
1)configure: error: Cannot find OpenSSL's
brew install openssl
brew link openssl –force
2)configure: error: jpeglib.h not found.
brew install libjpeg
3)configure: error: png.h not found.
brew install libpng
4)freetype
前往苹果官方开源支持:http://www.apple.com/opensource/查找并下载GD需要的 zlib/libpng/jpeg/freetype/libgd,这里提供一个包及执行脚本:
tar -zxf gd.tar.gz
cd gd
sudo ./install
4) configure:error: Cannot locate header file libintl.h
安装 gettext
sudo brew install gettext
编辑 configure 文件,找到 $PHP_GETTEXT /usr/local /usr 在后面加上gettext的路径 $PHP_GETTEXT /usr/local /usr /usr/local/opt/gettext
5) configure: error: mcrypt.h not found. Please reinstall libmcrypt.
brew install wget
http://www.tuicool.com/articles/yaQnmi2
以上就介绍了mac搭建PHP环境,包括了方面的内容,希望对PHP教程有兴趣的朋友有所帮助。