Home  >  Article  >  Backend Development  >  Compile and install php under Apple Mac OS X

Compile and install php under Apple Mac OS X

伊谢尔伦
伊谢尔伦Original
2016-12-02 11:21:011609browse

The PHP version that comes with OS PHP, and some common extension modules are enabled.

The purpose of this compilation and installation is to use Nginx to run PHP through FastCGI to build an LNMP environment under OS X.

Download and install the dependencies required in the compilation options

All dependent libraries are compiled and installed under the /usr/local/lib path. If the path does not exist, create it manually first.

libmhash (encryption extension library)

# 下载页: http://sourceforge.net/projects/mhash/
# 当前版本: http://ncu.dl.sourceforge.net/project/mhash/mhash/0.9.9.9/mhash-0.9.9.9.tar.gz
$ tar zxvf mhash-0.9.9.9.tar.gz
$ cd mhash-0.9.9.9
$ ./configure --prefix=/usr/local/lib/libmhash
$ make
$ sudo make install

libmcrypt (encryption extension library)

# 下载页: http://mcrypt.hellug.gr/lib/
# 当前版本: ftp://mcrypt.hellug.gr/pub/crypto/mcrypt/libmcrypt/libmcrypt-2.5.7.tar.gz
$ tar zxvf libmcrypt-2.5.7.tar.gz
$ cd libmcrypt-2.5.7
$ ./configure --prefix=/usr/local/lib/libmcrypt
$ make
$ sudo make install

libiconv (character encoding conversion library)

# 下载页: http://www.gnu.org/software/libiconv/
# 当前版本: http://ftp.gnu.org/pub/gnu/libiconv/libiconv-1.14.tar.gz
$ tar zxvf libiconv-1.14.tar.gz
$ cd libiconv-1.14
$ ./configure --prefix=/usr/local/lib/libiconv
$ make
$ sudo make install

libpng (png image processing, GD library dependency)

# 下载页: http://www.libpng.org/pub/png/libpng.html
# 当前版本: http://ncu.dl.sourceforge.net/project/libpng/libpng16/1.6.17/libpng-1.6.17.tar.gz
$ tar zxvf libpng-1.6.17.tar.gz
$ cd libpng-1.6.17
$ ./configure --prefix=/usr/local/lib/libpng
$ make
$ sudo make install

libjpeg (jpg image processing, GD Library dependencies)

# 下载页: http://www.ijg.org/
# 当前版本: http://www.ijg.org/files/jpegsrc.v9a.tar.gz
$ tar zxvf jpegsrc.v9a.tar.gz
$ cd jpeg-9a
$ ./configure --prefix=/usr/local/lib/libjpeg
$ make
$ sudo make install

Compile and install PHP

$ tar zxvf php-5.6.8.tar.gz
$ cd php-5.6.8
$ ./configure \
    --prefix=/usr/local/php \
    --with-config-file-path=/usr/local/php \
    --with-mysql \
    --with-mysqli \
    --enable-pdo \
    --with-pdo-mysql \
    --with-mysql-sock=/tmp/mysql.sock \
    --enable-opcache \
    --enable-cgi \
    --enable-fpm \
    --enable-sockets \
    --enable-mbstring \
    --enable-mbregex \
    --enable-bcmath \
    --enable-xml \
    --enable-zip \
    --with-zlib \
    --with-gd \
    --with-png-dir=/usr/local/lib/libpng \
    --with-jpeg-dir=/usr/local/lib/libjpeg \
    --with-openssl \
    --with-curl \
    --with-mhash=/usr/local/lib/libmhash \
    --with-mcrypt=/usr/local/lib/libmcrypt \
    --with-iconv=/usr/local/lib/libiconv
$ make
$ sudo make install
$ sudo cp php.ini-development /usr/local/php/php.ini
$ cd /usr/local/php/etc
$ sudo cp php-fpm.conf.default php-fpm.conf

If no errors are reported in the above steps, the new PHP will be installed successfully here.


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