


mac OS X comes with a PHP environment, and there is no freetype solution
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.

Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

Video Face Swap
Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Article

Hot Tools

Notepad++7.3.1
Easy-to-use and free code editor

SublimeText3 Chinese version
Chinese version, very easy to use

Zend Studio 13.0.1
Powerful PHP integrated development environment

Dreamweaver CS6
Visual web development tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)

Hot Topics



PHP 8.4 brings several new features, security improvements, and performance improvements with healthy amounts of feature deprecations and removals. This guide explains how to install PHP 8.4 or upgrade to PHP 8.4 on Ubuntu, Debian, or their derivati

Visual Studio Code, also known as VS Code, is a free source code editor — or integrated development environment (IDE) — available for all major operating systems. With a large collection of extensions for many programming languages, VS Code can be c

If you are an experienced PHP developer, you might have the feeling that you’ve been there and done that already.You have developed a significant number of applications, debugged millions of lines of code, and tweaked a bunch of scripts to achieve op

JWT is an open standard based on JSON, used to securely transmit information between parties, mainly for identity authentication and information exchange. 1. JWT consists of three parts: Header, Payload and Signature. 2. The working principle of JWT includes three steps: generating JWT, verifying JWT and parsing Payload. 3. When using JWT for authentication in PHP, JWT can be generated and verified, and user role and permission information can be included in advanced usage. 4. Common errors include signature verification failure, token expiration, and payload oversized. Debugging skills include using debugging tools and logging. 5. Performance optimization and best practices include using appropriate signature algorithms, setting validity periods reasonably,

This tutorial demonstrates how to efficiently process XML documents using PHP. XML (eXtensible Markup Language) is a versatile text-based markup language designed for both human readability and machine parsing. It's commonly used for data storage an

A string is a sequence of characters, including letters, numbers, and symbols. This tutorial will learn how to calculate the number of vowels in a given string in PHP using different methods. The vowels in English are a, e, i, o, u, and they can be uppercase or lowercase. What is a vowel? Vowels are alphabetic characters that represent a specific pronunciation. There are five vowels in English, including uppercase and lowercase: a, e, i, o, u Example 1 Input: String = "Tutorialspoint" Output: 6 explain The vowels in the string "Tutorialspoint" are u, o, i, a, o, i. There are 6 yuan in total

Static binding (static::) implements late static binding (LSB) in PHP, allowing calling classes to be referenced in static contexts rather than defining classes. 1) The parsing process is performed at runtime, 2) Look up the call class in the inheritance relationship, 3) It may bring performance overhead.

What are the magic methods of PHP? PHP's magic methods include: 1.\_\_construct, used to initialize objects; 2.\_\_destruct, used to clean up resources; 3.\_\_call, handle non-existent method calls; 4.\_\_get, implement dynamic attribute access; 5.\_\_set, implement dynamic attribute settings. These methods are automatically called in certain situations, improving code flexibility and efficiency.
