?
Solved

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

Posted on 2007-10-11
6
Medium Priority
?
5,210 Views
Last Modified: 2011-10-03
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
Comment
Question by:cgarvey
  • 2
  • 2
5 Comments
 
LVL 48

Accepted Solution

by:
hernst42 earned 2000 total points
ID: 20055538
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
 
LVL 9

Expert Comment

by:tkalchev
ID: 20063870
Or just

dl("mysql");

no need of PEAR here
0
 
LVL 48

Expert Comment

by:hernst42
ID: 20063902
@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
 
LVL 9

Expert Comment

by:tkalchev
ID: 20064018
@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
 
LVL 1

Expert Comment

by:Computer101
ID: 20649483
Forced accept.

Computer101
EE Admin
0

Featured Post

Free Backup Tool for VMware and Hyper-V

Restore full virtual machine or individual guest files from 19 common file systems directly from the backup file. Schedule VM backups with PowerShell scripts. Set desired time, lean back and let the script to notify you via email upon completion.  

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

There are times when I have encountered the need to decompress a response from a PHP request. This is how it's done, but you must have control of the request and you can set the Accept-Encoding header.
It’s a season to be thankful, and we’re thankful for users like you who engage on site, solve technology problems, and network with others in the industry. What tech are we most thankful for? Keep reading.
The viewer will learn how to dynamically set the form action using jQuery.
The viewer will learn how to look for a specific file type in a local or remote server directory using PHP.
Suggested Courses
Course of the Month17 days, 7 hours left to enroll

864 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question