Compile PHP + Imagick on Windows

Source: Internet
Author: User
Tags imagemagick php source code

PHP uses the Imagick extension to process images. The Imagick extension is based on ImageMagick, but the Imagick extension is not included in PHP. If you want to use it, you can either search for Binary files in Windows, either compile one by yourself. In Linux, these are not problems. However, there is very little information on Windows. The following describes the compilation process.

Preparation Process:

1. Download PHP source code and compilation tools
PHP source code can be downloaded from www.php.net, specific can go to the download page (http://www.php.net/downloads.php) to find.

Then go to the documentation page (http://www.php.net/docs.php) to find the help of the compilation process, the specific page is: http://www.php.net/manual/zh/install.windows.building.php.

You can download the relevant compilation tools win32build and bindlib_w32 from this page, and decompress them to the source code in the directory of the same level. The specific directory structure is as follows:

+--BuildRootDir|  ||  +--bindlib_w32|  |  ||  |  +--arpa|  |  ||  |  +--conf|  |  ||  |  +--...|  ||  +--php-5.x.x|  |  ||  |  +--build|  |  ||  |  +--...|  |  ||  |  +--win32|  |  ||  |  +--...|  ||  +--win32build|  |  ||  |  +--bin|  |  ||  |  +--include|  |  ||  |  +--lib

Add the win32build \ bin directory to the Path of the system environment variable, which can be specified during compilation. In addition, you need to create a directory C: \ usr \ local \ bin on drive C, and copy bison. simple under the win32build \ bin \ directory to this directory.

After completing the above work, compile resolv. lib. The VC project file of this file is located in: bindlib_w32. You can use VC to open the project file and compile it to compile the generated resolv. copy lib to the win32build \ lib directory (if this file already exists, overwrite it ).

So far, PHP compilation preparation has been completed.

2. download and install the ImageMagick installation package

Download Windows Binary files (http://www.imagemagick.org/script/index.php? ImageMagick = ir9ijldaeppff0fudjv4kmfcj0 # windows), select the dll version, because only the dll version contains the development file. Install the dll version. Check the following options during installation: install development headers and libraries for C and C ++ and Add application directory into your system path.

3. Download Imagick source code

 Go to the Program interface page of ImageMagick (http://www.imagemagick.org/script/api.php) to find the PHP interface Imagick. Then download (http://pecl.php.net/package/imagick) and decompress it to the ext directory under the php source code directory (BuildRootDir/php-5.x.x/ext/imagick ). Open the config. w32 file in the imagick directory and replace imagick_read.c with imagick_file.c. This is probably a Bug in imagick. Remember.

4. Configure Windows

If your Windows system is not an English version or the encoding of the opened file is not English (US) by default, the compilation process may be fail. Therefore, you need to slightly modify the configuration of the Windows system, specifically: Open the control panel, select the region and language, and find the language items of the non-Unicode program, then, the default language is English (US)/English (US ).

After completing the above four steps, you can finally compile the SDK.

Compilation process:

Use Command Prombt of VC to enter the character interface (cmd Interface), then cd to the php Directory, check the path to see if the system path contains the win32build \ bin directory. If not, run: set path = BuildRootDir \ win32build \ bin; % path %.

Run the buildconf. bat file in the php source code directory to generate the configure. js file. Then, the system prompts "configure -- help". You can directly type configure -- enable-snapshot-build -- disable-zip -- disable-zlib -- with-imagick = shared.

Note whether the last report generated below contains a line such as imagick shared. If yes, configure is successful. You can type nmake snap to compile. We recommend that you use nmake snap> build. log to redirect the compilation output to a file. Because the compilation process is too long, you can use log files for future checks.

After compilation is complete, there will be a Release_TS directory, there will be a php-5.x.x (5.x. x is your php version number) and 3 zip files.

The final result of compilation is in the php-5.x.x directory. You can Copy it to the desired location and use it.

Test compilation result:

The following information about imagick returned by phpinfo.

  

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.