問題描述
我有一個現有的 Web 應用程序,該應用程序是在過去幾年中編寫的.我選擇 mysqli 作為訪問 MySQL 數據庫的方法.這很好用.我的問題是我正在部署到 3rd 方網絡主機服務器 - WHM/cPanel - 我找不到在該服務器上安裝 mysqli 的方法.我嘗試了太多無法在此列出的內容 - 包括我在本網站上可以找到的所有內容.此服務器使用 yum.它有 PHP5.4 - MySQL 5.5 當我在它上面運行 phpinfo 時,有一個 MySQL 部分,但沒有 MySQLi 部分.我的代碼因找不到類 mysqli"錯誤而崩潰.PHP.net 上的文檔指出,從 PHP 5.0 開始,mysqli 包含在標準發行版中.我知道一個不再正確的事實 - 我用 Ubuntu 構建的最后 3 臺機器上沒有 mysqli 我不得不使用 apt-get install php5-mysqlnd 找到/安裝它我找不到 mysqli 的包這個服務器.重寫我所有的 SQL 以使用本機驅動程序將不是一項簡單的任務.我寧愿避免這種情況.任何想法將不勝感激.
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.
推薦答案
我自己問題的答案:WHM --> 軟件 --> EasyApache
The answer to my own question: WHM --> Software --> EasyApache
我當前的配置顯示在頂部并被選中(單選按鈕).我編輯了它并選擇了詳盡的選項列表.我能夠選擇幾個項目,包括 mysqli、mbstring、json、mcrypt、XML、date、openssl、sockets、soap、xmlwriter ......很難相信其中很多都丟失了很多是我的下一個問題,我還沒有發現.
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 為我重新編譯了 apache/php 并自動重啟了 apache.MySQLi 現在與我選擇的其他元素一起包含在內.
EasyApache recompiled apache/php for me and restarted apache automagically. MySQLi was now included along with the other elements I selected.
為了進一步配置 PHP - 我必須使用 phpinfo 來找到它正在加載的 php.ini 文件并以 root 身份編輯它 (sudo).有一個設施位于
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 --> 服務配置 --> PHP 配置編輯器
WHM --> Service Configuration --> PHP Configuration Editor
可以代替使用,但使用此頁面不太可能提供所有選項.另外:請參閱下面的說明:我必須手動編輯 php.ini 才能配置新內容.
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.
我還想指出,還有其他部分應該添加到 php.ini 文件中,但沒有添加.應該有一個部分來配置 mysqli(與 mysql [本機驅動程序] 分開)、mbstring、soap 等.在運行 EasyApache 更新 PHP 后,我的服務器上的 php.ini 文件中沒有這些.我必須編輯 php.ini 文件并為它們添加部分并重新啟動 apache.僅供參考
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
這篇關于如何在 cPanel 管理的服務器上安裝 MySQLi?的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網!