How can I enable PHP Extension intl in an Apache server? - php

I have removed the starting semicolon ( ; ) from php.ini the following code.
;extension=php_intl.dll
Screenshot: php.ini
And everything seems fine when I runs
php -m
Screenshot: cmd.exe. Looks like intl has been loaded
But in the website powered by Apache, the extension intl simply disappeared when I opens a website with source code below:
<?php
phpinfo();
?>
ScreenShot: intl disappeared
Meanwhile, extension mbstring can be seen in both direction.
I'm wondering how to load intl correctly. Please help me.
Note:
Operating system: Windows 10
Apache: httpd-2.4.54-o111s-x64-vs16
PHP: php-8.2.0-Win32-vs16-x64
I have tried:
copy php_intl.dll to Apache24/bin or Windows/SysWOW64
reinstall Visual C++ 2019 Redistributed
check httpd.conf and php.ini again
httpd.conf
LoadModule php_module modules/php-8.2.0-Win32-vs16-x64/php8apache2_4.dll
AddType application/x-httpd-php .php .html .htm
PHPIniDir "C:/Program Files/Apache Software Foundation/Apache24/modules/php-8.2.0-Win32-vs16-x64/"
php.ini
extension=intl

I copied icu****.dll from PHP folder to Apache24/bin folder and everything looks fine now.

Related

How to enable openSSL in PHP 7.4 with Apache Server 2.4?

I am aware very similar questions have been around but none seem to have the solution for my problem. I wonder if you could give me a hand with this one. I'll try to be as specific as possible:
I'm on a Windows x64
PHP version 7.4.6
Apache server 2.4.43
On the php.ini file I uncommented extension=openssl and extension_dir = "ext"
On the httpd.conf file I added this extra snippet
<IfModule php7_module>
AddHandler application/x-httpd-php .php
PHPIniDir "C:/php-7.4.6"
LoadFile "C:/php-7.4.6/libcrypto-1_1-x64.dll"
LoadFile "C:/php-7.4.6/libssl-1_1-x64.dll"
LoadFile "C:/php-7.4.6/libssh2.dll"
LoadFile "C:/php-7.4.6/nghttp2.dll"
LoadFile "C:/php-7.4.6/php7ts.dll"
</IfModule>
(I include the LoadFiles as I saw somewhere that that might be solution, well it's not for me at least)
Checked on the command line the modules installed (php -m) and it seems that the ssl module is enabled. However when checking with the extension_loaded ('openssl') instruction it returns a false. Also, with phpinfo() I see that OpenSSL support is disabled and I should install (ext/openssl).
I don't know why they are telling me opposite things. https wrapper is not enabled either.
I checked if both php and apache were reading from different php.ini files and they both say the same thing:
Configuration File (php.ini) Path C:\WINDOWS
Loaded Configuration File C:\php-7.4.6\php.ini
Which btw I understand little, as there is no php.ini in the Windows folder. I understand that the file is got from the path specified below.
In the ext folder there is the php_openssl.dll file.
I tried to include C:\php-7.4.6\libcrypto-1_1-x64.dll as environmental variable as I saw that in a different link.
And yes, I restarted the server several times.
I reckon I ran out of options and I don't know what else I should do. Thanks for your help!
I try to attach the links that I've been visiting, although I'm sure I'm leaving some behind as I lost track.
Unable to find the wrapper "https" with file_get_contents
OpenSSL Support disabled in Apache 2.4/PHP 7.4.4
PHP OpenSSL extension not working while install Typo3 6.2.2 on window7
How to enable HTTPS stream wrappers
Thanks a lot!
Fortunately I managed to get it to work and I want to share with you all the solution in case you are facing the same problem.
I happened to think about checking the error logs of Apache and the following error was registered for every module: Unable to load dynamic library. It was trying to take the module from the /ext folder, which it didn't know where it was, so what I did was to change in the php.ini file the extension_dir to an absolute PATH "C:\php-7.4.6\ext" and now it works like a dream!
There is a line in php.ini:
;extension_dir = "ext"
You just have to uncomment it in addition to uncomment extension=php_openssl.dll as well.

OpenSSL Support disabled in Apache 2.4/PHP 7.4.4

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
Download and Extract httpd-2.4.43-win64-VS16.zip from apachelounge to "D:\Programs-64Bit\Apache24"
Set ServerRoot in httpd.conf with full path
Set ServerName to localhost:80
Define WWWROOT with desired DocumentRoot path in httpd.conf (i.e. Define WWWROOT "E:/Programs/WWW")
Set DocumentRoot and <Directory> values to "${WWWROOT}"
II. Combining PHP with apache
Download and Extract Thread Safe php-7.4.4-Win32-vc15-x64.zip to "D:\Programs-64Bit\PHP\PHP7.4.4-64Bit"
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"
Copy and rename php.ini-development to the same php root directory as php.ini
set extension_dir and enable every single extension except oci8_12c, pdo_firebird, pdo_oci and snmp
III. Testing PHP with Apache
Create a php file (index.php) with the following code:
<?php
phpinfo();
?>
run httpd.exe
This is what it tells me about openssl:
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?
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)
If you'd like to enable OpenSSL suport in Phar.
Just uncomment following line.
// php.ini
extension=openssl
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:
And an openssl section will appear:
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.

sqlite3 and pdo_sqlite not loaded in php apache2 localhost but loaded in php cmd window

Problem description
I use Windows 10 OS. I have installed Apache 2.4 in C:/Apache24 and PHP7.4.1 in C:/php7. In the configuration file of Apache, httpd.conf, I appended the following
LoadModule php7_module "c:/php7/php7apache2_4.dll"
#<FilesMatch \.php$>
# SetHandler application/x-httpd-php
#</FilesMatch>
AddType application/x-httpd-php .php
PHPIniDir "C:/php7"
I also have modified the php.ini file of php in the following way:
extension_dir = C:\php7\ext
extension=bz2
extension=curl
;extension=ffi
extension=fileinfo
extension=gd2
extension=gettext
extension=gmp
extension=intl
extension=imap
;extension=ldap
extension=mbstring
extension=exif ; Must be after mbstring as it depends on it
extension=mysqli
;extension=oci8_12c ; Use with Oracle Database 12c Instant Client
;extension=odbc
extension=openssl
;extension=pdo_firebird
extension=pdo_mysql
;extension=pdo_oci
extension=pdo_odbc
extension=pdo_pgsql
extension=pdo_sqlite
extension=pgsql
extension=shmop
; The MIBS data available in the PHP distribution must be installed.
; See http://www.php.net/manual/en/snmp.installation.php
;extension=snmp
extension=soap
extension=sockets
;extension=sodium
extension=sqlite3
extension=tidy
extension=xmlrpc
extension=xsl
and still in php.ini I have also modified
[sqlite3]
; Directory pointing to SQLite3 extensions
; http://php.net/sqlite3.extension-dir
sqlite3.extension_dir = C:\Apache24\htdocs
Then I have restarted apache several tens of times and the PC once.
Problem:
I have made a 'index.php' file and placed it in 'c:/apache24/htdocs' which has the following text in it:
<?php phpinfo(); ?>
Going to 'localhost' in Chrome Web browser I see the PHP info file. However, ---> it does not have sqlite3 nor pdo_sqlite enabled <---. However, running 'php -m' in comand window, it shows that sqlite3 and pdo_sqlite are loaded. Furthermore, in localhost PHP info says that it uses the loaded configuration file found here 'C:\php7\php.ini' hich is indeed the right one.
I have no other idees, why sqlite3 or pdo_sqlite is not visible in apache2 but visible in com window, especially bue to the fact that it uses the same php.ini file.
Update
Checking the 'error.log' file from Apache24\logs I can see that the following warning:
PHP Warning: PHP Startup: Unable to load dynamic library 'pdo_sqlite' (tried: C:\\php7\\ext\\pdo_sqlite (The specified module could not be found.), C:\\php7\\ext\\php_pdo_sqlite.dll (The specified module could not be found.)) in Unknown on line 0
However, php_pdo_sqlite.dll can be seen in c:\php7\ext using the Windows 10 explorer, but on the other hand C:\\php7\\ext is not a valid path for the windows explorer. I do not know if double backslashes are used just for printing or indeed it searches at that path. However cmd is not bothered by double backslashes. I really do not know what to think!
Upgrading Apache to 2.4.41 + adding the following to my httpd.conf fixed the problem for me.
# PHP7
LoadModule php7_module "C:/Php/php7apache2_4.dll"
AddHandler application/x-httpd-php .php
AddHandler application/x-httpd-php .phtml
PHPIniDir C:/Php
# FIX CURL REQUIRES LIBSSH2
LoadFile "C:/Php/libssh2.dll"
LoadFile "C:/Php/libsqlite3.dll"
When apache runs php (because you fetch a URL which is served by the web server and it redirects the *.php URLs to the php) then php loads a php.ini file from one particular directory. You can see the path of the loaded php.ini (and potentially other configuration files) in the output of phpinfo() within your web browser.
By contrast, if you run php from command line then php uses a different php.ini, more precisely, a php.ini from a different directory. You can see the path of this php.ini also in the output of phpinfo() but it will be shown in your terminal, not in your browser. You can get this output via a command similar to this one:
php c:\Apache24\htdocs\index.php
The point is that you need to adjust both of the php.ini files if you want to use your sqlite or other extensions both from command line and web server.
Instead of double backslashes, maybe you should use single froward slashes, like extension_dir = "C:/php7/ext" but, disclaimer, I have no installed apache and php on my windows computer so I cannot confirm if I say it correctly.
I still hope I was able to help. :)
I wish you a happy new year. :)

PHP extensions are not recognized by Apache

Running php -m on the command line I can see all of installed PHP extensions. However, on phpinfo() output I can not find some of them e.g. mbstring. What is wrong with it? I use PHP 5.6 and Apache http server 2.4 on windows 7 all 64b.
Did you really not overlook anything?
Add PHP settings in httpd.conf:
LoadModule php5_module "your_path_to\php\php5apache2_4.dll"
AddHandler application/x-httpd-php .php
PHPIniDir "your_path_to\php"
Remove the comma in php.ini: ;extension=php_mbstring.dll to extension=php_mbstring.dll!
It should work now.

PHPIniDir Directive causing apache to crash

I have installed Apache (httpd-2.2.17-win32-x86-openssl-0.9.8o) and PHP (php-5.3.5-Win32-VC9-x86) on Windows XP SP3 and when i use put the PHPIniDir into the Apache configuration file, then Apache won't start, it would crash, and if i removed the directive it works fine but of course doesn't read the PHP configuration.
What might be causing this and what should i do to fix it ?
Here is how it appears inside httpd.conf
#BEGIN PHP INSTALLER EDITS - REMOVE ONLY ON UNINSTALL
LoadModule php5_module "D:/Program Files/PHP/php5apache2_2.dll"
PHPIniDir "D:/Program Files/PHP/"
AddType application/x-httpd-php .php .phtml .html
#END PHP INSTALLER EDITS - REMOVE ONLY ON UNINSTALL
based on answer
Open php.ini file with a notepad or any text editor. Disable all of the extension in php.ini file. Comment extensions by one by, and find out which extension causes the problem.
You are using wrong PHP version.
Use VC6 instead of VC9 (at least for this apache version)

Categories