I'm sure this is something simple that I'm overlooking, but it's driving me a bit crazy. I'm on a Ubuntu machine running LAMP. I have several sites running on this machine using Php / MySql without a hassle. I've recently begun a site using the Yii framework, but I don't think that this is a Yii quesiton. Maybe it is. Anyway...
My other sites used mysqli so Yii's PDO requirement is new to me. I did a quick -i|grep on the PDO and it came back as installed / enabled so no worries. I installed the framework, created a quick test site and database. However, when I try to connect to the database via the site I get an error telling me that the PDO failed. Specifically, a failure to open the stream. So it's not finding the PDO even though the PDO is installed. The Yii site is in the same web folder as the other sites, so there can't be a path issue.
From a Yii standpoint, if that is where the problem lies... I was able to create controllers for the various database tables in Gii, but pulled the same unable to open stream error when I tried to generate CRUD for those tables.
For the record, yes, the MySql is enabled in the Yii main.php file. Yes, the connection string is correct. I'm a bit at a loss as to why the PDO would fail to open if it lists as enabled.
Posting this just for the search engines. I still have no idea exactly what the problem might have been. As I mentioned, PDO was showing enabled from the CLI, but not from phpinfo. This is possible because the CLI uses a different php.ini than does apache2. However, after a complete re-install of php I was still running into the same problem. I again opened both .ini files in gedit and went line by line with them using a non-case sensitive find on "pdo". They were absolutely, completely identical. Finally, I gave up trying to understand the problem and just went for the easy fix. I removed the .ini from Apache2 and replaced it with the one from cli, and voila! I have PDO enabled in Apache2. I still have absolutely no idea what the problem was, but at least it's solved.
Related
Sorry to get back to you for a question that has been asked many years ago. But I am really stuck with this.
I have a legacy application which is very old, running PHP 5.2.17.
I followed this guide to setup my docker container
https://andrewscaya.net/blog/bringing-php-52-back-life
I have everything setup correctly. I made a downloaded and compiled a PHP installation and configured this with Apache. And its working fine with php.
However, it is essential that I have SSL support (in PHP) for the POSTGRES connection.
Which is now default not enabled according to PHPINFO
I have basically the very same problem somebody else had many years ago. SSL support of Pgsql
See:
Enable SSL support for pgsql
So from what I am understanding is that I need to recompile PHP again, but with a package called libpg ?
Where do I get this package and how can I compile this with the PHP source code?
After 2 days of searching I finally found LAPP stack which has some older versions available with pgsql ssl support
https://community.bitnami.com/t/can-i-get-the-installers-for-wapp-and-lapp-stacks-for-5-4-45/38548
In the long-run I would recommend upgrading PHP versions, but I understand that this can be a lot of work. There are many good guides on upgrading versions. I recommend going through the version upgrades one-by-one, dealing with deprecated features and other potential problems one-at-a-time and testing each script.
In the short-term, I'm not sure if this would work, but PDO is supported in 5.2 (actually in 5.1 even) and as it simply passes info to the PostgreSQL library, I would expect SSL support to work. I have used it in 5.4, and I am not aware of any changes made between those two versions.
There is a solution here, by IMSoP, that explains how to get this working and points you to more official documentation if you need more info: Connecting to PGSQL over SSL via PHP PDO
If this fails, a second approach that I would try would be to create an SSH tunnel to connect to a local port. An example would be:
ssh -L 127.0.0.1:5443:127.0.0.1:5432 username#remoteboxaddress
Then you can initiate what looks to PHP like a local connection on port 5433, but it will actually be a (secure) SSH tunnel to the remote box. This will also require that the remote box is configured to accept (non-encrypted) local connections, and that you have SSH access to it. Then, if you test it out and it works, you can make a script to start the tunnel on boot, or better yet, when the webserver is started; this necessitates using an authentication method like keys stored in a file, that doesn't require the entering of a password. So...there are a lot of "if's" here, in terms of whether or not you will be able to get this solution to work, but it can be done if you have root access on both servers, and occasionally if you do not, depending on how they are configured.
Hopefully, one of these two solutions will work for you.
I am trying to use the yii framework for a while. I have been referring - first-app-doc and yiic-doc.
I have read all the posts related to mine on "stackoverflow" but couldn't get any luck resolving my problem. Mostly because I am stuck on the .ini files and the pdo.
I have modified the config file-protected/config/main.php according to my database configuration. I am using the command line tool - yiic to create the model. It gives me 'http://hostname/path/to/index.php?r=user' to hit.
When I hit http://localhost/index.php?r=user; it gives CDbException - CDbConnection failed to open the DB connection: could not find driver in the browser itself. It seems like it can't find the pdo_mysql.
Also, I don't have the php.ini file in /etc/php5/, but I have different php.ini files in /etc/php5/cgi/, /etc/php5/apache2/ and /etc/php5/cli/.
Also, the php5-mysql package, I have it installed on my computer.
I have been trying and trying. This is like impossible to do.
I know this is a little old question now but hopefully it can help other people, I actually had the same issue I was using it on Google Compute engine where we set up the server and we found out you have to install sqlite PDO extension as well as the MySQL PDO extension.
More information is on my question: https://stackoverflow.com/a/24555366/817213
Hopefully this can help other people too.
1- try to access the database with MAMP or WAMP or XAMP, or even by command line first. you will then know if you need a username and password for that.
2- check what databases you have. you will know then if the database exists or not.
3- check the database connection string in the project if it's correct or not.
Trying to install Joomla 2.5.7 but I can't get past the Pre-Installation Check as it says: Database support: No
I've got mysql (5.5.24) and php (5.3.15) installed manually on a Linux machine (I don't want to use LAMPP). I've done this a few times before and checked everything is the same with my other working machines in terms of the packages and the php.ini file. I can also access the mysql fine.
Any suggestions on what I can try? Is there a way to find out what check it is failing on?
Argh! I did miss a package. A pretty vital one at that: php-mysql. Don't forget to restart web server.
Joomla checks what databases are supported by testing each type for a connection. One possible issue is that the way you have things set up the owner of the installation process does not have permission to use the databases.
Ooops sorry I didn't see that you had soled
Most CMS come with a sql database setup files. These files must be added to your mysql data. Or tables and users must be manually created.
Have you done this?? If not check manual for details.
http://linuxinternetworks.com/how-to-install-joomla-in-linux/
Comment, after trying, I am reading it too.
I've been googling and searching SO for the better part of an hour, and fail to find a good answer. I'm a server admin noob here, so I'm sure this is not too difficult, but I sure don't know what to do.
Info:
Running PHP5.3.6 on an Apache server, using WHM/cPanel as the server admin GUI
I'm trying to connect to a client's MsSQL database, and alas, get the following error:
Fatal error: Call to undefined function mssql_connect()
So I start googling, see that perhaps that's not the best function to use anyway. Alright, so I look at PHPinfo for PDO support:
PDO drivers sqlite, sqlite2, mysql
How on earth do I get mssql to show up in that list, so I can do something like the following:
$dbh = new PDO("mssql:host=host.name;dbname=name", 'user', 'pass');
I can't seem to google my way out of this one. Any thoughts?
You can uncomment the "extension=php_pdo_mssql.dll" line in php.ini if you have access to it.
If it still doesn't work, you might want to try this (once again, only if you have access to it):
ntwdblib.dll - The most common issue is that you do not have the
ntwdblib.dll file installed in your PHP directory (where php.exe is,
or sometimes placing it in the ext directory works as well). This
library can be found with your Enterprise Manager dll's or in your SQL
servers system32 folder. It's generally best to take the file from the
server where SQL Server is installed -quoted from
http://www.helpspot.com/helpdesk/index.php?pg=kb.page&id=13
If you are doing this on some kind of rented hosting (IE: Shared Hosting) you may need to contact the support from the hosting provider to get them to enable it if you can't get it to work.
http://us.php.net/mssql also has a lot of information. The installation is what I just stated above, but the user comments address a lot of more unique situations and provide more detail.
Is there a pure PHP implementation of SQLite that will run on PHP 5.1.6? I am working on an application that would benefit from being able to store data in a relational database, but the server that it has to run on is stuck with PHP 5.1.6 and has been configured "'--without-sqlite"
I have no control over this server; cannot recompile, upgrade or otherwise modify PHP aside from using .htaccess files. Hosting externally is also not an option, unfortunately. MySQL may be possible but would be a nightmare trying to get their IT to create a database for me. (It took them 6 weeks to get .htaccess files enabled because of red tape and other things)
Am I out of luck? My fall back is to write everything to flat files but I really would rather not do that.
EDIT: Fixed typo. PHP does not have the SQLite extension and was configured "'--without-sqlite" according to the output of phpinfo()
Actually, you could easily download and install sqlite in your userspace, whether on windows or on a linux remote shell doesn t usually matter unless your host is unusually restrictive, if that is the case you should change service provider.
Once sqlite is installed, you can one of the available pear extensions or pecl extension to allow easy access through php.
Tutorial and code examples for the pear solution here.