프로그래밍/PHP

PHP 개발환경 설정 (Windows 10)

채윤아빠 2020. 6. 9. 22:47
728x90
반응형

Install Apache24

Apache 2.4.43 Win64 download : https://www.apachelounge.com/download/
download file : httpd-2.4.43-win64-VS15.zip ; 가급적 PHP와 동일한 VS15 버전으로 다운로드
extract to "C:\Dev\Apache24"

Apache 정상 동작 확인


C:\Dev\Apache24\bin>httpd -version
Server version: Apache/2.4.43 (Win64)
Apache Lounge VC15 Server built:   Apr 22 2020 11:11:00

Install PHP74

PHP 7.4.6 Win64 download : https://windows.php.net/download ; *"php7apache2_4.dll" 등을 위하여 Thread Safe 버전을 다운로드 받아야 함*
download file VC15 x64 Thread Safe (2020-May-12 15:28:43) ; php-7.4.6-Win32-vc15-x64.zip
extract to "C:\Dev\php-7.4.6"

PHP 정상 동작 확인


C:\Dev\php-7.4.6>php --version
PHP 7.4.6 (cli) (built: May 12 2020 11:38:52) ( NTS Visual C++ 2017 x64 )
Copyright (c) The PHP Group
Zend Engine v3.4.0, Copyright (c) Zend Technologies

VisualStudio 2017 Runtime이 설치되지 않은 경우,
https://aka.ms/vs/15/release/VC_redist.x64.exe ; Microsoft Visual Studio 2017 Redistributable Runtime download & install

디버깅을 위하여 xDebug Download : https://xdebug.org/download.php
dwonload file : PHP 7.4 VC15 (64 bit) ; php_xdebug-2.9.6-7.4-vc15-x86_64.dll
copy to "C:\Dev\php-7.4.6\ext"

PHP 환경설정(Configuration)

"php.ini"는 php.ini-production 파일을 복사하여 생성

"php.ini" 설정


; PHP.ini 맨 아래 추가하거나, 해당 부분을 찾아서 아래와 같이 수정
;extension_dir = "ext"
extension_dir = "C:\Dev\php-7.4.6\ext"

extension=php_bz2.dll
extension=php_curl.dll
extension=php_gd2.dll
extension=php_mysqli.dll
extension=php_openssl.dll
extension=php_sockets.dll



; PHP.ini 맨 아래 추가
[XDebug]
zend_extension="C:/Dev/php-7.4.6/ext/php_xdebug-2.9.6-7.4-vc15-x86_64.dll"
xdebug.remote_autostart=true
xdebug.remote_enable=true
xdebug.remote_host=127.0.0.1
xdebug.remote_port=9000

"php.ini" 환경설정을 마친 후에, PHP 버전을 다시 확인해 보면, 마지막에 xDebug가 포함되어 있음을 확인할 수 있습니다.


C:\Dev\php-7.4.6>php -v
PHP 7.4.6 (cli) (built: May 12 2020 11:38:54) ( ZTS Visual C++ 2017 x64 )
Copyright (c) The PHP Group
Zend Engine v3.4.0, Copyright (c) Zend Technologies
    with Xdebug v2.9.6, Copyright (c) 2002-2020, by Derick Rethans

CURL 모듈이 정상 로딩되지 않는 경우


PHP Warning:  PHP Startup: Unable to load dynamic library 'curl' (tried: ext\\curl (\xec\xa7\x80\xec\xa0\x95\xeb\x90\x9c \xeb\xaa\xa8\xeb\x93\x88\xec\x9d\x84 \xec\xb0\xbe\xec\x9d\x84 \xec\x88\x98 \xec\x97\x86\xec\x8a\xb5\xeb\x8b\x88\xeb\x8b\xa4.), ext\\php_curl.dll (\xec\xa7\x80\xec\xa0\x95\xeb\x90\x9c \xeb\xaa\xa8\xeb\x93\x88\xec\x9d\x84 \xec\xb0\xbe\xec\x9d\x84 \xec\x88\x98 \xec\x97\x86\xec\x8a\xb5\xeb\x8b\x88\xeb\x8b\xa4.)) in Unknown on line 0

PHP가 설치된 폴더 ("C:\Dev\php-7.4.6")에서 "libsasl.dll", "libssh2.dll" 및 "libcrypto-*.dll" 파일들을 "Apache24/bin" 폴더로 복사하여 줍니다.

Apache24 Configuration

Edit httpd.conf : "C:\Dev\Apache24\conf\httpd.conf"

아래의 각 부분들을 찾아서 다음과 같이 수정합니다.


Define SRVROOT "C:/Dev/Apache24"


LoadModule rewrite_module modules/mod_rewrite.so


ServerName www.example.com:80:80


#DocumentRoot "${SRVROOT}/htdocs"
#
DocumentRoot "D:/MyProj/PHP/"



    #AllowOverride None
    AllowOverride All



    DirectoryIndex index.php index.html index.htm

Edit "C:\Dev\Apache24\conf\extra\httpd-vhosts.conf"


# PHP settings for non thread safe
LoadModule  php7_module "C:/Dev/php-7.4.6/php7apache2_4.dll"
PHPIniDir   "C:/Dev/php-7.4.6/"
AddType application/x-httpd-php .html .php