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.
Related
I am using xampp in ubuntu, while i do php artisan migrate, it showed PDO Exception could not find driver
Then to fix that
I showed me to install mbstring, php_curl etc., i have installed mbstring, then while install php_curl i got error can't locate
root#allau-Inspiron-5558:/home/allau# sudo apt-get install php5-curl
Reading package lists... Done
Building dependency tree
Reading state information... Done
E: Unable to locate package php5-curl
when i type php --ini it showed the following
root#allau-Inspiron-5558:/home/allau# php --ini
Configuration File (php.ini) Path: /etc/php/7.0/cli
Loaded Configuration File: /etc/php/7.0/cli/php.ini
Scan for additional .ini files in: /etc/php/7.0/cli/conf.d
Additional .ini files parsed: /etc/php/7.0/cli/conf.d/10-opcache.ini,
But i am using xampp in ubuntu, i guess it points the php.ini of /etc/php/7.0 but i want to use php of /opt/lampp how can i do that ?
help pls
PHP that you are using via CLI is different from the one that is being used by XAMPP. XAMPP brings its own PHP, and if you want to run that one via CLI instead the one that you probably got with Ubuntu, then you should add it to your PATH:
nano ~/.bashrc
Then add this line at the end of the file:
export PATH=/opt/lampp/bin:$PATH
...and save it (ctrl+o -> enter -> ctrl+x)
I'm running Manjaro linux and I have installed apache 2.4.10-1 with php 5.5.15-1 and php-composer 1.0.0.alpha8.458-1.
I want to download project with composer by this command
composer create-project nette/sandbox TaskManager
but I'm getting error with ext-iconv
- nette/neon v2.2.1 requires ext-iconv * -> the requested PHP extension iconv is missing from your system.
- nette/nette v2.2.0 requires ext-iconv * -> the requested PHP extension iconv is missing from your system.
But in my php.ini i have enabled iconv extension
extension=iconv.so
.
.
[iconv]
iconv.input_encoding = ISO-8859-1
iconv.internal_encoding = ISO-8859-1
iconv.output_encoding = ISO-8859-1
In my php scripts I can use iconv function without any problem.
When I run php -m i see iconv in list with other modules
Any idea where could be problem?
Edit:
When I run php -i from cli, I got this:
Configuration File (php.ini) Path => /etc/php
Loaded Configuration File => /etc/php/php.ini
Scan this dir for additional .ini files => /etc/php/conf.d
Additional .ini files parsed => (none)
And in this config file is iconv enabled.
Even when I run
php -d error_reporting=E_ALL -r 'echo iconv("UTF-8", "ASCII//TRANSLIT", "Žluťoučký kůň\n");'
it executes properly and prints "Zlutoucky kun".
So i found out, that composer uses different php config file, which is stored in
/usr/share/php-composer/php.ini
there I just added following line
extension=iconv.so
And everything works!
I solved this problem uncomment the line
ext=iconv
in /etc/php/ini.php
Working on manjaro linux
In WHM on Centos7 it worked for me.
yum install ea-php72-php-iconv
You can replace your php version instead of php72
If you are using PHPBrew run this command to install iconv extension:
phpbrew ext install iconv
I'm also running Arch (under the Manjaro stack, also using pacman.)
If the php.ini file has the correct extensions declared, but you still get the error, try the composer flag --ignore-platform-req=. In your case, probalby something like:
composer create-project nette/sandbox TaskManager --ignore-platform-req=ext-iconv
Additionally, make sure you never run composer as root, but as web, then php
su httpd -c 'php composer create-project nette/sandbox TaskManager --ignore-platform-req=ext-iconv'
If php is executing the composer command, then Composer may have a better time looking at the more relevant php.ini file.
The tendency for false alarms is arguably one more reason to not use composer when creating your own projects for others.
Bear in mind, composer was created as a kind of "nanny" to automatically install dependencies... because web admins don't know how to read the docs and do that on their own, right? It is primarily useful for web developers who don't know web admin, or are denied root access by their employers or customers, but only work higher in the stack.
Because of Composer's purpose, it may trigger a lot of false warnings. This is probably why it has the --ignore-platform-req= flag. Don't be afraid to use this as it is one of composer's redeeming qualities.
I'm trying to install php's ssh2 extension, and having a little bit of difficulty. The file is there, it's just not loading into php.
First, I've installed ssh2 with:
aptitude install libssh2-1-dev libssh2-php
(For what it's worth, I'm running Ubuntu 12.04 on Nginx.)
I can see that ssh2 is loaded using the modules command:
php -m |grep ssh2
ssh2
However, when I run my code, I get an undefined function error.
In my phpinfo() script, I can see that my php installation scans this directory for additional ini files: /etc/php5/fpm/conf.d. Listing the contents of that directory, I can see that my ssh2.ini is there:
ls /etc/php5/fpm/conf.d
mysqli.ini mysql.ini pdo.ini pdo_mysql.ini ssh2.ini
According to phpinfo again, the other four ini files are loaded. SSH2 is not.
I've also tried placing "extension=ssh2.so" directly in my php.ini file - /etc/php5/fpm/php.ini. And yes - I've restarted my nginx server.
Am I missing something else?
Set display_startup_errors = On in you php.ini
Set error_log = '/var/log/php-error.log' in you php.ini
Create error log - touch /var/log/php-error.log
Now, you can restart php5-fpm daemon and lookup in error log any errors with ssh2 module
The answer from Aleksandr was helpful. I was attempting to install a PHP extension for a Plesk build. You need to make the modifications to the Plesk php.ini version that corresponds to the domain (which you can find in the web-based control panel under Tools and Settings). The error log will be located in /var/log/plesk-phpXX-fpm.
Do NOT uncomment the error_log (#2 / #3) as noted above otherwise you won't see the error show up in this location.
I'm trying to set up a cronjob which requires curl, and I'm calling it directly from crontab with
* * * * * /usr/bin/php myurl/my_cron.php
The problem is, it looks like the curl module isn't installed for my phpcli.
It works just fine when I hit the url from my browser, but when I run
php -q myfile.php
from the command line, it returns
PHP Fatal error: Call to undefined function curl_init() in my_cron.php on line 20
When I run php -m the curl module does not show up. However when I go to the browser and dump the php_info(), the module shows up and says its correctly installed.
The other kicker is i've been trying to install curl with apt-get onto the server (Ubuntu 12.04 php 5.4), it seems to take down my PHP as it begins to simply attempt to download the index.php file wherever I try to browse to.
Here are the attempts I've made to install curl that have taken down PHP:
sudo apt-get install php-curl
sudo apt-get install curl libcurl3 libcurl3-dev php5-curl
After each of these I restarted the apache2 server and still no dice, it attempted to download the file instead of opening the page.
How can I install php5-curl to just the cli, so that my server can run it and I don't have to go through a browser?
The other possibility is I could run the cronjobs through wget from the crontab file, but I've heard that's not the best option and potentially unreliable.
Any help is much appreciated. Thanks!
I had the same issue. But, finally I solved it by running the following command.
sudo apt-get install php7.0-curl
Restart the server after installing. This answer may not be useful for the user who asked because he asked it two months ago. But, this may be useful for the users who reading this in the future.
Here's how I've fixed this on ubuntu 14.04 when curl was working in php files run through apache, but not when called from the cli.
ssh to your server and cd to /
find / -name 'curl.so'
Run the above find command to locate where the curl binary is hanging out at. If you can't find the file, you might need to install curl and run the find command again.
apt-get install php5-curl
You'll now want to edit the php.ini being used for php files run from the cli (it's different than the one used by apache), and is likely at /etc/php5/cli/php.ini
nano /etc/php5/cli/php.ini
You can also run
php -i | grep 'php.ini'
To get the file path, just to be sure.
In your php.ini file search for [curl] by pressing ctrl + w
You'll now want to add the extension to the file and it should look something like the following, though your path to the curl.so file and such might be a little different:
[curl]
; A default value for the CURLOPT_CAINFO option. This is required to be an
; absolute path.
;curl.cainfo =
extension=/usr/lib/php5/20131226/curl.so
After doing the above, I was able to use curl in php scripts run from the cli.
first find the version of your php cli by:
php -v
for example if it was version 7 then:
sudo apt-cache search php7
this will give you the proper module names for your current version:
php7.0-curl - CURL module for PHP <---- the name of curl module.
php7.0-dev - Files for PHP7.0 module development
php7.0-gd - GD module for PHP
php7.0-gmp - GMP module for PHP
php7.0-json - JSON module for PHP
php7.0-ldap - LDAP module for PHP
php7.0-mysql - MySQL module for PHP
.
.
so on
so to add curl support, copy the name of curl module from the list above then do the following:
sudo apt-get install php7.0-curl
If you are using the command-line interface ('cli') for php5, instead of
php -q myfile.php
please use:
php5 -q myfile.php
php5-curl seems to enable the curl module for the cli php5 and not php and both (can) load different configurations and modules.
I use ubuntu 14.04 and php 5.3. After upgrading to php 5.6.29 I also has problem with php curl. My directory structure after updating to php 5.6.29:
/etc/php5 - old version (5.3)
/etc/php/5.6 - new version
The next command
sudo apt-get install php5-curl
didn't help (looks like it connects to old php version - 5.3).
I have found next article: php 5.6 for magento
It advice to use command
apt-get -y install php5.6-curl
instead of
apt-get -y install php5-curl
It works for me!
The first thing you should always check is your php.ini file. You should have a php.ini file in your web root. Curl is installed by default on most web servers; I haven't found a web server with PHP that hasn't already had curl installed. Its not always enabled, though.
Check your your php.ini file and search for php_curl.dll, it should look like this:
;extension=php_curl.dll
Just remove the semicolon (;) from before "extension" and save the file. It should work right away. According to your phpinfo.php its already installed, so it likely just needs to be enabled.
A similar question can be found here if you're interested: Call to undefined function curl_init()
In case someone reached here to find windows version of running curl.
Open php.ini and remove the ; before extension=php_curl.dll around line 656.
I am pretty much sure what Apache loads is C:\wamp\bin\apache\Apache2.2.17\bin\php.ini therefore you may find curl working from browser.
But when php is run from command line then it may show unknown function curl_init();
Run php -r "echo php_ini_loaded_file();" in the command line to see which ini file is being loaded.
Usually its found inside C:\wamp\bin\php\php5.3.5\php.ini its a different file from what Apache is using. So open it and then remove the ; before extension=php_curl.dll around line 656.
Hope it helps someone.
After I tried for hours to find the good path for PHP-CLI, i finally found it. But my proud was soon gone again.
Still i got the following error:
The following requirements were not met. As a result video uploads have been disabled.
Unable to locate path to PHP-CLI
I have tried much different paths
bin/php
usr/local/lib
usr/local/lib/php
usr/local/bin/php (this is the good one I thought).
Still getting the same error as above. Whats happening? My server is not running in Safe Mode and my exec() are enabled via the php.ini file.
Please help me..
Edit:
Paul
Q: Have you tried any "fully qualified paths", e.g. "/bin/php" (not
just "bin/php")?
A: I have tried both solutions, no result.
Q: Are you sure php-cli is installed on your system (it's typically a
seperate package from the Apache PHP plug-in)? EXAMPLE: apt-get
install php5-common libapache2-mod-php5 php5-cli.
A: I tried this in the SSH of my server, its a CentOS server so he didn't found the comment
#Peter:
If you installed PHP through your OS package manager, the path would
probably be /usr/bin/php, which appears to be the only one you didn't
try
I tried that one now, i didn't help, still the same error:
Edit2
#Dev-null
You have found and what? Just knowing where >is located will not fix it, have you changed some >code or environment variable PATH to make it
A: its an input field where i need to put the path in. I haven't changed any code, because PHP version 5.3.17 (CLI) installed on my CentOS server. So no need to change some code just for the path, right?
Edit
My PHP info, PHP 5.3.17 (CLI) Check the image below..
Edit
When I do rpm -q php-cli I get PHP-CLI not installed and when I want to install i get No package php-cli available. See image below.
Edit
Result of /bin/php -v below.
CentOS ships the PHP command-line interpreter in the php-cli package. So you first need to verify whether it's installed or not:
rpm -q php-cli
If installed, you can list all its files:
rpm -ql php-cli
... and filter out potential binaries:
rpm -ql php-cli | grep /bin/
You can get further details in the Using RPM chapter of the deployment guide.
If the package is not installed:
yum install php-cli
More info at Installing New Software with yum.
All this answer assumes that nobody broke the package system by installing software manually. If that happened, there's no way to tell what changes were made to the system.
Edit #1: I've just seen your last edit where php-cli is up and running. Then, if you want to know the path you just need to type this:
which php
Edit #2: You seem to have up to 4 binaries called php in your path. I still think that the proper reliable way to find the php-cli binary is running rpm -ql php-cli but given that php finds it on the path I'm pretty sure that it's located at /bin/php and you can verify it by running:
/bin/php -v
Run that exact command—don't remove any slashes or append -cli.
If your script, whatever it looks like, cannot find it, it's either doing it wrong or it's missing the appropriate permissions.
try the following to find it:
sudo find / -name php-cli
You most likely want php instead of php-cli though.
None of the solutions on this page found the installed versions of PHP that were present in my own elusive search for php-cli. The solution for me was to use the following command:
locate bin/php
This listed all php versions and I could then replace php with, for example:
/usr/bin/php71-cli
To access the command line interface version of php rather than the default cgi one. I then alias my instructions like so:
alias composer='/usr/bin/php71-cli bin/composer.phar'
I installed "drush" for my drupal website.
when I tried to run "drush":
[root#server /]# drush
/usr/share/drush/drush.launcher: line 132: /usr/bin/php-cli: No such file or directory
[root#server /]#
php-cli was not in my default directory /usr/bin
Solution was to copy my "php"-file to "php-cli" file (no rename!!, just copy)
[root#server /]# cp php php-cli
weird, but still working!