1

I'm trying to setup Apache MariaDB PHP manually but I'm running into some issues with the openssl feature. Here are the steps I took to setup Apache 2.4 and PHP 7.4.4:

I. Apache httpd Installation and configuration

  1. Download and Extract httpd-2.4.43-win64-VS16.zip from apachelounge to "D:\Programs-64Bit\Apache24"
  2. Set ServerRoot in httpd.conf with full path
  3. Set ServerName to localhost:80
  4. Define WWWROOT with desired DocumentRoot path in httpd.conf (i.e. Define WWWROOT "E:/Programs/WWW")
  5. Set DocumentRoot and <Directory> values to "${WWWROOT}"

II. Combining PHP with apache

  1. Download and Extract Thread Safe php-7.4.4-Win32-vc15-x64.zip to "D:\Programs-64Bit\PHP\PHP7.4.4-64Bit"
  2. Add the following lines at the end of httpd.conf:
Define PHPROOT "D:/Programs-64Bit/PHP/PHP7.4.4-64Bit"
LoadModule php7_module "${PHPROOT}/php7apache2_4.dll"
AddType application/x-httpd-php .php
PHPIniDir "${PHPROOT}"

LoadFile "${PHPROOT}/libcrypto-1_1-x64.dll"
LoadFile "${PHPROOT}/libssl-1_1-x64.dll"
LoadFile "${PHPROOT}/libssh2.dll"
LoadFile "${PHPROOT}/nghttp2.dll"
LoadFile "${PHPROOT}/php7ts.dll"
  1. Copy and rename php.ini-development to the same php root directory as php.ini
  2. set extension_dir and enable every single extension except oci8_12c, pdo_firebird, pdo_oci and snmp

III. Testing PHP with Apache

  1. Create a php file (index.php) with the following code:
<?php 
     phpinfo();
?>
  1. run httpd.exe

This is what it tells me about openssl:

image showing the phar section of phpinfo. openssl support is disabled

according to "OpenSSL support disabled in Apache/PHP on Windows" on StackOverflow and the last comment in the php.net page "PHP Manual > Function Reference > Cryptography Extensions > OpenSSL > Installing/Configuring" it should be working. what am I doing wrong?

Paiku Han
  • 581
  • 2
  • 16
  • 38

4 Answers4

1

In case anyone's extension=openssl and LoadModule ssl_module modules/mod_ssl.so are both uncommented and still looking for answers, try setting your extension_dir to absolute path; extension_dir = "C:\php\ext".

I've been searching around for hours and that solved it. Thanks to Koichi's answer. Also I didn't need any of those LoadFile lines my httpd.conf.


My environment (for any reference):

  • Windows Server 2019 Datacenter
  • PHP Version 7.4.13
  • Apache/2.4.46 (Win64) OpenSSL/1.1.1i (from Apache Haus)
sykez
  • 2,015
  • 15
  • 14
  • 1
    This is what worked for me. In Windows 10 just "ext" worked, but when I upgraded to Windows 11 I had to set the absolute path to get it to work. – Scott Apr 03 '22 at 22:38
0

If you'd like to enable OpenSSL suport in Phar.
Just uncomment following line.

// php.ini
extension=openssl
Shawn
  • 26
  • 4
  • done that already! like I said in the original post every extensions are enabled except a few ones (oci8_12c, pdo_firebird, pdo_oci and snmp) – Paiku Han Apr 05 '20 at 18:20
0

This is actually easy to solve. after checking if openssl was enable on PHP in a command prompt with the command php index.php where index.php is the file created in the original post. One can see that openssl is actually enable.

To enable it on Apache2.4, one needs to uncomment LoadModule ssl_module modules/mod_ssl.so in httpd.conf.

The phar section will look like this:

image showing the Phar section of phpinfo where openssl support is enabled

And an openssl section will appear:

image showing the openssl section that is only visible when openssl is enabled

Paiku Han
  • 581
  • 2
  • 16
  • 38
0

I spent a long time on this problem too and tried the suggested methods (uncommenting line, absolute not relative path). What finally worked was installing PHP into "C:\php" and updating the PHP module settings in Apache's httpd.conf, rather than having it in some other path. It feels like there's an Apache problem somewhere, as it working perfectly fine when PHP was installed in my initial non-standard path and served by another web server.

If you have PHP installed somewhere else and are able to move it to C:\php and adjust Apache's settings, it's worth trying.

  • 1
    This is not really a satisfying answer. Millions of users have installes php at very different paths so this is certainly not the reason of the problem. – Alexander Dobernig Feb 04 '21 at 13:13
  • Yes, I agree with that comment. – amoschou Feb 04 '21 at 13:52
  • @amoschou maybe your apache install doesn't allow space(s) in the path to php. Maybe that's why it worked with C:\php. if that's the case then maybe try using double quote to define the path. Also knowing your configuration (OS, apache version, php version) would help others – Paiku Han Feb 05 '21 at 14:30