Home > Backend Development > PHP Tutorial > mac OS X comes with a PHP environment, and there is no freetype solution

mac OS X comes with a PHP environment, and there is no freetype solution

WBOY
Release: 2016-07-29 09:03:33
Original
2506 people have browsed it

Recently, I used my computer to make something small and needed to use a verification code. I used the thinkPHP framework. The verification code for TP needs to be supported by the freetype library. OS X for MAC comes with APACHE and PHP. You can use it by configuring it directly. It is very It is convenient and has a lot of extension support, which is quite convenient, but freetype does not have it, which is a troublesome thing.
In fact, it is not troublesome at all. Just add a support. If you are in a Linux server environment, it is easy to handle, or you can compile it yourself. The environment is easy to handle, but because I use my own environment and I don’t want to change the system too much, I am afraid that there are other components in the system that need to have their own Apache or PHP support, and changing them will cause other problems, so I changed It’s a bit troublesome. Most of the answers on the Internet are about recompiling PHP and adding freetype support, but I haven’t mentioned the specifics. I just had nothing to do these two days, so I messed around and got it done.
My idea is to use PHP For related things, re-download and install them so as not to damage the original environment. At the same time, back up the file /usr/libexec/apache2/libphp5.so and rename it to libphp5-OX.so. Then in /etc/apache2/httpd.conf Add one:
#LoadModule php5_module libexec/apache2/libphp5-OX.so
This can easily switch between the built-in PHP and the newly compiled PHP
First:
Download gd:
https://github.com/libgd/ libgd/releases
libgd-2.1.1.tar.gz
Requires png and jpeg, which can be installed through brew, as well as liftoff and libvpx libraries
brew install libpng
brew install libjpeg
brew install libtiff
brew install libvpx
Compile GD (Pay attention to the corresponding library location installed by brew, 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. It can be different from the version in the system, it doesn’t matter.
It should be noted here that the MAC system has a system file protection function (SIP) Some directories will be inaccessible even to ROOT users, because we only want to replace PHP, not APACHE, so when PHP compiles and generates libphp5.so required by apache, it needs to put this file in /usr /libexec/apache2/ directory, and this directory is protected, so you need to turn off the system protection first. The shutdown steps are as follows:
1. Restart the MAC, press and hold the command+R key, and wait until you see the MAC icon Release
2. After booting into Recovery Mode, find Terminal in the tools menu and open it,
3. Use the command: csrutil disable; to close it, and then reboot.
If you want to enable it again in the future, you can use csrutil enable;.
Then
Compile 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 we encounter another evil dependency system To deal with it, first report:
'X11/xpm.h' file not found
Follow this prompt and you need to install the libXpm package, as follows:
libXpm-3.5.5.tar.bz2
But when installing this package, it will prompt:
No package 'x11' found
No package 'xproto' found
Reinstall:
libX11-1.5.0.tar.gz
With the xproto package,
there will be a series of dependent packages when installing X11, there is no way, slow Slow installation
There is a note here
Because there are too many packages, and these packages use pkg-config to check dependencies, so pkg-config needs to be installed (this can also be installed using brew,)
and pkg -config checks the dependencies through the environment variable: PKG_CONFIG_PATH to check the pc file of the corresponding package, so my method is to install all these packages in a directory, and then configure the environment variable:
export PKG_C/local/xproto /lib/pkgconfig:/usr/lib/pkgconfig:/usr/local/lib/pkgconfig
Next, if it prompts which package is missing, go to the corresponding package, download it in tar.gz format,
then unzip it,
unify the installation path :
./configure —prefix=/usr/local/xproto
Tips: Most of the corresponding packages can be passed through
lists.freedesktop.org
and
ftp://ftp.x.org/pub/X11R7.7 /
I found

in these two. I don’t want to bother to find it. I packaged the packages I downloaded during the installation process and put them up for everyone to download. The address is as follows:

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

After all packages are installed, finally install

libXpm-3.5.5.tar.bz2
,

finally compile PHP and add 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

There is no problem with configure, but when making, it prompts that the gd.c file cannot find the header file X11/xpm.h. It is very strange. I clearly specified —with-xpm-path=/usr/local/xproto, but There is the file xpm.h under include/X11/ in this path,

After changing --with-xpm-path=/usr/local/xproto/include like this, configure failed.
Changing the include path in gd.c to include/X11/xpm.h also didn’t work.
Finally I changed / Copy the X11 folder under usr/local/xproto/include to the ext/gd/ folder under the PHP source code. There is no problem with compilation, and there is no problem with make install.
I guess it is a problem with the path environment variable. If you change $ It is probably possible to add /usr/local/xproto/include to PATH. If you are interested, you can try it.

The above introduces the PHP environment that comes with mac OS X. There is no freetype solution, including the relevant content. I hope it will be helpful to friends who are interested in PHP tutorials.

Related labels:
source:php.cn
Statement of this Website
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template