Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
1.7k views
in Technique[技术] by (71.8m points)

php - How to install MySQLi on a cPanel-managed server?

I have an existing web application that was written over the past few years. I chose mysqli as the method for accessing a MySQL database. That works fine. My problem is that I'm deploying to a 3rd party web host server - WHM/cPanel - and I cannot find a way to get mysqli installed on this server. I've tried too many things to list here - including everything I could find on this site. This server uses yum. It has PHP5.4 - MySQL 5.5 When I run phpinfo on it there is a MySQL section but no MySQLi section. My code crashes with "class mysqli not found" error. The documentation on PHP.net states that mysqli was included in the standard distribution starting with PHP 5.0. I know for a fact that is no longer true - the last 3 machines i've built with Ubuntu did not have mysqli on them I had to find/install it using apt-get install php5-mysqlnd I cannot find a package for mysqli on this server. Rewriting all my SQL to use the native driver will not be a simple task. i'd prefer to avoid that. Any ideas would be greatly appreciated.

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

The answer to my own question: WHM --> Software --> EasyApache

My current configuration was shown at the top and was selected (radio button). I edited that and selected Exhaustive List of Options. I was able to select several items including mysqli, mbstring, json, mcrypt, XML, date, openssl, sockets, soap, xmlwriter ... hard to believe so many of those were missing many were my next problem I just had not yet discovered.

EasyApache recompiled apache/php for me and restarted apache automagically. MySQLi was now included along with the other elements I selected.

To further configure PHP - I had to use phpinfo to find the php.ini file it is loading and edit that as root (sudo). There is a facility located in

WHM --> Service Configuration --> PHP Configuration Editor

that can be used instead but it is unlikely all options will be available using this page. Also: see note below: I had to manually edit php.ini to configure the new stuff.

I'd like to also point out that there are additional sections that should have been added to the php.ini file but were not. There should be a section to configure mysqli (separate from mysql [native driver]), mbstring, soap etc. These are not present in the php.ini file on my server after running EasyApache to update PHP. I had to edit the php.ini file and add the sections for them and restart apache. Just FYI


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...