I need to add curl to my PHP, I read multiple articles which recommended just sudo apt-get install php5-curl
But when I try it I get error as below
Error:
The following packages have unmet dependencies:
dropbox : Depends: python-gtk2 (>= 2.12) but it is not going to be
installed
php5-curl : Depends: php5-common (= 5.4.45-1~dotdeb+6.1) but
5.4.31-1~dotdeb.0 is to be installed
So I go a bit deeper and try to install it manualy, so I basicly download curl from curl website with: wget http://curl.haxx.se/download/curl-7.36.0.tar.gz
and then just unpack it and just ./configure and sudo make and after that sudo make install
Dispite the fact i didnt get any error It also didnt help.
From error I see that I have older version of my PHP than one in repository but I really have no clue what I can do now.
Is here anyone who can help me?
If you're stuck with that version of PHP, you can build the cURL extension yourself and then activate it with PHP. Normally, cURL is compiled into the PHP binary but you can also run it as a dynamic extension.
When you downloaded, compiled, and installed cURL, this installed the curl program and libraries but has nothing to do with PHP.
You can follow these steps to build a cURL PHP extension for your system:
Go to http://php.net/releases and download the source code for the version of PHP you are currently running
Extract to a temporary location
From the command line, cd to php-5.x.x/ext/curl
Run the following commands:
phpize
./configure --with-curl=/usr/local (/usr/local should be correct, but you can try leaving it blank, or specify the --prefix you used when you installed cURL.
make && make install
After make install runs, it should say something like:
Installing shared extensions: /usr/lib/php5/20121212/
This is where it will place curl.so
Now, edit your php.ini file that PHP uses and add:
extension=curl.so
Restart your webserver &/or PHP, check that cURL is loaded.
Note: If you don't have the phpize (it should have come with PHP) you might need to just build PHP to a temporary location and copy phpize to /usr/bin so you have it.
Hope that helps.
You need to update your PHP version and then install curl.
Do apt-get update to get the latest definitions, then apt-get upgrade to upgrade all packages, then apt-get install php5-curl.
Related
Trying to install ssh2 onto a litespeed server and using the traditional install methods are not working for me. I have successfully installed ssh2 into the /etc/php/cli and it works from the command line. However my litespeed server is using the php.ini from the directory /usr/local/lsws/lsphp74/etc/7.4/litespeed/php.ini. I confirmed that by running phpinfo() from the browser and looking at the Loaded Configuration File entry which shows /usr/local/lsws/lsphp74/etc/php/7.4/litespeed/php.ini. No matter what I try and what examples or steps provided to me, I cannot get it to install in an area that I can use via the browser. I do see this line "/usr/local/lsws/lsphp74/etc/php/7.4/mods-available/50-ssh2.ini," in the Additional .ini files parsed section of the phpinfo() page however no matter what I have tried, I cannot get it so show up like its installed when I view the phpinfo() page.
This works for LSPHP81 with SSH2, feel free to replace the PHP version with your current version.
1 - Install necessary PHP packages and ssh2 lib
apt-get update
apt-get install lsphp81-pear lsphp81-dev -y
apt-get install libssh2-1 libssh2-1-dev -y
2 - Download SSH2 package from pecl
wget https://pecl.php.net/get/ssh2-1.3.1.tgz
tar -zxvf ssh2-1.3.1.tgz
cd ssh2-1.3.1
3 - Compile ssh2 package
/usr/local/lsws/lsphp81/bin/phpize
./configure --with-ssh2=/usr/local/lsws/lsphp81 --with-php-config=/usr/local/lsws/lsphp81/bin/php-config
make
make install
echo "extension=ssh2.so" >> /usr/local/lsws/lsphp81/etc/php/8.1/mods-available/ssh2.ini
4 - Reload lsws and PHP
systemctl restart lsws
killall lsphp
5 - Result
Can anyone help me install php-redis in MAC OSX .
brew install php-redis
not working.
pecl install php-redis
also not working getting -
invalid package name/package file "php-redis".
Homebrew Error:
homebrew_error
git clone https://www.github.com/phpredis/phpredis.git
cd phpredis
phpize && ./configure && make && sudo make install
Add extension=redis.so in your php.ini
brew services restart php#7.2
make test
You can check working or not
php -r "if (new Redis() == true){ echo \"\r\n OK \r\n\"; }"
As of 2019, with homebrew php7.2 and up, pecl is now installed by default alongside the php binaries.
To see this for yourself type which pecl.
Steps to install
Check your version of redis, then find a suitable version of the extension here.
If unfamiliar with pecl, type pecl to see the options.
Issue pecl install redis-5.0.2. (or your version). Enter no to each question asked if you're not sure.
If that succeeds check the new file it created at: /usr/local/lib/php/pecl/20180731/redis.so
The install will have added extension="redis.so" to top of your php ini.
Check that by opening the file /usr/local/etc/php/7.3/php.ini.
(assuming you're on 7.3 there)
brew services restart php.
php -i | grep Redis
Redis Support => enabled
Redis Version => 5.0.2
This is what I just did in September 2019 and it works for me.
If what mwal wrote above doesn't work (please try his/her answer first),
first, try to uninstall first (if you have it but broken):
sudo pecl uninstall redis
and after that run:
sudo pecl install redis
After that, ini the php.ini, use full path for the extension.
Mine was /usr/local/Cellar/php#7.3/7.3.21/pecl/20180731/redis.so (assuming you are using php#7.3)
so at the top of my php.ini file is like this:
extension="/usr/local/Cellar/php#7.3/7.3.21/pecl/20180731/redis.so"
Here are steps to use pickle, for PHP >= 7.3 (tested with 8.1):
brew install pickle
pickle install redis
Find your php.ini location via php -i|grep php.ini
Edit the php.ini, insert extension=redis. Preferable at Dynamic Extensions section.
No restart of Apache httpd service is required. You may test your PHP code with Redis
Bonus
If you use VS Code, to enable intellisense / auto complete, at Preference -> paste intelephense.stubs at Search setting box -> Add Item -> select redis.
If you got the following error,
Please make sure the PHP Redis extension is installed and enabled
despite doing everything in the verified answer above, try valet restart . It worked for me
I have tried all these solutions but didn't work for me for a while so I tried this link https://developer.redis.com/develop/php/ from the original docs and it works as charm
If someone gets an error during sudo pecl install redis
Warning: mkdir(): File exists in System.php on line 294
PHP Warning: mkdir(): File exists in /opt/homebrew/Cellar/-----/pear/System.php on line 294
that means you need to create the broken directory manually.
Try to create the directory...
pecl config-get ext_dir | pbcopy
mkdir -p {paste clipboard value}
# in my case, it was
mkdir -p /opt/homebrew/lib/php/pecl/20200930
Now try to install any pecl extensions.
sudo pecl install redis
After installing any extension, restart php
brew services restart php
Happy coding :)
I have a server which has PHP5 installed. I need pthreads and found that link to install php5 with pthreads:
PHP5 installation with pthreads
I install all the packages I need with apt-get install. I have no idea about what a make file is, how to compile a source code etc. I am a web developer with limited OS knowledge.
I have followed the steps given in the link above. At the last command on step 4, I get an error because /opt/php-zts/modules.d/ does not exist.
I simply wanted to replace existing php with a new php installation that supports pthreads. Now, the server code does not work.
How can I install PHP5 with pthreads enabled so that it will replace existing PHP5 installation that I installed with sudo apt-get install php5 libapache2-mod-php5?
Also, I have another question. I need some other packages like php-curl. Can I install them with sudo apt-get install php-curl after I succesfully install PHP? Do these commands work with custom builds?
Edit: how-to-install-pthread-in-ubuntu-12-10 This is not a solution for my problem because I don't want an isolated installation. I want the installation to replace already existing php installation.
I have began installing pecl on MAMP. I have added the correct php version to the path and when which php it says /Applications/MAMP/... which is correct.
I have downloaded the Server Components and libraries moved them to a new folder in my php and run the ./configure everything seems to run ok and looked through all the checks being performed while installing and unpacking.
It gets to the last line and says;
configure: error: Please specify the install prefix of iconv with --with-iconv=<DIR>
Where should I set the <DIR> for the iconv?
Just make another folder and point it at that?
I am only trying to get the mongo pecl installed.
The information I have followed is here http://www.lullabot.com/blog/article/installing-php-pear-and-pecl-extensions-mamp-mac-os-x-107-lion
Wait wait wait wait. Why are you rebuilding your PHP installation to install the MongoDB driver?
You don't have to do that.
Just run e.g.:
/Applications/MAMP/bin/php/php7.1.1/bin/pecl install mongo
Assuming thats the full path to the pecl command part of your MAMP installation.
You might need to replace /php7.1.1/ with your current and active MAMP php version.
Working on this right now and found a workaround to just disable iconv with ./configure --without-iconv which not the best solution of course, but works for me.
Edit: Downloaded libiconv-1.14 package, and after running ./configure , make, make install, PHP configure runs fine.
This did it for me:
$ ./configure --with-iconv=/usr/lib/
First needed to install libxml2 and libxslt via homebrew though:
$ brew install libxml2
$ brew install libxslt
I installed apache and php from source and got them working together a month ago. Because I'm learning both of them this term.
Now I need mysql to do more works. And I installed mysql from source just now. However I don't know how to let it work with php.
I looked around and found some topics on setting up LAMP environment. Most of them install mysql first and use command options --with-mysql=/usr/local/mysql and --with-mysqli=/usr/local/mysql/bin/mysql_config when installing php. But in my case, I installed php first.
Is there any way to let php know that I have installed mysql? Or should I reinstall php ?
UPDATE
Finally I recompiled my php source with appending --with-mysql=/opt/mysql, --with-mysqli=/opt/mysql/bin/mysql_config and --with-pdo-mysql three configure options to let my php support the modules of mysql. Steps taken as follows:
1> stop apache and mysql services
2> backup php.ini
3> remove php
4> reconfigure php source
./configure --prefix=/opt/php --with-apxs2=/opt/apache/bin/apxs --with-mysql=/opt/mysql --with-mysqli=/opt/mysql/bin/mysql_config --with-pdo-mysql --...and other options
5> make and then make install
6> copy php.ini back and uncomment the corresponding directs on mysql modules
Why are you installing packages from source?
Use yum in CentOS and apt-get in Ubuntu like:
yum install php
yum install mysql
To make PHP work with MYSQL you have to install php-mysql extention like:
yum install php-mysql