mysqli for php on Ubuntu 8.04 LAMP stack - php

Does anyone know how, on Ubuntu 8.04, with PHP 5 and MySQL 5.0, to enable/install the mysqli package/extensions?
Preferably I'd like to preserve the existing installations, but, if necessary, I'll reinstall from scratch.
I realise it's not, technically, programming-related but, I think (at a stretch, maybe) it's programming-enabling? hopes
Thanks for any help you're able to provide.

In Ubuntu Hardy (8.04) mysqli is part of the php5-mysql package along with the standard mysql library and pdo - see http://packages.ubuntu.com/hardy/php5-mysql for more info.
sudo apt-get install php5-mysql

You might have to install php with the mysqli option: apt-get install php5-mysqli

From the PHP documentation.
To ensure that the mysqli extension for PHP is enabled, you will need to configure the PHP source code to use mysqli. This is achieved by running the configure script with the option --with-mysqli=mysql_config_path/mysql_config, prior to building PHP. This will enable mysqli and it will use the MySQL Client Library (libmysql) to communicate with the MySQL Server.
But since you are on ubuntu. You can just install the mysqli package. Details about it here.
sudo apt-get install php5-mysqli

With PHP5 php5-mysqli package is not available, but it is replaced by another package. May be package is obsolete.
It can be downloaded by the following command
sudo apt-get install php5-mysqlnd

Related

Installing Mongodb PHP Drivers on Ubuntu 18.04

I have installed mongodb on a new Ubuntu 18.04 server. I can access and work with the database through the command line, but cannot access it via PHP, and was wondering how other people have gotten it to work.
Following a new build of Ubuntu 18.04, and installation of LAMP, I ran:
sudo apt install mongodb-server php-pear php7.2-dev
sudo pecl install mongodb
I then added the mongodb.so extension to the php.ini file, and a phpinfo(); page shows mongodb as installed. So far so good.
If I browse to a test php page ($mongo=new Mongo();), the page fails to load though.
Through web searches, I find the https://github.com/alcaeus/mongo-php-adapter page come up a lot, and I have run the composer installation command there, but to no avail.
Installed versions are: Ubuntu 18.04.2 LTS; mongoDBv3.6.3; php 7.2.17; Apache 2.4.29
I was wondering what steps other people who have gotten PHP to work successfully with Mongodb have followed? I plan to scrap this server and start from a fresh VM install again.
I was able to install php-mongodb after adding the ppa repository ondrej/php:
sudo add-apt-repository ppa:ondrej/php
sudo apt update
sudo apt-get install php-mongodb
try:
sudo apt-get install php-mongodb
worked for me
It appears that you're attempting to use the Mongo class from the legacy driver, but you're using the non-legacy driver so that class doesn't exist. Please look at the documentation for the updated version of the driver here. You might also consider using the MongoDB PHP Library to abstract away many of the driver calls.
Please note that there are also compatibility considerations between your versions of the PHP library, MongoDB, and the MongoDB PHP driver. You can find the compatibility information for them here.

mysqli does not work after installing mysqlnd on ubuntu

After installing php5-mysqlnd, php5-mysql is removed.
I install php5-mysql, php5-mysqlnd is removed and I can use mysqli. However, I will received this error
mysqli_real_connect(): Headers and client library minor version mismatch. Headers:50541 Library:50627
Based on other answers on stackoverflow, I need to install php5-mysqlnd to fix this. How to break out of this cycle?
UPDATE 1:
Try to add extension = mysqlnd.so in php.ini
try php5enmod mysqli and php5enmod mysqlnd in bash
mysqli still does not work after installing php5-mysqlnd by apt-get
mysqli_real_connect(): Headers and client library minor version mismatch. Headers:50541 Library:50627
The error message means that there is a version conflict on your system. You installed the package containing "libmysql" and the package "php5-mysql" which links against that library, while using a different version. This indicates that there either is a bug in packaging from Ubuntu (unlikely) or you messed up with different package sources. To be precise: PHP thinks it would use libmysql 5.5, whereas 5.6 is installed.
Anyways, to the other part of the question: php5-mysqlnd and php5-mysql both contain the different MySQL userspace API libraries (mysql, mysqli and pdo_mysql) one package is the "traditional" one where those modules use libmysql, the other is the "modern" one where those modules use myslqnd. Documentation explaining the difference is on http://php.net/manual/en/mysqlinfo.library.choosing.php short form is: Use mysqlnd unless you have very specific requirements (i.e. using libmysld, with d in the end .. if you don't know what this is you don't want to use it; don't let it confuse you, use mysqlnd)
Now if there is no mysqli after installing php5-mysqlnd this might be caused by Ubuntu installing it, but not enabling the module, for this Ubuntu has a tool php5enmod try this:
php5enmod mysqli

How to install PHP5 with pthreads on Ubuntu?

I have a server which has PHP5 installed. I need pthreads and found that link to install php5 with pthreads:
PHP5 installation with pthreads
I install all the packages I need with apt-get install. I have no idea about what a make file is, how to compile a source code etc. I am a web developer with limited OS knowledge.
I have followed the steps given in the link above. At the last command on step 4, I get an error because /opt/php-zts/modules.d/ does not exist.
I simply wanted to replace existing php with a new php installation that supports pthreads. Now, the server code does not work.
How can I install PHP5 with pthreads enabled so that it will replace existing PHP5 installation that I installed with sudo apt-get install php5 libapache2-mod-php5?
Also, I have another question. I need some other packages like php-curl. Can I install them with sudo apt-get install php-curl after I succesfully install PHP? Do these commands work with custom builds?
Edit: how-to-install-pthread-in-ubuntu-12-10 This is not a solution for my problem because I don't want an isolated installation. I want the installation to replace already existing php installation.

How do I remove Dotdeb version of PHP and replace it with official Ubuntu repo

I'm a UBUNTU and CLI Noob.
I'm running UBUNT 12.04 LTS
I'm trying to get CURL to work for my PHP install and come to find out that PHPCURL does not work with the Dotdeb version of PHP that installed on my server.
Everything I've read so far says to remove the DOtdeb version of PHP and replace it with an official Ubuntu version however I'm not seing any clear instructions on this.
Is there an easy command to remove the Dotdeb version?
Should I just run sudo apt-get -y purge php*? I'm afraid that it will remove stuff I didn't intend to remove but I'm not sure.
Also, how do I know that the new PHP5 package I install is an official Ubuntu package?
First remove Dotdeb.org from your source list.
Next your need to uninstall php5
aptitude purge php5
Now run a simple update
aptitude update
Now reinstall php5
aptitude install php5
This really is the only way to go about it. You really need to do a purge, because simply removing it using normal uninstall does not get rid of the dotdeb config files that sometime remain.
You might just not have the php curl library installed. sudo apt-get install php5-curl will fix that.

can't get odbc working in apache

I installed unixODBC by using apt-get install, and now when I try to use odbc_connect() is still get this error.
PHP Fatal error: Call to undefined function odbc_connect()
what do i need to do to configure it to work with php? I have been looking online but I can't really figure it out.
I think you need to install php5-odbc also. unixODBC provides the driver manager, but you need the PHP code that calls it.
Had the same issue on CentOS 6.3 with PHP 5.3.16. But the fix was to use yum to install php-odbc.
yum install php-odbc
Did you add it to your LD_LIBRARY_PATH? Check the documentation for your server, it may require third-party libraries to be in a specific sub-directory, or have some other mechanism for finding them. If so, you should be able to create a symbolic link to the library. That way, if it gets updated, your server will automatically use it.
We had this problem also. We installed php5-odbc, and still had the problem. Turns out we needed to reboot Linux for php to see the function. Recycling Apache was not enough!
Make sure to enable odbc extension for your Apache by a2enmod odbc.
Then check if exists by: apache2ctl -M.
If you don't have this extension, install via apt-get install php-odbc (use yum in case of CentOS).
See also: Installing the Microsoft ODBC Driver for SQL Server on Linux and macOS.

Categories