Mac OS x comes with PHP environment, no FreeType workaround

Source: Internet
Author: User
Tags php source code
Recently use their own computer to do a small thing, need to use the verification code, with the thinkphp framework, TP Verification code needs FreeType Library support, MAC OS X with Apache and PHP, directly configured can be used, very convenient, and extended support is more, very convenient, But FreeType no, it's a problem,
In fact, there is no trouble, add a support can be, if in the Linux server environment, are good to do, or self-compiled environment to do, but is because of the use of the environment, but also do not want to change the system too much, because it is feared that the system has other components need to bring Apache or PHP support, Change and will cause other problems, so it becomes a bit of trouble, the Internet is a word, recompile PHP, increase freetype support, but specifically did not say, these two days just idle to nothing, toss a bit, fix,
My idea is to PHP-related things, re-download the installation, so as not to destroy the original environment, while backing up/usr/libexec/apache2/libphp5.so this file, and renamed to Libphp5-ox.so. and then in/etc/apache2/ Add one in httpd.conf:
#LoadModule Php5_module libexec/apache2/libphp5-ox.so
This makes it easy to switch between PHP and the newly compiled PHP
First of all:
Download GD:
Https://github.com/libgd/libgd/releases
Libgd-2.1.1.tar.gz
PNG and JPEG are required and can be installed via brew, as well as liftoff and LIBVPX libraries
Brew Install Libpng
Brew Install Libjpeg
Brew Install Libtiff
Brew Install LIBVPX
Compile GD (note, use the corresponding library location for brew installation, PNG JPEG, etc.):
./configure--prefix=/usr/local/gd2--with-zlib--with-png=/usr/local/opt/libpng--with-freetype=/usr/local/opt/ FreeType--with-jpeg=/usr/local/opt/jpeg/--with-vpx=/usr/local/opt/libvpx/--with-tiff=/usr/local/opt/libtiff/
Then download a version of PHP from the PHP official website, can be different from the version within the system, does not matter,
It is important to note that the MAC system has a System File Protection feature (SIP) that will not even be accessible to the root user because we only want to replace PHP and not replace Apache. So PHP when compiling the libphp5.so needed to build Apache, it is necessary to put this file in the/usr/libexec/apache2/directory, and this directory is protected, all need to first turn off the system protection, the shutdown steps are as follows:
1. Restart your Mac, press and hold the Command+r key, and then release when you see the Mac icon
2. After booting into recovery mode, locate the terminal (Terminal) in the tool inside the menu and open it.
3. Use the command: Csrutil disable; to close, then reboot reboot.
If you want to enable again later, you can use csrutil enable;
And then
Compiling PHP
./configure--prefix=/usr/local/php/--with-config-file-path=/usr/local/php/--with-apxs2--enable-sockets-- Enable-mbstring--with-bz2=shared--with-ic--with-mysql--with-gd=/usr/local/gd2/--with-pdo-mysql
Here again encountered the evil dependency system processing, the first is reported:
' x11/xpm.h ' File not found
This prompts you to install the LIBXPM package as follows:
libxpm-3.5.5.tar.bz2
However, installing this package also prompts you to:
No package ' x11 ' found
No package ' Xproto ' found
Re-install:
Libx11-1.5.0.tar.gz
and Xproto this bag,
When installing X11, there will be a string of dependent packages, no way, slowly installed
Here's a note.
Because there are too many packages, and these packages use Pkg-config to check dependencies, you need to install Pkg-config (this can also be installed using brew).
and Pkg-config check that the dependency is through the environment variable: pkg_config_path to check the corresponding package of PC files, so my approach is that all the installation of these packages are placed in a directory, and then configure the environment variables:
Export Pkg_c/local/xproto/lib/pkgconfig:/usr/lib/pkgconfig:/usr/local/lib/pkgconfig
The next tip less which package, go to find the corresponding package, download tar.gz format,
Then unzip,
Unified Installation Path:
./configure-prefix=/usr/local/xproto
Tips: The corresponding package, most of them can be
lists.freedesktop.org
And
ftp://ftp.x.org/pub/X11R7.7/
These two found inside.

Do not want to struggle to find, I put the package I downloaded in the process of uniform packaging put up, for everyone to download, the address is as follows:

http://download.csdn.net/detail/sdomain/9432886

After all packages are installed, the final

libxpm-3.5.5.tar.bz2
On this outfit,

Finally compile PHP to increase the xpm extension.

./configure--prefix=/usr/local/php/--with-config-file-path=/usr/local/php/--with-apxs2--enable-sockets-- Enable-mbstring--with-bz2=shared--with-ic--with-mysql--with-gd=/usr/local/gd2/--with-pdo-mysql--with-xpm-dir=/ Usr/local/xproto

Configure no problem, but make, prompt gd.c file cannot find x11/xpm.h This header file, very strange, clearly I designated-with-xpm-path=/usr/local/xproto, and this path include/x11/ Here's the xpm.h file,

-with-xpm-path=/usr/local/xproto/include so change, configure and pass,
It is not possible to change the include path in GD.C into include/x11/xpm.h.
Finally I copy the/usr/local/xproto/include below the X11 folder to PHP source code under the Ext/gd/folder, compile no problem, make install also no problem,
I estimate is the PATH environment variable problem, if change $path add a/usr/local/xproto/include estimate also can, interested can try.

The above describes the Mac OS x comes with PHP environment, there is no freetype solution, including aspects of the content, I hope that the PHP tutorial interested in a friend helpful.

  • Contact Us

    The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

    If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

    A Free Trial That Lets You Build Big!

    Start building with 50+ products and up to 12 months usage for Elastic Compute Service

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.