Where is my php.ini file location defined? - configuration

[root#localhost \]# php -i | grep Configuration
Configuration File (php.ini) Path => /usr/local/lib
Loaded Configuration File => (none)

you should use this instead
php --ini

Make the following php script:
<?php
phpinfo();
?>
and run it throw browser. It will contain "Loaded Configuration File" with path to loaded php.ini file.

That is for CLI,
Run phpinfo() and run it thought CGI (apache).
Also, in order to help you you need to post more information!

it seems that apache has no right to read php.ini file under "/usr/local/lib" check the rights for

Related

Getting error when using php artisan migrate [duplicate]

PHP Fatal error: Class 'PDO' not found in /home/bd/public_html/app/webroot/Cake/Model/Datasource/Database/Mysql.php on line 177
PHP INFO:
PDO
PDO support => enabled
PDO drivers => sqlite, sqlite2, mysql
pdo_mysql
PDO Driver for MySQL => enabled
Client API version => 5.5.24
Directive => Local Value => Master Value
pdo_mysql.default_socket => /var/lib/mysql/mysql.sock => /var/lib/mysql/mysql.sock
pdo_sqlite
PDO Driver for SQLite 3.x => enabled
SQLite Library => 3.7.7.1
PHP INI:
extension=pdo.so
extension=pdo_sqlite.so
extension=sqlite.so
extension=pdo_mysql.so
CODE:
/**
* Check whether the MySQL extension is installed/loaded
*
* #return boolean
*/
public function enabled() {
return in_array('mysql', PDO::getAvailableDrivers());
}
Ideas as to why I'm getting this error?
PHP 5.3.15
CloudLinux/CentOS 6
CPanel
try
yum install php-pdo
yum install php-pdo_mysql
service httpd restart
Try adding use PDO; after your namespace or just before your class or at the top of your PHP file.
This can also happen if there is a php.ini file in the web app's current working directory. If one has been placed there to change certain settings, it will override the global one.
To avoid this problem, don't use a php.ini file to change settings; instead you can:
Specify settings in the vhost declaration
Use an .htaccess file with php_flag (see here)
Use an .user.ini file (see here)
Ensure they are being called in the php.ini file
If the PDO is displayed in the list of currently installed php modules, you will want to check the php.ini file in the relevant folder to ensure they are being called. Somewhere in the php.ini file you should see the following:
extension=pdo.so
extension=pdo_sqlite.so
extension=pdo_mysql.so
extension=sqlite.so
If they are not present, simply add the lines above to the bottom of the php.ini file and save it.
What is the full source of the file Mysql.php. Based on the output of the php info list, it sounds like you may be trying to reference a global class from within a namespace.
If the file Mysql.php has a statement "namespace " in it, use \PDO in place of PDO - this will tell PHP to look for a global class, rather than looking in the local namespace.
I had the same problem on GoDaddy. I added the extension=pdo.so to php.ini, still didn't work. And then only one thing came to my mind: Permissions
Before uploading the file, kill all PHP processes(cPanel->PHP Processes).
The problem was that with the file permissions, it was set to 0644 and was not executable . You need to set the file permission at least 0755.
you can just find-out loaded config file by executing below command,
php -i | grep 'php.ini'
Then add below lines to correct php.ini file
extension=pdo.so
extension=pdo_sqlite.so
extension=pdo_mysql.so
extension=sqlite.so
Then restart web server,
service httpd restart
Its a Little Late but I found the same problem and i fixed it by a "\" in front of PDO
public function enabled() {
return in_array('mysql', \PDO::getAvailableDrivers());
}
This error is caused by PDO not being available to PHP.
If you are getting the error on the command line, or not via the same interface your website uses for PHP, you are potentially invoking a different version of PHP, or utlising a different php.ini configuration file when checking phpinfo().
Ensure PDO is loaded, and the PDO drivers for your database are also loaded.
For Fedora 33 you can install as follows:
Install
dnf install php-pdo
dnf install php-pdo_mysql
Restart PHP
systemctl restart php-fpm.service
I solved it with library PHP_PDO , because my hosting provider didn't accept my requirement for installation of PDO driver to apache server.
If you run php with php-fpm module,do not forget to run command systemctl restart php-fpm!That will reload php-fpm module.
I had to run the following on AWS EC2 Linux instance (PHP Version 7.3):
sudo yum install php73-php-pdo php73-php-mysqlnd
After a long time, I finally solved it. check your folder in Cpanel to see if there is a php.ini file. if yes delete it since Cpanel will be using its own php.ini
If anyone getting this error in cPanel, please check the PHP version type in your cPanel. Change it, alt-php to ea-php. This setting worked for me.

How to edit the php.ini file in Ubuntu 19.04 (Disco Dingo)

Consider:
Now I am getting this error. How can I resolve this issue?
I found found some related issue, but that told me change max-size inside file php.ini, so how can I edit file php.ini (phpmyadmin-config)?
Importing into MySQL, the database size is above 100 MB. And the MySQL database size converts it into a ZIP file, and then import working, but it is not inserting all tables.
I'm not sure which OS or Apache server you're using right now.
If you are not aware of the php.ini file path then create one info.php file inside your www/htdocs folder and write the below line of code inside that file.
<?php echo phpinfo(); ?>
Execute the above file in your web browser. You will find the loaded php.ini configuration file path, like shown below.
Now go to the file path and increase the values of the below two variables as per your need.
upload_max_filesize=128M
post_max_size=128M
PS: Don't forget to restart your Apache server. :)
The configuration file is located at the below path:
/etc/php/php_version/apache2/php.ini
Now increase the value of:
post_max_size = 150MB
upload_max_size = 150MB
Then restart the server:
sudo service apache2 restart

CGI Script displayed as Plain Text in Apache2 (localhost)

I currently have to do a web server in Apache2 that consists on a Login/Register web, and I have to call a CGI Script to validate the input data from the user. Well, when I call the script with the submit button, the CGI Script appears as Plain Text, and I don't know what else to do to fix it.
I have tried uncommenting CGI Modules in /etc/apache2/httpd.conf, setting a default directory for CGI Scripts, uncommenting the AddHandler for CGI and changing Options values in my localhost directory and in the CGI directory adding ExecCGI in them all. But it still does not work, it just appears as plain text.
P.S.: I followed this tutorial (http://httpd.apache.org/docs/2.2/howto/cgi.html) and also looked for the solution here in StackOverflow, but I got nothing working for me.
Edit: Also thank you for helping if you do :)
The problem was the directory configuration, so I kept the default http.config file, that has a preset ScriptAlias for the /cgi-bin/ directory to the following directory:
/Library/WebServer/CGI-Executables
Then I enabled the CGI Module by uncommenting the line (removing the '#' before the line) in the httpd.conf file from apache2:
LoadModule cgi_module libexec/apache2/mod_cgi.so
Finally I saved the file, and then I restarted the Apache2 server using the command:
sudo /usr/sbin/apachectl restart
Then I just pasted the .cgi script in the CGI-Executables directory, setting the permissions of the file as chmod a+x.
To run the script now you just have to access
localhost/cgi-bin/script.cgi
Thank you for the help anyways!

Fatal error: Call to undefined function mysqli_init()

I have a really strange error. My httpd server have been working fine until last Wednesday, when I uninstalled the MS SQL and visual studio C#. When I restarted the PC, Ii discovered that some parts of the Environment variable PATH disappeared...Almost all the problems where recovered, The only one that cannot be adjusted is my httpd server... or the PHP configuration, I don't know.
I have already uninstalled the Apache server, PHP and MySql and resintalled them again... I have done this lots of times on other PCs so I'm sure that it should work...but I'm missing something.
The worst thing is that the data I get when I do in cmd "php -i" is different form the data I get form a page info.php like this:
<?php
phpinfo();
?>
The page doesn't show any info about the mysqli configuration...
can any body help me?
I'm trying anything to avoid formatting the PC!!!
Thanks in advance
Update::::::::::::::::::::::::::
With phpinfo I find:
Configuration File (php.ini) Path C:\WINDOWS
Loaded Configuration File C:\PHP\php.ini
In C:\windows there's no php.ini file. Where else can PHP find other configurations?
Open the folder you installed PHP
Edit php.ini file
If no php.ini exists, copy one of the php.ini/Production/Development to php.ini
uncomment
extension=php_mysqli.dll
if you have not installed php in the default folder...
or if you have the php extensions in a separated folder
change the extension_dir to the correct path
change
extension_dir = "C:/APL/php/ext/"

Why won't PHP 5.2.14 display any errors (even from the command line)?

I have PHP 5.2.10 and PHP 5.2.14 (x86 non-threadsafe Win32 builds) installed on a Windows 2008 R2 server and on Windows 7 64 bit.
For some reason PHP 5.2.14 refuses to show error messages.
Even when I set the following settings in php.ini I don't get any errors reported if I use 5.2.14:
error_reporting = E_ALL
display_errors = On
This happens even when running a test script from the command line using php.exe with a deliberate syntax error:
c:\php>php test.php
PHP is using the correct php.ini file because I can see my settings change when I run php.exe -i.
I also notice that php.exe in PHP 5.2.14 is very slow to start up.
When I perform the same set of tests using PHP 5.2.10 on the same machines I get error messages reported just fine.
Both of the php.ini files are stock (based off of php.ini-recommended) but with the error_reporting and display_errors settings modified.
I have found this truly annoying, so here's a strategy for checking the syntax from the command line:
Don't load the ini file.
Turn on display_errors and display_startup_errors explicitly.
php -n -l -d display_errors -d display_startup_errors path/to/your/phpfile.php
$ php -h
-n No php.ini file will be used
-l lint, syntax checking only
-d foo[=bar] Define INI entry foo with value 'bar'
I'm running a later PHP (5.4.24), but these other answers lack the -d option I found exemplified elsewhere that makes PHP display intelligible parsing errors when running from the command line:
php -d display_errors test.php
This is the best answer to the question I was googling. Running the linter with -l only tells you "Errors parsing foo.php".
You might have to enable display_startup_errors as well:
display_startup_errors boolean
Even when display_errors is on, errors that occur during PHP's startup sequence are not displayed. It's strongly recommended to keep display_startup_errors off, except for debugging.
You can also try to lint the file with c:\php>php -l test.php to test for syntax errors.
Lately, I had to work on someone else's project... Not being able to debug, I had no choice but to check for this:
error_reporting(0);
So, check on your source code. Search for something like this: "error_reporting(0);".
Once you've found it, comment it!!!
Normally, you don't have to put that in the source code, but in the php.ini file.