Home >Backend Development >PHP Tutorial >Build PHP environment on mac
1. Install various plug-ins first. The first one is the command line tool. After opening the terminal, enter xcode-select –install and install it after agreeing. The second one is HomeBrew. In the terminal, enter ruby -e "$(curl -fsSL https://raw.github.com/Homebrew/homebrew/go/install)"
The third one is to install autoconf, enter brew install autoconf
2. Start importing PHP packages in Mac.
Terminal input ./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. Solve the error
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
Go to Apple Official open source support: http://www.apple.com/opensource/Find and download zlib/libpng/jpeg/freetype/libgd required by GD. Here is a package and execution script:
tar -zxf gd.tar. gz
cd gd
sudo ./install
4) configure:error: Cannot locate header file libintl.h
install gettext
sudo brew install gettext
Edit the configure file, find $PHP_GETTEXT /usr/local /usr and add the path of gettext at the end $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
The above introduces how to set up a PHP environment on Mac, including various aspects. I hope it will be helpful to friends who are interested in PHP tutorials.