How can I configure PHP 7.4 on Apache?

Leonardo picture Leonardo · Dec 17, 2019 · Viewed 10.8k times · Source

I am trying to configure PHP 7.4 and Apache 2.4 on my machine, but it is returning the following error:

httpd.exe: Syntax error on line 542 of C:/XIDServer/Apache24/conf/httpd.conf: 
Can't locate API module structure 'php7_module' in file C:/XIDServer/php/php7.dll: No error

The bottom of my httpd.conf has the code:

# PHP7 module
AddHandler application/x-httpd-php .php
AddType application/x-httpd-php .php .html
LoadModule php7_module "C:/XIDServer/php/php7.dll"
PHPIniDir "C:/XIDServer/php"

I've done already:

  • Copy/paste php7.4 on the location: 'C:\XIDServer\php'
  • Edited the php.ini file on 'C:\XIDServer\php\php.ini', enabling some modules:
  • extension=curl
  • extension=gd2
  • extension=mbstring
  • extension=mysql
  • extension=pdo_mysql
  • extension=xmlrpc
  • Created the environment variable for php appointing to 'C:\XIDServer\php'
  • Copy/paste Apache 2.4 64 bits to the folder: 'C:\XIDServer\Apache24'
  • Edited the httpd.conf file, to appoint to the new location ('C:\XIDServer\Apache24')
  • Installed the Windows Service of Apache 2.4
  • Added the above lines on the bottom of file 'httpd.conf'

I'm doing it on a Windows Server 2012 machine.

Answer

Bongni picture Bongni · Mar 15, 2020

I've had the same issue. You probably downloaded the Non-Thread-Save version of php7. However you have to download the Thread-Save version. Because in this version you will get a file called php7apache2_4.dll which you need to load as a module instead of php7.dll.

LoadModule php7_module "C:/XIDServer/php/php7apache2_4.dll"

If you change this line it should work.