Hello!

I need to install some PHP modules in my webstie (curl, mbstring, openssl and xmlrpc). The manual sais that I have to edit my php.ini file and write in it:

php_extension_dir=<path_to_my_php_extensions>
php_extension=libcurl.so
...

The problem is that I can't do this because I don't have permissions to write this file.

I've read that I could do this with .htaccess (where I can write) instead of with php.ini, just writing the same code (without the '=' operator).

I've tested this and my website crashes.

Does anybody know how to load a PHP extension without using php.ini?

I hope I've explained myself well.

Thank you,

Potter

Comments

charlie_’s picture

Yes, you provided an excellent description. :)
You are using Drupal, correct?
That being the case. Simply open the .htaccess file that comes as part of the Drupal distribution.
You should have a copy in your Drupal root. Now that you have it open in your editor, scroll
down until you find the line that states:
<IfModule mod_php4.c>

an example for php 4

 
<IfModule mod_php4.c>
php_extension_dir <path_to_my_php_extensions>
php_extension mbstring.so
php_extension openssl.so
php_extension libcurl.so
# or
php_extension curl.so
# which ever is the case
 
</IfModule>
 

an example If you are using php 5

 
<IfModule mod_php5.c>
php_extension_dir <path_to_my_php_extensions>
php_extension mbstring.so
php_extension openssl.so
php_extension libcurl.so
# or
php_extension curl.so
# which ever is the case
 
</IfModule>
 

In both cases, I'm assuming you're using Apache, and loading PHP as
an Apache module.
Also, given that I am running/operating all of my 50 servers locally, I haven't
ever had the need to make these declarations via .htaccess. As I have access to
all of my PHP installations, and thus, all of the php.ini files. I only state this
to let you know that I haven't ever had to do this before (untested). It should
work. However, there may be a slight discrepancy. It would very likely be in your best
interest to do some further research at the PHP web site.
Performing a search there for php.ini.
A search at the Apache web site might also provide additional answers.

Further; should it not already be obvious, you'll need to replace <path_to_my_php_extensions> with the location of where you managed
to install the required PHP extensions. :)

Best wishes.

--Charlie

cog.rusty’s picture

I think this is unlikely to work using php_value lines in htaccess... According to the following, there are three kinds of PHP variables, PHP_INI_SYSTEM, PHP_INI_PERDIR, and PHP_INI_ALL.

http://php.net/ini.core

The first kind can be set only in php.ini, the second kind can be set also in .htaccess using a php_value line, and the third kind can be also set in any php script with an ini_set() function call (Drupal has some of those in settings.php). And the ones you want are of the first kind.

Sometimes a modified local copy of the php.ini file in your site's web root works. Sometimes a php.ini file which contains only your changes works as well (but sometimes that resets all other values to the php defaults).

charlie_’s picture

Like I said...

Also, given that I am running/operating all of my 50 servers locally, I haven't
ever had the need to make these declarations via .htaccess. As I have access to
all of my PHP installations, and thus, all of the php.ini files. I only state this
to let you know that I haven't ever had to do this before (untested). It should
work. However, there may be a slight discrepancy. It would very likely be in your best
interest to do some further research at the PHP web site.
Performing a search there for php.ini.
A search at the Apache web site might also provide additional answers.

Emphasis on the php, and Apache web sites. :)

--Charlie

rubeuspotter’s picture

Hello!

Sorry, but I can't access to the PHP an Apache links you sent me, do you know any other page that explain these issues? I've searched through google but I didn't find any page really good.

On the other hand, I've tested these two links:

http://drupal.org/node/113220
http://drupal.org/node/147534

to create a copy of php.ini but it doesn't work.

I don't know if it has to be with my site configuration. My website runs over Linux, Apache 2.0.63, Perl 5.8.8, PHP 5.2.5, cpanel...but I've seen that the files mentioned in the two post above are in a different place, for example, I have my php.ini file in /usr/local/lib, I don't have php.cgi file...

Do you know what could I do now or where could I see?

Thank you.