How to install a php extension by .so file?

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
leekis
Forum Newbie
Posts: 3
Joined: Wed May 12, 2010 3:21 pm

How to install a php extension by .so file?

Post by leekis »

Hi, everyone!
I need your help!

I'm working on a project that needs to develop a php extension for our clients.
The php extension is written by C/C++ and we have complied and installed it to our linux server for testing by using phpize and etc.

So I got a .so file and now we should deliver our product it to our clients, but the problem is that we can't give the source code to them for installing on their php server.
I googled a lot, but all the articls are about phpize&./configure&make&make install things by which needs the source code.

Can I just give the .so file which is complied on our server to our clients and then tell them just copy the .so file to the php exetension modules folder ,setup the php.ini file and then restart apache?
Does it work? Or some ideas?
User avatar
flying_circus
Forum Regular
Posts: 732
Joined: Wed Mar 05, 2008 10:23 pm
Location: Sunriver, OR

Re: How to install a php extension by .so file?

Post by flying_circus »

leekis wrote:Can I just give the .so file which is complied on our server to our clients and then tell them just copy the .so file to the php exetension modules folder ,setup the php.ini file and then restart apache?
Does it work? Or some ideas?
This should work just fine.
User avatar
AbraCadaver
DevNet Master
Posts: 2572
Joined: Mon Feb 24, 2003 10:12 am
Location: The Republic of Texas
Contact:

Re: How to install a php extension by .so file?

Post by AbraCadaver »

flying_circus wrote:
leekis wrote:Can I just give the .so file which is complied on our server to our clients and then tell them just copy the .so file to the php exetension modules folder ,setup the php.ini file and then restart apache?
Does it work? Or some ideas?
This should work just fine.
Yes, so long as any libraries that your extension uses are also on the other server.
mysql_function(): WARNING: This extension is deprecated as of PHP 5.5.0, and will be removed in the future. Instead, the MySQLi or PDO_MySQLextension should be used. See also MySQL: choosing an API guide and related FAQ for more information.
leekis
Forum Newbie
Posts: 3
Joined: Wed May 12, 2010 3:21 pm

Re: How to install a php extension by .so file?

Post by leekis »

I see! Thank you very much!!
leekis
Forum Newbie
Posts: 3
Joined: Wed May 12, 2010 3:21 pm

Re: How to install a php extension by .so file?

Post by leekis »

AbraCadaver wrote:
flying_circus wrote:
leekis wrote:Can I just give the .so file which is complied on our server to our clients and then tell them just copy the .so file to the php exetension modules folder ,setup the php.ini file and then restart apache?
Does it work? Or some ideas?
This should work just fine.
Yes, so long as any libraries that your extension uses are also on the other server.

Thanks for your replay!

I tried to copy the .so file to the php extension folder and use dl("abc.so") to load.
But it failed.

When I use "make" to compile the source on my machine, I found a file called "abc.la" created along with the "abc.so".
Do I have to do something with the "abc.la" file too???
Or do some "ldconfig" stuff after I copied the abc.so to the php extension folder???
By the way, the abc.so file needs a 3rd party library of linux program and that's installed at the same path on the client's server too.
Post Reply