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.
Related
I compiled PHP but there is no "extensions" folder. I do not see any configuration flags related to extensions. Is the extension folder manually added after or when I install an extension.
The following website had the modules I needed: https://pecl.php.net/
Specifically, apc.so, geoip.so, imagick.so and redis.so
On the OLD system I need to find which version was being used so I was able to install on the NEW system. The following showed me the version for imagick.
/usr/local/php54/bin/php --re imagick | head -1
Then I download the package to the new system using wget.
wget https://pecl.php.net/get/imagick-3.4.1.tgz
Uncompress...
tar zxvf imagick-3.4.1.tgz
CD to the directory
cd imagick-3.4.1
Run the following which gives the configure file.
/usr/local/php54/bin/phpize
Configure
configure --with-php-config=/usr/local/php54/bin/php-config
Followed by make, make test and make install.
After doing the make install you'll see something similar to the following.
Installing shared extensions: /usr/local/php54/lib/php/extensions/no-debug-non-zts-20100525/
Installing header files: /usr/local/php54/include/php/
The extensions directory is created for you.
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.
I'm using MAMP and ive installed a fresh version of Opencart, its telling me i dont have MCrypt enabled, when i go to terminal and type:
php -m | grep mcrypt
output: mcrypt
I can locate the library but it doesn't seem to be enabled.
That fact that php -m | grep mcrypt returns mcrypt, means the mcrypt library is INSTALLED and ENABLED.
Although it may just be enabled for CLI.
You can try editing the PHP.ini file and adding the following line under the ; Extensions section:
extension=mcrypt.so
Restart Apache / MAMP after saving php.ini file.
To find the correct php.ini file to edit, run the following command line:
php --info | grep php.ini
(If the line already exists, you may just need to remove the ; thats in front of it.)
I have tried so many ways but had no luck.
After a lot of trials finally came up with a solution.
Go to bin directory inside current active PHP version directory. In my case it is /Applications/MAMP/bin/php/php7.2.8/bin
It might be different in your case. Now run the below command with sudo
sudo ./pecl install channel://pecl.php.net/mcrypt-1.0.1
Now You should add extension=mcrypt.so to php.ini
Restart MAMP Service and check if it is working.
I had this issue following upgrading to MAMP 5.1 and using PHP 7.1.20...
The issue I found was not that MAMP PHP did not have mcrypt installed, it certainly does come bundled.
The issue was that the MAMP PHP configuration option "Make this version available on the command line" was NOT working and so the version of PHP I was using on the command line [in my case] was the macOS default PHP 7.1.16 without mcrypt (the version included in macOS by default)
Reverting to the old cli php alias meant the correct MAMP version of PHP was used on the command line
Added to .bash_profile
alias php='/Applications/MAMP/bin/php/php7.1.20/bin/php'
try in console
pecl install mcrypt
Using Brew:
Install mcrypt: brew install mcrypt
In Mamp: File -> Edit Template -> PHP (php.ini)-> {PHP version}
Find 'Dynamic Extensions' in the text and add the following below (after the lines starting with ';'):
extension=mcrypt.so
Save, restart and test (with php -i | grep mcrypt for example)
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!
I'm developing an application in PHP on a Linux server. The server has at least two different versions of php installed on it: 5.2.0 and 5.2.9.
The 5.2.0 version has the following directory /usr/local/lib/php in the include_path in php.ini.
I need to find out where the 5.2.9 version of this directory is located.
I checked the include_path setting in the 5.2.9 php.ini but it only has . and /usr/share/pear for include_path.
(Note that I just installed pear right now, since the 5.2.9 php was originally configured without pear.) The files in /usr/share/pear do not seem to match what I see in /usr/local/lib/php and it seems a little absurd to tell pear that php_dir is /usr/share/pear. Any ideas?
UPDATE - Is it possible that /usr/local/lib/php also belongs to php 5.2.9? Is there anything within this directory itself I can look at, to see?
If the directory you're looking for exists (it might not if you excluded pear during install): The default location would be /xxx/lib/php where /xxx is the installation prefix.
For example, on one of my servers, one of my PHP executables (I have 4 versions installed) is located /custom/php5.3.5/bin/php so it's corresponding PEAR/general library directory is /custom/php5.3.5/lib/php
(/custom/php5.3.5 being the installation prefix, normally it would be /usr/local or /usr.)
If your lib/php directory has a pearcmd.php file, call (yourphpbin) pearcmd.php info pear and it should be able to tell you pear version, it's requirements and whatnot. (If pearcmd.php exists, there's a good chance pear exists in that directory.) The pear shell-script would by default be at /xxx/bin/pear again /xxx being the installation prefix.
As far as I'm aware, you can set it up so that PEAR is shared among multiple versions of PHP. I would assume that's how the /usr/share/pear one is set up. (Distribution repository-provided?) Not sure if the same holds true for pecl. If you have multiple installs of pear, you just need to make sure you install the packages you want to use into the right pear install.
PHP will happily use whatever PEAR installation you tell it to in include_path.
Try the whereis command. It usualy gets you the binary, man page and configuration paths.
$ whereis php
You can then check the information each PHP version outputs:
$ /path/to/php.binary -i
There should be information about the included paths and configuration files used.
To find it, use:
]# sudo updatedb
]# locate php
That might return LOTS of results, you can filter in various ways. I usually try this first:
]# locate php | grep bin
You can try this command in the console:
which php