• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 5369
  • Last Modified:

How can I enable PHP dynamic extensions via the .htaccess file?

I'm using shared hosting on a Linux Server running Apache and I want to enable mysqli, which is a dynamic php extension.
My hosting company has told me I can do ..and I quote :

"All of those directives are customizable from a .htaccess file you must create and place in the directory you wish to affect the change on."

I've searched around and haven't found any examples of doing this.
Can anyone help me out with the necessary .htaccess lines necessary to do this?

Also, when I enable msqli locally on my WAMP server, the service restarts. Does this mean I'm going to have to try to find a way to reboot my hosted server as well or is it only the W in WAMP that necessitates a restart?


Thanks in advance
0
cgarvey
Asked:
cgarvey
  • 2
  • 2
1 Solution
 
hernst42Commented:
Extension can't be enabled via a .htaccess http://www.php.net/manual/en/ini.core.php#id3861895
How  to change other settings via .htaccess and php.ini sSee http://www.php.net/manual/en/configuration.changes.php

you might modify the software to automaticly load extension from within php like this:
require_once('PEAR.php');
pear::loadExtension('mysqli');
0
 
tkalchevCommented:
Or just

dl("mysql");

no need of PEAR here
0
 
hernst42Commented:
@tkalchev:
dl("mysql"); is not sufficient. It depends on the running os. For windows you need:
dl("php_mysqli.dll");
for Linux
dl("mysqli.so");
And thats what you don't need to care about if you use pear.

0
 
tkalchevCommented:
@hernst42

Yes, you are completely right that you should provice library name there, so it should be :

if ( !extension_loaded('mysqli')) {
  if (strtoupper(substr(PHP_OS, 0, 3)) === 'WIN') {
        dl('php_mysqli.dll');
  }
  else {
        dl('mysqli.so');
  }
}

or eveny simplier :

if (!extension_loaded('mysqli')) {
    $prefix = (PHP_SHLIB_SUFFIX === 'dll') ? 'php_' : '';
    dl($prefix . 'mysqli.' . PHP_SHLIB_SUFFIX);
}

Examples taken from http://www.php.net/manual/en/function.dl.php
0
 
Computer101Commented:
Forced accept.

Computer101
EE Admin
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Keep up with what's happening at Experts Exchange!

Sign up to receive Decoded, a new monthly digest with product updates, feature release info, continuing education opportunities, and more.

  • 2
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now