2

I have successfully installed php 7.4 with Remi packages in my CentOS 8 VPS (Used this guide https://www.digitalocean.com/community/tutorials/how-to-run-multiple-php-versions-on-one-server-using-apache-and-php-fpm-on-centos-8)

I have a VirtualHost in my Apache server, that points to my domain and load the required php version for that environment.

<VirtualHost *:80>
    ServerName www.example.net
    ServerAlias example.net
    DocumentRoot /var/www/example.net/html
    ErrorLog /var/www/example.net/log/error.log
    CustomLog /var/www/example.net/log/requests.log combined
  <IfModule !mod_php7.c>
    <FilesMatch \.(php|phar)$>
        SetHandler "proxy:unix:/var/opt/remi/php74/run/php-fpm/www.sock|fcgi://localhost"
    </FilesMatch>
  </IfModule>
</VirtualHost>

How do you enable the pdo_sqlsrv extension to a php 7.4 installation using Remi?

I've followed this guide: https://learn.microsoft.com/en-us/sql/connect/php/installation-tutorial-linux-mac?view=sql-server-ver15#installing-the-drivers-on-red-hat-7-and-8 but I think something went wrong.

If I do <?php echo phpinfo(); ?> I see that no modules are being loaded https://gyazo.com/d5a30969f06c49e78bf3473a07776492

Also if I check for the PHP version using php -v, this is the output:

PHP Warning:  Module 'sqlsrv' already loaded in Unknown on line 0
PHP Warning:  Module 'pdo_sqlsrv' already loaded in Unknown on line 0
PHP 7.4.12 (cli) (built: Oct 27 2020 15:01:52) ( NTS )
Copyright (c) The PHP Group
Zend Engine v3.4.0, Copyright (c) Zend Technologies

EDIT:

I have also checked using this command yum list installed | grep php

and I have the following output. Notice the php-pdo from remi.

php-json.x86_64                     7.4.12-1.el8.remi                          @remi-modular
php-pdo.x86_64                      7.4.12-1.el8.remi                          @remi-modular
php-sqlsrv.x86_64                   5.8.1-1.el8.remi.7.4                       @remi-modular
php74.x86_64                        1.0-3.el8.remi                             @remi-safe
php74-php-cli.x86_64                7.4.12-1.el8.remi                          @remi-safe
php74-php-common.x86_64             7.4.12-1.el8.remi                          @remi-safe
php74-php-fpm.x86_64                7.4.12-1.el8.remi                          @remi-safe
php74-php-json.x86_64               7.4.12-1.el8.remi                          @remi-safe
php74-runtime.x86_64                1.0-3.el8.remi                             @```
Alessandro
  • 164
  • 1
  • 2
  • 11
  • 1
    you have it on step 3, but make sure you are using the right .ini file. Also if you are using fpt, you might have to restart the php service, for the change to be effective. – Julien B. Nov 15 '20 at 17:46
  • Looks like, to me, you've not added the modules to your `php.ini`. check the PHP file (crucially that Apache is using) and I suspect you'll note they are missing. – Thom A Nov 15 '20 at 17:46
  • I've tried adding `extension=pdo_sqlsrv.so` to the Php.ini that is being loaded, but still nothing changes. – Alessandro Nov 15 '20 at 17:47
  • Notice both myself and @JulienB. Have suspicious you've not added it to the correct one. I suspect you have added it to a `php.ini` file, just not the one Apache is using. – Thom A Nov 15 '20 at 17:52
  • This is the one I am adding it https://gyazo.com/13d70786f38653136e732f3cf60e458d – Alessandro Nov 15 '20 at 17:52
  • In the output of the `phpinfo()`, look for "Loaded Configuration File", this is most likely where you should add the extensions. – Julien B. Nov 15 '20 at 17:57
  • is there a way to check all the php.ini that are in the system? – Alessandro Nov 15 '20 at 17:57
  • @JulienB. that's exactly what I just showed. I did `phpinfo()` and this is the configuration file https://gyazo.com/13d70786f38653136e732f3cf60e458d and this one is where I added the `extension=pdo_sqlsrv.so` – Alessandro Nov 15 '20 at 17:58
  • Ok, and you do not see anything related to pdo_sqlsrv in your `phpinfo()` output. Note that this is not necessarily listed under additional modules. It might be under its own section "pdo_sqlsrv". – Julien B. Nov 15 '20 at 18:02
  • I don't see anything related to it. – Alessandro Nov 15 '20 at 18:08
  • I see that I have another `php.d` folder outside the Remi package, and it contains a bunch of `.ini` files including `pdo_sqlsrv.ini` – Alessandro Nov 15 '20 at 18:11

1 Answers1

5

How do you enable the pdo_sqlsrv extension to a php 7.4 installation using Remi? php-sqlsrv.x86_64 5.8.1-1.el8.remi.7.4 @remi-modular php74-php-fpm.x86_64 7.4.12-1.el8.remi @remi-safe

You are confused betweeen php-* (single/default version) and php74-* (designed for multiple versions installation). Read the repository FAQ

For a proper installation, simply follow the Wizard instruction.

So, if you use php-fpm, you need php-sqlsrv (which is the simpler way, so recommended).

If you use php74-php-fpm, you need php74-php-sqlsrv.

dnf remove php74\*
dnf install php-fpm php-cli

You don't have to build anything from source, and don't have to modify any INI file.

Remi Collet
  • 6,198
  • 1
  • 20
  • 25