PHP not loading module as user - php

I have a problem where drush isn't able to connect to my drupal site with mysql. I think it's due to a module loading issue. For example, as root, I check if pdo_mysql is loaded like this:
# php -m|grep mysql
mysql
mysqli
pdo_mysql
# php -m|wc -l
55
# which php
/usr/bin/php
# php -i|grep conf
Scan this dir for additional .ini files => /etc/php5/cli/conf.d
Additional .ini files parsed => /etc/php5/cli/conf.d/curl.ini,
/etc/php5/cli/conf.d/gd.ini,
/etc/php5/cli/conf.d/ldap.ini,
/etc/php5/cli/conf.d/mysql.ini,
/etc/php5/cli/conf.d/mysqli.ini,
/etc/php5/cli/conf.d/pdo.ini,
/etc/php5/cli/conf.d/pdo_mysql.ini
But when I run this command as my user, I don't see any mysql modules:
$ php -m|grep mysql
$ php -m|wc -l
48
$ which php
/usr/bin/php
$ php -i|grep conf
Scan this dir for additional .ini files => /etc/php5/cli/conf.d
Why is this? And how do I get these modules to be loaded in php-cli as my user?
I'm using php 5.3.10 (old I know, but it's for compatibility with our production servers) on ubuntu 14.04.

I solved this by making /etc/php5 executable: chmod a+x /etc/php5.

Related

PHP does not updates

So I'm currently running php 5.5.34 on my mac.
I tried installing php 5.6 via :-
curl -s https://php-osx.liip.ch/install.sh | bash -s 5.6
However, after installing when I ran php -v , it again gave me 5.5
What am I doing wrong here?
Edit.
php --ini output
Configuration File (php.ini) Path: /usr/local/php5/lib
Loaded Configuration File: /usr/local/php5/lib/php.ini
Scan for additional .ini files in: /usr/local/php5/php.d
Additional .ini files parsed: /usr/local/php5/php.d/10-extension_dir.ini,
/usr/local/php5/php.d/20-extension-opcache.ini,
/usr/local/php5/php.d/40-curl.ini,
/usr/local/php5/php.d/40-openssl.ini,
/usr/local/php5/php.d/50-extension-apcu.ini,
/usr/local/php5/php.d/50-extension-curl.ini,
/usr/local/php5/php.d/50-extension-gmp.ini,
/usr/local/php5/php.d/50-extension-igbinary.ini,
/usr/local/php5/php.d/50-extension-imap.ini,
/usr/local/php5/php.d/50-extension-intl.ini,
/usr/local/php5/php.d/50-extension-mcrypt.ini,
/usr/local/php5/php.d/50-extension-memcached.ini,
/usr/local/php5/php.d/50-extension-mongodb.ini,
/usr/local/php5/php.d/50-extension-mssql.ini,
/usr/local/php5/php.d/50-extension-pdo_pgsql.ini,
/usr/local/php5/php.d/50-extension-pgsql.ini,
/usr/local/php5/php.d/50-extension-propro.ini,
/usr/local/php5/php.d/50-extension-raphf.ini,
/usr/local/php5/php.d/50-extension-readline.ini,
/usr/local/php5/php.d/50-extension-redis.ini,
/usr/local/php5/php.d/50-extension-solr.ini,
/usr/local/php5/php.d/50-extension-ssh2.ini,
/usr/local/php5/php.d/50-extension-xdebug.ini,
/usr/local/php5/php.d/50-extension-xsl.ini,
/usr/local/php5/php.d/60-extension-pecl_http.ini,
/usr/local/php5/php.d/99-liip-developer.ini

ubuntu litespeed php7.0 got a weird php.ini path

Ubuntu 16.04.2
LSPHP7.0
wget -O - http://rpms.litespeedtech.com/debian/enable_lst_debain_repo.sh | bash
apt install -y lsphp70
Then I added /usr/local/lsws/lsphp70/bin to $PATH and made a symlink for /usr/local/lsws/lsphp70/bin/php7.0 to /usr/local/lsws/lsphp70/bin/php. This way I can run php in terminal as cli version.
apt install composer
composer require geoip2/geoip2:~2.0
I got an error said the requested PHP extension curl is missing from your system.
And also it said
To enable extensions, verify that they are enabled in those .ini files:
- /etc/php/7.0/cli/php.ini
You can also run `php --ini` inside terminal to see which files are used by PHP in CLI mode.
But when I run php -i | grep php.ini it shows the ini is not /etc/php/7.0/cli/php.ini but /usr/local/lsws/lsphp70/etc/php/7.0/litespeed/php.ini
Further more, I run php --ini, it shows:
Configuration File (php.ini) Path: /usr/local/lsws/lsphp70//etc/php/7.0/litespeed/
Loaded Configuration File: /usr/local/lsws/lsphp70/etc/php/7.0/litespeed/php.ini
Scan for additional .ini files in: /usr/local/lsws/lsphp70//etc/php/7.0/mods-available/
Additional .ini files parsed: /usr/local/lsws/lsphp70//etc/php/7.0/mods-available/curl.ini,
/usr/local/lsws/lsphp70//etc/php/7.0/mods-available/imap.ini,
/usr/local/lsws/lsphp70//etc/php/7.0/mods-available/json.ini,
/usr/local/lsws/lsphp70//etc/php/7.0/mods-available/mysqli.ini,
/usr/local/lsws/lsphp70//etc/php/7.0/mods-available/opcache.ini,
/usr/local/lsws/lsphp70//etc/php/7.0/mods-available/pdo_mysql.ini
How can php cli get /etc/php/7.0/cli/php.ini as its php config file? Anyone gives a clue? thanks.
Ubuntu normally installs system default php(currently php7.0) to /usr/bin/php
Composer will normally call the PHP defined in $PATH, usually /usr/bin/php.
The Error "the requested PHP extension curl is missing from your system" means Ubuntu system default php7.0 curl is missing. To resolve:
apt-get install php7.0-curl
So far, it should resolve your problem already.
LiteSpeed Web Server normally use LiteSpeed API to communicate with PHP engine, which is faster than other APIs. In LiteSpeed Ubuntu/Debian repo, it provides different versions of lsphp, which will be at different location other than system default location, normally at /usr/local/lsws/lsphpxx/bin/.
Composer will normally use system default php location as explain above. If you want to overwrite PHP path to use lsphp70 php binary, you will need to add this path to the beginning of $PATH.
export PATH="/usr/local/lsws/lsphp70/bin/:$PATH"
This way, when you run:
which php
System should use the php found first in the PATH, which is /usr/local/lsws/lsphp70/bin/php
In this case, when you see similar php-curl missing error message, you should run:
apt-get install lsphp70-curl
to fix the problem.
To make the new PATH permanently, you can edit ~/.profile or .bashrc, or any other similar way, which is beyond the discussion of this topic.

Laravel 5: Artisan throw PDOException could not find driver

I've found other question like this but none seems to solve my problem. In my case it occurs on any artisan command, even if I just type "php artisan" the output is [PDOException] could not find driver.
I'm running Laravel 5 on Ubuntu 14.04 LTS, with a LEMP stack (PHP 5.6 fpm, Mysql, Nginx). In the config/database.php the default driver is set to mysql.
I've checked the output of php --ini, it seems to load all configuration files:
Configuration File (php.ini) Path: /etc/php5/cli
Loaded Configuration File: /etc/php5/cli/php.ini
Scan for additional .ini files in: /etc/php5/cli/conf.d
Additional .ini files parsed: /etc/php5/cli/conf.d/05-opcache.ini,
/etc/php5/cli/conf.d/10-pdo.ini,
/etc/php5/cli/conf.d/20-gd.ini,
/etc/php5/cli/conf.d/20-json.ini,
/etc/php5/cli/conf.d/20-mcrypt.ini,
/etc/php5/cli/conf.d/20-mysql.ini,
/etc/php5/cli/conf.d/20-mysqli.ini,
/etc/php5/cli/conf.d/20-pdo_mysql.ini,
/etc/php5/cli/conf.d/20-readline.ini
If i open /etc/php5/cli/conf.d/20-pdo_mysql.ini i see:
; configuration for php MySQL module
; priority=20
extension=pdo_mysql.so
And this the content of /etc/php5/cli/conf.d/10-pdo.ini is:
; configuration for php PDO module
; priority=10
extension=pdo.so
Inside /etc/php5/cli/conf.d i see pdo ini files symlinked like this:
10-pdo.ini -> ../../mods-available/pdo.ini
20-mysql.ini -> ../../mods-available/mysql.ini
20-pdo_mysql.ini -> ../../mods-available/pdo_mysql.ini
The symlink match the base directory /etc/php5/mods-available that contains all the ini files:
pdo.ini
pdo_mysql.ini
That's all. If someone already experienced this, some help would be really appreciated. Thanks!
So, after many attempts i finally find out how to fix it: just needed to install php5-sybase package. After that Artisan works perfectly!
I guess on homestead it's already installed, unluckily I needed to configure a bare-bone ISO on a VMWare Workstation.

Enable Thread Safety in PHP+Apache2 on Ubuntu - compiling php from source with pthreads

I'm trying to get pthreads running on my Ubuntu-Server (14.04) after I installed Apache2 and PHP5 via apt-get.
My initial steps:
installed apache2 - apt-get install apache2
installed php5 with the usual modules apt-get install php5 libapache2-mod-php5 php5-mcrypt ...
Then i followed this tutorial to get pthreads running (User contributed manual on php.net):
1 - Get PHP version
For this example we will use version: 5.4.36
# wget http://www.php.net/distributions/php-5.4.36.tar.gz
2- Get Pthreads version:
I'm using an old version but, you could take any on
# wget http://pecl.php.net/get/pthreads-1.0.0.tgz
Extract both, php and pthreads versions
#tar zxvf php-5.4.36.tar.gz
#tar zxvf pthreads-1.0.0.tgz
3- Move Pthreads to php/ext folder. Inside version of PHP downloaded at item 1.
4- Reconfigure sources
# ./buildconf --force
# ./configure --help | grep pthreads
You have to see --enable-pthreads listed. If do not, clear the buidls with this commands:
# rm -rf aclocal.m4
# rm -rf autom4te.cache/
# ./buildconf --force
5 - Inside php folder run configure command to set what we need:
# ./configure --enable-debug --enable-maintainer-zts --enable-pthreads
--prefix=/usr --with-config-file-path=/etc
6 - Install PHP
We will run make clear just to be sure that no other crashed build will mess our new one.
# make clear
# make
# make install
7 - Copy configuration file of PHP and add local lib to include path
# cp php.ini-development /etc/php.ini
Edit php.ini and set Include_path to be like this:
Include_path = “/usr/local/lib/php”
9 - Check Modules
# php -m (check pthread loaded)
You have to see pthreads listed
10 - If pthread is not listed, update php.ini
# echo "extension=pthreads.so" >> /etc/php.ini
Everything works fine until step 7.
There is a new directory (seems to be the make install - outcome) in /usr/lib/php .
Now i don't know how to handle with replacing the existing php-installation with my new one.
Where do i have to copy the php.ini-development from step 7?
I tried cp php.ini-development /etc/php.ini
but it had no effect on my existing installation.
How can i get my new-compiled php working in / with apache2?
I found three php.ini-files from the initial installation on my server:
/etc/php5/apache2/php.ini
/etc/php5/fpm/php.ini
/etc/php5/cli/php.ini
Create a file in your webserver's root folder (or any folder that you can easily access from a browser). Inside the file write the following and save it as phpinfo.php:
<?php phpinfo(); ?>
When you access the file from a browser, you will see the configuration of the php engine that parsed the file. Somewhere there is the path to your php.ini file, the one you need to modify.
Usually, if you are using mod_php5 then your php.ini SHOULD be the one located under the apache2 folder; if you are using php-fpm then it should be the one under fpm, but the only certain way to know which one you are using is to issue a phpinfo().

Issue with the doctrine-cli

I am having issues getting my database to build from my YAML file.
Here is the error:
./scripts/doctrine-cli build-all-load
build-all-load - Generated models successfully from YAML schema
build-all-load - Couldn't locate driver named mysql
build-all-load - Created tables successfully
build-all-load - Data was successfully loaded
It builds my models, but nothing in the database. I am using MAMP and I have checked and pdo_mysql is running. I am not completely sure why this would happen. Thank you.
This quite looks like pdo_mysql is not enabled ; you said you checked php.ini, but did you check the one that's used when PHP is run from the command line ?
(That's often not the same as the one used when PHP is run as an Apache module)
You can use php -m to get the list of loaded extensions :
$ php -m
[PHP Modules]
bcmath
bz2
...
pcre
PDO
pdo_mysql
...
And php -i should indicate which .ini file is used, when running PHP from the CLI :
$ php -i | grep 'ini'
Configuration File (php.ini) Path => /etc/php5/cli
Loaded Configuration File => /etc/php5/cli/php.ini
Scan this dir for additional .ini files => /etc/php5/cli/conf.d
additional .ini files parsed => /etc/php5/cli/conf.d/apc.ini,
/etc/php5/cli/conf.d/curl.ini,
...

Categories