Microsoft MVP성태의 닷넷 이야기
개발 환경 구성: 122. PHP 소스를 윈도우 환경에서 빌드하기 [링크 복사], [링크+제목 복사],
조회: 30414
글쓴 사람
정성태 (techsharer at outlook.com)
홈페이지
첨부 파일
 
(연관된 글이 4개 있습니다.)
PHP 소스를 윈도우 환경에서 빌드하기

저도 ^^ PHP 빌드를 한번 시도해 보았습니다. 전체적인 내용은 아래의 Wiki 문서에 기반하고 있습니다.

Build your own PHP on Windows
; https://wiki.php.net/internals/windows/stepbystepbuild 

처음부터 괜히 고생하지 않기 위해 Visual Studio 2010에서의 컴파일은 일단 포기하고, 위의 문서에서 요구하는 대로 Visual C++ 2008과 Windows SDK까지 맞춰서 설치를 했습니다.

Windows SDK for Windows Server 2008 and .NET Framework 3.5 
; http://www.microsoft.com/downloads/en/details.aspx?FamilyID=e6e1c3df-a74f-4207-8586-711ebe331cdc&displaylang=en

이제, 빌드를 위한 폴더 구조를 잡아야 하는데요. 일단 모든 소스코드 환경을 담기 위해 "d:\phpbuild" 폴더를 생성해 두었습니다.

그다음, 첫 번째 작업으로 아래의 php-sdk-binary-tools-20110512.zip을 다운로드해서 압축을 해제하는데 "d:\phpbuild" 하위에 구성합니다.

php-sdk-binary-tools-20110512.zip
; http://windows.php.net/downloads/php-sdk/

여기까지, 일단 제 빌드 폴더 구성은 다음과 같습니다.

how_to_build_php_win_1.png

이제, "시작" / "Microsoft Windows SDKK v6.1" / "CMD Shell" 명령어를 실행시키고, 다음의 명령어들을 차례로 실행해 줍니다.

setenv /x86 /xp /release (디버그 모드: setenv /x86 /xp /debug)

cd /d d:\phpbuild

.\bin\phpsdk_setvars.bat

.\bin\phpsdk_buildtree.bat php53dev

아래는 제 경우에 실행해 본 화면 사례입니다.

how_to_build_php_win_2.png

그리고, 아래는 위의 작업까지 진행했을 때의 폴더 구조입니다.

how_to_build_php_win_3.png

다음으로, PHP 소스 코드를 다운로드 받습니다.

PHP 5.3.6 (tar.gz)
; http://www.php.net/downloads.php

D:\phpbuild\php53dev\vc9\x86 폴더 하위에 PHP 5.3.6 소스 코드를 풀어 놓아서, 이제 폴더 구조는 아래와 같이 구성됩니다.

how_to_build_php_win_4.png

아직 제가 PHP에 대해서는 ^^; 아무것도 모르기 때문에 deps 폴더에는 별다르게 파일들을 추가하지는 않았습니다.




처음 부분에서 준비를 해 두었던 '명령행 윈도우'로 돌아가서, 다음과 같은 명령어들을 차례대로 실행해 줍니다.

d:\phpbuild>cd D:\phpbuild\php53dev\vc9\x86\php-5.3.6

D:\phpbuild\php53dev\vc9\x86\php-5.3.6>buildconf
Rebuilding configure.js
Now run 'configure --help'

D:\phpbuild\php53dev\vc9\x86\php-5.3.6>configure --disable-all --enable-cli (디버그 모드인 경우, --enable-debug 옵션 추가)
Saving configure options to config.nice.bat
Checking for cl.exe ...  <in default path>
  Detected compiler MSVC9 (Visual C++ 2008)
  Detected 32-bit compiler
Checking for link.exe ...  d:\Program Files (x86)\Microsoft Visual Studio 9.0\VC\Bin
Checking for nmake.exe ...  <in default path>
Checking for lib.exe ...  <in default path>
Checking for bison.exe ...  <in default path>
Checking for re2c.exe ...  <in default path>
  Detected re2c version 0.13.5
Checking for zip.exe ...  <in default path>
Checking for lemon.exe ...  <not found>
Checking for mc.exe ...  D:\Program Files\Microsoft SDKs\Windows\v6.1\Bin\x64
Checking for mt.exe ...  D:\Program Files\Microsoft SDKs\Windows\v6.1\Bin\x64

Build dir: Release_TS
PHP Core:  php5ts.dll and php5ts.lib

Checking for wspiapi.h ...  <in default path>
Enabling IPv6 support
Enabling SAPI sapi\cli
Enabling extension ext\date
Enabling extension ext\ereg
Enabling extension ext\pcre
Enabling extension ext\reflection
Enabling extension ext\spl
Checking for timelib_config.h ...  ext/date/lib
Enabling extension ext\standard

Creating build dirs...
Generating files...
Generating Makefile
Generating main/internal_functions.c
Generating main/config.w32.h
Generating phpize
Done.



Enabled extensions:
-----------------------
| Extension  | Mode   |
-----------------------
| date       | static |
| ereg       | static |
| pcre       | static |
| reflection | static |
| spl        | static |
| standard   | static |
-----------------------


Enabled SAPI:
-------------
| Sapi Name |
-------------
| cli       |
-------------


-------------------------------------------
|               |                         |
-------------------------------------------
| Build type    | Release                 |
| Thread Safety | Yes                     |
| Compiler      | MSVC9 (Visual C++ 2008) |
| Architecture  | x86                     |
-------------------------------------------


Type 'nmake' to build PHP

D:\phpbuild\php53dev\vc9\x86\php-5.3.6>

이것으로 준비는 모두 끝났고, 마지막으로 nmake를 실행해주면 빌드가 됩니다. 인텔 i7 컴퓨터의 Hyper-V Virtual Machine 환경에서 약 2분 30초 정도 걸렸습니다.

빌드 완료 후, "D:\phpbuild\php53dev\vc9\x86\php-5.3.6\Release_TS" 폴더(디버그인 경우 Debug_TS)가 생성되어 있는 것을 볼 수 있는데, 바로 그 폴더가 (".NET 개발자가 처음 설치해 본 Apache + PHP" 글에서 알아본) phpmodule 디렉터리에 넣을 내용이 되는 것입니다.

그런데, 음... ^^; 생각보다 기본 빌드 구성으로는 많이 빠져있는 것 같습니다. 예를 들어, Apache의 httpd.conf 파일 내에 LoadModule로 지정한 php5apache2_2.dll 파일도 없습니다. 그 부분은 천천히 살펴봐야겠습니다. ^^




참고 사항 1: 다음과 같은 컴파일 오류가 발생한다면?


ext\standard\browscap.c(61) : error C2001: newline in constant
ext\standard\browscap.c(62) : warning C4305: '=' : truncation from 'int' to 'char'
ext\standard\browscap.c(62) : error C2146: syntax error : missing ';' before identifier 't'
ext\standard\browscap.c(89) : error C2001: newline in constant
ext\standard\browscap.c(90) : error C2146: syntax error : missing ':' before identifier 't'
ext\standard\browscap.c(91) : error C2001: newline in constant
ext\standard\browscap.c(92) : warning C4305: '=' : truncation from 'int' to 'char'
ext\standard\browscap.c(92) : error C2143: syntax error : missing ';' before 'break'
ext\standard\browscap.c(100) : error C2001: newline in constant
ext\standard\browscap.c(102) : warning C4305: '=' : truncation from 'int' to 'char'
ext\standard\browscap.c(102) : error C2146: syntax error : missing ';' before identifier 't'
NMAKE : fatal error U1077: '"d:\Program Files (x86)\Microsoft Visual Studio 9.0\VC\Bin\cl.exe"' : return code '0x2'
Stop.

아래의 글에서처럼 개행 문자를 일일이 소스 코드마다 다시 편집해주는 것도 가능하겠지만,

Compiler Error C2001
; https://docs.microsoft.com/en-us/cpp/error-messages/compiler-errors-1/compiler-error-c2001

PRB: C2001: Newline in Constant for a String on Multiple Lines
; http://support.microsoft.com/kb/40160/en-us

저는 포기했습니다. 검색해 보니, 다음과 같은 글이 나오는데요.

Bug #50112 - compile error with Non-English Operating system
; http://bugs.php.net/bug.php?id=50112

댓글에 보면, 다음과 같은 해답이 나옵니다.

[2010-09-13 07:05 UTC] liuranball at gmail dot com
I just use the 0xA7 to instead of 'signum sectionis' can fix it.


0xa7로 어떻게 바꾸는지 몰라서, 저는 그냥 제어판의 "Region and Language" / "Administrative" / "Language for non-Unicode programs" 설정을 "English (United States)"로 바꿨습니다. (재부팅 해야 합니다. ^^;)




참고 사항 2: configure --help


D:\phpbuild\php53dev\vc9\x86\php-5.3.6>configure --help
Options that enable extensions and SAPI will accept 'yes' or 'no' as a
parameter. They also accept 'shared' as a synonym for 'yes' and request a
shared build of that module. Not all modules can be built as shared modules;
configure will display [shared] after the module name if can be built that
way.

  --enable-snapshot-build       Build a snapshot; turns on everything it can
                                and ignores build errors
  --enable-one-shot             Optimize for fast build - best for release and
                                snapshot builders, not so hot for
                                edit-and-rebuild hacking
  --with-cygwin                 Path to cygwin utilities on your system
  --enable-object-out-dir       Alternate location for binary objects during
                                build
  --enable-debug                Compile with debugging symbols
  --enable-debug-pack           Release binaries with external debug symbols
                                (--enable-debug must not be specified)
  --disable-zts                 Thread safety
  --with-prefix                 where PHP will be installed
  --with-mp                     Tell VC9+ use up to [n,auto,disable] processes
                                for compilation
  --with-php-build              Path to where you extracted the development
                                libraries
                                (http://wiki.php.net/internals/windows/libs).
                                Assumes that it is a sibling of this source
                                dir (..\deps) if not specified
  --with-extra-includes         Extra include path to use when building
                                everything
  --with-extra-libs             Extra library path to use when linking
                                everything
  --disable-ipv6                Disable IPv6 support (default is turn it on if
                                available)
  --enable-fd-setsize           Set maximum number of sockets for select(2)
  --enable-zend-multibyte       Enable Zend multibyte encoding support
  --with-snapshot-template      Path to snapshot builder template dir
  --enable-security-flags       Enable the compiler security flags
  --enable-static-analyze       Enable the VC compiler static analyze
  --with-aolserver              Build AOLserver support
  --enable-apache               Build Apache 1.3.x version of PHP
  --with-apache-includes        Where to find Apache 1.3 headers
  --with-apache-libs            Where to find Apache 1.3 libraries
  --enable-apache2filter        Build Apache 2.x filter
  --enable-apache2-2filter      Build Apache 2.2.x filter
  --enable-apache2handler       Build Apache 2.x handler
  --enable-apache2-2handler     Build Apache 2.2.x handler
  --with-apache-hooks           Build Apache 1.3.x (hooks) version of PHP
  --disable-cgi                 Build CGI version of PHP
  --disable-cli                 Build CLI version of PHP
  --enable-crt-debug            Enable CRT memory dumps for debugging sent to
                                STDERR
  --enable-cli-win32            Build console-less CLI version of PHP
  --enable-embed                Embedded SAPI library
  --enable-isapi                Build ISAPI version of PHP
  --enable-nsapi                Build NSAPI for Netscape/iPlanet/SunONE
                                webservers
  --with-nsapi-includes         Where to find NSAPI headers
  --with-nsapi-libs             Where to find NSAPI libraries
  --with-pi3web                 Pi3Web
  --disable-bcmath              bc style precision math functions
  --with-bz2                    BZip2
  --disable-calendar            calendar conversion support
  --disable-com-dotnet          COM and .Net support
  --disable-ctype               ctype
  --with-curl                   cURL support
  --with-dba                    DBA support
  --with-enchant                Enchant Support
  --without-ereg                POSIX extended regular expressions
  --enable-fileinfo             fileinfo support
  --disable-filter              Filter Support
  --disable-ftp                 ftp support
  --without-gd                  Bundled GD support
  --without-t1lib               t1lib support
  --with-gettext                gettext support
  --with-gmp                    Include GNU MP support.
  --disable-hash                enable hash support
  --with-mhash                  mhash support
  --without-iconv               iconv support
  --with-imap                   IMAP Support
  --with-interbase              InterBase support
  --enable-intl                 Enable internationalization support
  --disable-json                JavaScript Object Serialization support
  --with-ldap                   LDAP support
  --enable-mbstring             multibyte string functions
  --enable-mbregex              multibyte regex support
  --disable-mbregex-backtrack   check multibyte regex backtrack
  --with-mcrypt                 mcrypt support
  --with-mssql                  mssql support
  --with-dblib                  mssql support with freetds
  --without-mysqlnd             Mysql Native Client Driver
  --with-oci8                   OCI8 support
  --with-oci8-11g               OCI8 support using Oracle 11g Instant Client
  --disable-odbc                ODBC support
  --with-openssl                OpenSSL support
  --with-pgsql                  PostgreSQL support
  --with-pspell                 pspell/aspell (whatever it's called this
                                month) support
  --disable-session             session support
  --enable-shmop                shmop support
  --with-snmp                   SNMP support
  --enable-sockets              SOCKETS support
  --with-sqlite3                SQLite 3 support
  --with-config-file-scan-dir   Dir to check for additional php ini files
  --with-sybase-ct              SYBASE_CT support
  --with-tidy                   TIDY support
  --disable-tokenizer           tokenizer support
  --disable-zip                 ZIP support
  --disable-zlib                ZLIB support
  --without-libxml              LibXML support
  --without-dom                 DOM support
  --enable-exif                 exif
  --with-mysql                  MySQL support
  --with-mysqli                 MySQLi support
  --enable-pdo                  Enable PHP Data Objects support
  --with-pdo-dblib              freetds dblib (Sybase, MS-SQL) support for PDO
  --with-pdo-mssql              Native MS-SQL support for PDO
  --with-pdo-firebird           Firebird support for PDO
  --with-pdo-mysql              MySQL support for PDO
  --with-pdo-oci                Oracle OCI support for PDO
  --with-pdo-odbc               ODBC support for PDO
  --with-pdo-pgsql              PostgreSQL support for PDO
  --with-pdo-sqlite             for pdo_sqlite support
  --with-pdo-sqlite-external    for pdo_sqlite support from an external dll
  --disable-phar                disable phar support
  --enable-phar-native-ssl      enable phar with native OpenSSL support
  --without-simplexml           Simple XML support
  --enable-soap                 SOAP support
  --with-sqlite                 SQLite support
  --without-wddx                WDDX support
  --without-xml                 XML support
  --disable-xmlreader           XMLReader support
  --with-xmlrpc                 XMLRPC-EPI support
  --disable-xmlwriter           XMLWriter support
  --with-xsl                    xsl support



[이 글에 대해서 여러분들과 의견을 공유하고 싶습니다. 틀리거나 미흡한 부분 또는 의문 사항이 있으시면 언제든 댓글 남겨주십시오.]

[연관 글]






[최초 등록일: ]
[최종 수정일: 6/26/2021]

Creative Commons License
이 저작물은 크리에이티브 커먼즈 코리아 저작자표시-비영리-변경금지 2.0 대한민국 라이센스에 따라 이용하실 수 있습니다.
by SeongTae Jeong, mailto:techsharer at outlook.com

비밀번호

댓글 작성자
 




... 31  32  33  34  35  36  37  38  39  40  41  [42]  43  44  45  ...
NoWriterDateCnt.TitleFile(s)
12606정성태4/21/202113520.NET Framework: 1042. C# - enum 값을 int로 암시적(implicit) 형변환하는 방법? [2]파일 다운로드1
12605정성태4/18/20219413.NET Framework: 1041. C# - AssemblyID, ModuleID를 관리 코드에서 구하는 방법파일 다운로드1
12604정성태4/18/20217964VS.NET IDE: 163. 비주얼 스튜디오 속성 창의 "Build(빌드)" / "Configuration(구성)"에서의 "활성" 의미
12603정성태4/16/20218959VS.NET IDE: 162. 비주얼 스튜디오 - 상속받은 컨트롤이 디자인 창에서 지원되지 않는 문제
12602정성태4/16/202110142VS.NET IDE: 161. x64 DLL 프로젝트의 컨트롤이 Visual Studio의 Designer에서 보이지 않는 문제 [1]
12601정성태4/15/20219161.NET Framework: 1040. C# - REST API 대신 github 클라이언트 라이브러리를 통해 프로그래밍으로 접근
12600정성태4/15/20219316.NET Framework: 1039. C# - Kubeconfig의 token 설정 및 인증서 구성을 자동화하는 프로그램
12599정성태4/14/202110087.NET Framework: 1038. C# - 인증서 및 키 파일로부터 pfx/p12 파일을 생성하는 방법파일 다운로드1
12598정성태4/14/202110171.NET Framework: 1037. openssl의 PEM 개인키 파일을 .NET RSACryptoServiceProvider에서 사용하는 방법 (2)파일 다운로드1
12597정성태4/13/202110237개발 환경 구성: 569. csproj의 내용을 공통 설정할 수 있는 Directory.Build.targets / Directory.Build.props 파일
12596정성태4/12/20219990개발 환경 구성: 568. Windows의 80 포트 점유를 해제하는 방법
12595정성태4/12/20219340.NET Framework: 1036. SQL 서버 - varbinary 타입에 대한 문자열의 CAST, CONVERT 변환을 C# 코드로 구현
12594정성태4/11/20218800.NET Framework: 1035. C# - kubectl 명령어 또는 REST API 대신 Kubernetes 클라이언트 라이브러리를 통해 프로그래밍으로 접근 [1]파일 다운로드1
12593정성태4/10/202110007개발 환경 구성: 567. Docker Desktop for Windows - kubectl proxy 없이 k8s 대시보드 접근 방법
12592정성태4/10/20219848개발 환경 구성: 566. Docker Desktop for Windows - k8s dashboard의 Kubeconfig 로그인 및 Skip 방법
12591정성태4/9/202113104.NET Framework: 1034. C# - byte 배열을 Hex(16진수) 문자열로 고속 변환하는 방법 [2]파일 다운로드1
12590정성태4/9/20219558.NET Framework: 1033. C# - .NET 4.0 이하에서 Console.IsInputRedirected 구현 [1]
12589정성태4/8/202110997.NET Framework: 1032. C# - Environment.OSVersion의 문제점 및 윈도우 운영체제의 버전을 구하는 다양한 방법 [1]
12588정성태4/7/202111568개발 환경 구성: 565. PowerShell - New-SelfSignedCertificate를 사용해 CA 인증서 생성 및 인증서 서명 방법
12587정성태4/6/202112406개발 환경 구성: 564. Windows 10 - ClickOnce 배포처럼 사용할 수 있는 MSIX 설치 파일 [1]
12586정성태4/5/202110046오류 유형: 710. Windows - Restart-Computer / shutdown 명령어 수행 시 Access is denied(E_ACCESSDENIED)
12585정성태4/5/20219695개발 환경 구성: 563. 기본 생성된 kubeconfig 파일의 내용을 새롭게 생성한 인증서로 구성하는 방법
12584정성태4/1/202110433개발 환경 구성: 562. kubeconfig 파일 없이 kubectl 옵션만으로 실행하는 방법
12583정성태3/29/202111905개발 환경 구성: 561. kubectl 수행 시 다른 k8s 클러스터로 접속하는 방법
12582정성태3/29/202110625오류 유형: 709. Visual C++ - 컴파일 에러 error C2059: syntax error: '__stdcall'
12581정성태3/28/202110593.NET Framework: 1031. WinForm/WPF에서 Console 창을 띄워 출력하는 방법 (2) - Output 디버깅 출력을 AllocConsole로 우회 [2]
... 31  32  33  34  35  36  37  38  39  40  41  [42]  43  44  45  ...