윈도우 시스템에 아파치와 php를 설치. 커맨드라인에서 php -v를 쳐보면
PHP Warning: 'C:\Windows\SYSTEM32\VCRUNTIME140.dll' 14.24 is not compatible with this PHP build linked with 14.42 in Unknown on line 0
와 같이 나왔다.
아파치 httpd.conf 파일의 최하단부에
LoadModule php_module "d:/php8/php8apache2_4.dll"
AddHandler application/x-httpd-php .php
AddType application/x-httpd-php .php .html
PHPIniDir "d:/php8"
와 같이 써주고 아파치를 윈도우 서비스에서 다시 올리려고 하는데 안 올라왔다.
문제는 Visual Studio Visual C++ 재배포 가능 패키지 설치문제였다. 아래의 링크로 Visual Studio Visual C++ 재배포 가능 패키지를 설치하고
https://aka.ms/vs/17/release/vc_redist.x64.exe
php -v를 쳐보면
PHP 8.4.3 (cli) (built: Jan 15 2025 11:04:37) (ZTS Visual C++ 2022 x64)
Copyright (c) The PHP Group
Zend Engine v4.4.3, Copyright (c) Zend Technologies
와 같이 정상적으로 버전이 출력되고 테스트 해보니 정상적으로 된다.
When PHP fails to load on Apache in a Windows system, the following steps can resolve the issue:
- Check PHP version:
Initially, running php -v
displayed an error:
PHP Warning: 'C:\Windows\SYSTEM32\VCRUNTIME140.dll' 14.24 is not compatible with this PHP build linked with 14.42 in Unknown on line 0
- Configure Apache:
Add these lines to the end of the httpd.conf
file:
LoadModule php_module "d:/php8/php8apache2_4.dll"
AddHandler application/x-httpd-php .php
AddType application/x-httpd-php .php .html
PHPIniDir "d:/php8"
- Install Visual C++ Redistributable:
The main issue was the missing Visual Studio Visual C++ Redistributable package. Download and install it from:
https://aka.ms/vs/17/release/vc_redist.x64.exe
- Verify PHP installation:
After installation, running php -v
should display:
PHP 8.4.3 (cli) (built: Jan 15 2025 11:04:37) (ZTS Visual C++ 2022 x64)
Copyright (c) The PHP Group
Zend Engine v4.4.3, Copyright (c) Zend Technologies
- Test the setup:
After these steps, PHP should work correctly with Apache on the Windows system.