I'm getting a PHP Fatal error:
Call to undefined function curl_init() error while testing some PHP code on my server.
I assumed Curl needed to be installed so i found the PHP version first:
php --version
PHP 5.6.11-1ubuntu3.4 (cli)
I proceeded to install the package:
sudo apt-get install php5-curl
Reading package lists... Done
Building dependency tree
Reading state information... Done
E: Unable to locate package php5-curl
I then tried:
sudo apt install php-curl
and it appeared to install but I saw references to PHP 7 and it completed successfully.
Yet, the problem persists.
How do I get curl running to stop the init() error?
UPDATE: When I run this I get:
sudo apt-get install curl
Reading package lists... Done
Building dependency tree
Reading state information... Done
curl is already the newest version (7.47.0-1ubuntu2.13).
0 upgraded, 0 newly installed, 0 to remove and 172 not upgraded.
You are using Ubuntu#16.04. 16.04 does not ship with php#5 but with php#7.
If you need your older version of php and its dependencies, you have to install it differently.
There is a trustworthy (note: any external repository may still be a security thread) repository maintained by ondrej, namely:
ondrej/php
I have build a Dockerfile using 16.04 to showcase how you could install php#5.6 and php5.6-curl:
FROM ubuntu:16.04
ARG DEBIAN_FRONTEND=noninteractive
RUN apt-get -qq update && \
apt-get -qq install software-properties-common > /dev/null && \
LC_ALL=C.UTF-8 add-apt-repository ppa:ondrej/php -y > /dev/null && \
apt-get -qq update && apt-get -qq install php5.6 php5.6-curl > /dev/null
RUN php -v && php -m | grep curl
This Dockerfile is not ideal, yet the last run prints:
PHP 5.6.40-8+ubuntu16.04.1+deb.sury.org+1 (cli)
Copyright (c) 1997-2016 The PHP Group
Zend Engine v2.6.0, Copyright (c) 1998-2016 Zend Technologies
with Zend OPcache v7.0.6-dev, Copyright (c) 1999-2016, by Zend Technologies
curl
showing that it has php#5.6 and php-curl#5.6 installed.
Try:
First Install CURL by typing sudo apt-get install curl.
Then Restart Apache by typing sudo service apache2 restart.
Install PHP5 CURL sudo apt-get install php5-curl.
Restart Apache by typing sudo service apache2.
Related
I have been trying to install laravel for 3 days on ubuntu 16.04. I am following the top search links of laravel installation process. But I failed to execute each and every process I had tried. Now I am facing a different issue on installing PHP on my ubuntu. I had installed maria db once, but did not succeed.
But it might have broken something that resulted in me not being able to install PHP. The issue I am facing:
Reading package lists... Done
Building dependency tree
Reading state information... Done
php is already the newest version (1:7.2+62+ubuntu16.04.1+deb.sury.org+3).
You might want to run 'apt-get -f install' to correct these:
The following packages have unmet dependencies:
mysql-server : Depends: mysql-server-5.7 but it is not going to be installed
E: Unmet dependencies. Try 'apt-get -f install' with no packages (or specify a solution).
When I try php -v it gives me this error
PHP Warning: PHP Startup: Unable to load dynamic library '/usr/lib/php/20170718/mcrypt.so' (tried: /usr/lib/php/20170718/mcrypt.so (/usr/lib/php/20170718/mcrypt.so: cannot open shared object file: No such file or directory), /usr/lib/php/20170718//usr/lib/php/20170718/mcrypt.so.so (/usr/lib/php/20170718//usr/lib/php/20170718/mcrypt.so.so: cannot open shared object file: No such file or directory)) in Unknown on line 0
PHP 7.2.9-1+ubuntu16.04.1+deb.sury.org+1 (cli) (built: Aug 19 2018 07:16:12) ( NTS )
Copyright (c) 1997-2018 The PHP Group
Zend Engine v3.2.0, Copyright (c) 1998-2018 Zend Technologies
with Zend OPcache v7.2.9-1+ubuntu16.04.1+deb.sury.org+1, Copyright (c) 1999-2018, by Zend Technologies
I am totally new on ubuntu and laravel. And if anyone guide me how to install laravel on ubuntu 16.04 I will be very grateful.
Thank You.
Install git apt-get install git-core
git clone https://github.com/thamaraiselvam/LEMP-Stack-Installer.git
cd quick-lemp-install or cd LEMP-Stack-Installer
chmod +x lemp.sh this command makes bash script executable
./lemp.sh
That's it :)
PHP version - v7.0
Mysql version - Latest Stable
Note: Default mysql password is root. you can change it before running
in the following lines before running the script
sudo debconf-set-selections <<< 'mysql-server
mysql-server/root_password password YOUR_PASSWORD'
sudo debconf-set-selections <<< 'mysql-server
mysql-server/root_password_again password YOUR_PASSWORD'
Now Install Laravel
Go to cd /var/www/html/
sudo apt-get install php-common php-mbstring php-xml php-zip
composer create-project --prefer-dist laravel/laravel blog "5.5.*"
Try to execute the following commands to solve your problem:
Get the list of MySQL packages installed on the system by executing
the command sudo dpkg -l | grep mysql
Remove the the packages shown above by executing the command sudo apt-get --purge autoremove <packages from the step 1>
Delete /var/lib/mysql
Try to install mysql again. It should solve your problem
I installed a new local server, when I installed php5 package with apt-get install php5 it got the version 5.6.
My production server is still with php 5.5 and I would like to upgrade it to php 5.6 like in my dev environment.
Can I do it easily using apt-get ? tell to apt-get to switch to the branch 5.6 ?
Thx
Enter the following commands in the order shown:
apt-get -y update
add-apt-repository ppa:ondrej/php
apt-get -y update
apt-get -y install php5.6 php5.6-mcrypt php5.6-mbstring php5.6-curl php5.6-cli php5.6-mysql php5.6-gd php5.6-intl php5.6-xsl
Enter the following command to verify PHP 5.6 installed properly:
php -v
Following is a sample response that indicates PHP 5.6 is installed:
PHP 5.6.22-4+deb.sury.org~trusty+1 (cli)
Copyright (c) 1997-2016 The PHP Group
Zend Engine v2.6.0, Copyright (c) 1998-2016 Zend Technologies
with Zend OPcache v7.0.6-dev, Copyright (c) 1999-2016, by Zend Technologies
Done+
To upgrade to a newer version of PHP 5.6 on Ubuntu 14.04, you can use Ondřej Surý's PPA. He is one of the Debian maintainers of the php5 package. To add the PPA and upgrade your packages, run:
sudo apt-get install software-properties-common
sudo add-apt-repository ppa:ondrej/php5-5.6
sudo apt-get update
sudo apt-get upgrade
sudo apt-get install php5
For PHP 5.6
sudo add-apt-repository ppa:ondrej/php5-5.6
For PHP 5.5
sudo add-apt-repository ppa:ondrej/php5
Reference
I know that it's a little late to answer this question , but for anyone like me who is confused when upgrading php , I should say please note that before installing new version of php remove it completely from your system, even remove config files and extensions, It caused me so many errors and problems.
sudo apt-get purge php.*
sudo rm -rf /etc/php5
sudo apt-get install software-properties-common
sudo add-apt-repository ppa:ondrej/php5-5.6
sudo apt-get update
sudo apt-get upgrade
sudo apt-get install php5
I'm trying to install php 5.6 on Amazon linux using the following command:
$ yum install php56
No package php56 available.
Error: Nothing to do
Is there a repository I need to add in order to do this? I've searched for this but couldn't find any source. I'd also like to know which Apache versions work with this version of php?
Below are the steps I have used to update PHP version from 5.3 to 5.6 in Amazon Linux
Steps (Use sudo only if required)
1) Remove OLD Apache
sudo service httpd stop
sudo yum erase httpd httpd-tools apr apr-util
2) Remove OLD PHP
sudo yum remove php-*
3) Install PHP 5.6 (Apache 2.4 will be automatically installed with this)
sudo yum install php56
4) Make sure all the required PHP extensions are installed
yum list installed | grep php
5) If not then install them using
sudo yum install php56-xml php56-xmlrpc php56-soap php56-gd
6) To list the other available php extensions
yum search php56
7) PHP 5.6 MySQL extension (Assume you have already installed MySQL)
sudo yum install php56-mysqlnd
(NOTE: it is not php56-mysql)
8) Start / Restart Apache
sudo service httpd start
sudo service httpd restart
9) Check the version
php -v
httpd -v
AWS has not yet packaged php 5.6. You need to install php 5.5 from the ALAMI repositories, or build 5.6 from source.
To list the available 5.5 packages use yum search php55
The php55 is the base package, but you may need others listed as well.
When 5.6 is ready, you'll be able to find it with
yum search php56
You can find information on building the source at php.net, specifically Installation on Unix Systems / Apache 2.x on Unix Systems
Just to mantain update the answers,
I tryed the proposed solution and didn't work.
Quite hard to install 5.6
I found the right command nowaday to install 7.2 is
amazon-linux-extras install php7.2
it install and upgrade everything without complications.
Try this:
sudo yum -y update
sudo yum install –y https://dl.fedoraproject.org/pub/epel/epel-release-latest-7.noarch.rpm
sudo wget https://dl.fedoraproject.org/pub/epel/epel-release-latest-7.noarch.rpm
sudo wget https://centos7.iuscommunity.org/ius-release.rpm
sudo rpm -Uvh ius-release*.rpm
sudo yum -y update
When you install the package you'll need to add a u to the end of php56. Here is an example of some packages you could install.
sudo yum -y install php56u php56u-opcache php56u-xml \
php56u-mcrypt php56u-gd php56u-devel php56u-mysql \
php56u-intl php56u-mbstring php56u-bcmath php56u-soap
Successfully installed php56 and required php-module on amazonlinux2 with the repo epo.ius.io.
sudo yum -y update
sudo yum install –y https://dl.fedoraproject.org/pub/epel/epel-release-latest-7.noarch.rpm
wget https://repo.ius.io/ius-release-el7.rpm
sudo rpm -Uvh ius-release*.rpm
sudo yum -y update
sudo yum install --enablerepo=ius-archive php56u php56u-opcache php56u-xml php56u-mcrypt php56u-gd php56u-devel php56u-mysql php56u-intl php56u-mbstring php56u-bcmath php56u-soap
Check PHP version with below command
[root#ip-10-10-1-47 ~]# php -v
PHP 5.6.40 (cli) (built: Jan 11 2019 10:27:04)
Copyright (c) 1997-2016 The PHP Group
Zend Engine v2.6.0, Copyright (c) 1998-2016 Zend Technologies
with Zend OPcache v7.0.6-dev, Copyright (c) 1999-2016, by Zend Technologies
To install php module
yum install --enablerepo=ius-archive php56u-{Module Name}
Validate the module name
php -m
php -m | grep {Module Name}
example to check php yaml module
php -m | grep yaml
Reference URL : https://forums.aws.amazon.com/thread.jspa?threadID=284157
Additional part from #Daniele post for resloving this problem.
This is more help than question, but to help other with problem which I had in my case. I need to install Wordpress site on EC2, but when I tried to run it with public IP address, it was problem. I tried to install php 5.6, but it was not possible.
I find solution to install php 7.2, using command:
**amazon-linux-extras install php7.2**
TO check that is really version php 7.2, use:
php -version or php -v
After this, you need to stop apache service, command for stop is:
service httpd stop
Start again apache service:
service httpd start
In your AWS console, go to Instance, find public IP address, copy and open in browser. You should see the WordPress page. You can install WordPress in Advanced part (bootstraping), when you create EC2 instance.
I'm trying to update my PHP (currently v:5.3.3 to the latest stable PHP build) but it's not playing ball and it's saying there is nothing to update.
Any help would be useful.
Keeps saying:
No Packages marked for Update
As Jacob mentioned, the CentOS packages repo appears to only have PHP 5.3 available at the moment. But these commands seemed to work for me...
rpm -Uvh http://mirror.webtatic.com/yum/el6/latest.rpm
yum remove php-common # Need to remove this, otherwise it conflicts
yum install php56w
yum install php56w-mysql
yum install php56w-common
yum install php56w-pdo
yum install php56w-opcache
php --version # Verify version has been upgraded
You can alternatively use php54w or php55w if required.
CAUTION!
This may potentially break your website if it doesn't fully resolve all your dependencies, so you may need a couple of extra packages in some cases. See here for a list of other PHP 5.6 modules that are available.
If you encounter a problem and need to reset back to the default, you can use these commands:
sudo yum remove php56w
sudo yum remove php56w-common
sudo yum install php-common
sudo yum install php-mysql
sudo yum install php
(Thanks Fabrizio Bartolomucci)
For CentOS 6, PHP 5.3.3 is the latest version of PHP available through the official CentOS package repository. Keep in mind, even though PHP 5.3.3 was released July 22, 2010, the official CentOS 6 PHP package was updated November 24, 2013. Why? Critical bug fixes are backported. See this question for more information: "Why are outdated packages installed by yum on CentOS? (specifically PHP 5.1) How to fix?"
If you'd like to use a more recent version of PHP, Les RPM de Remi offers CentOS PHP packages via a repository that you can add to the yum package manager. To add it as a yum repository, follow the site's instructions.
Note: Questions of this variety are probably better suited for Server Fault.
I managed to install php54w according to Simon's suggestion, but then my sites stopped working perhaps because of an incompatibility with php-mysql or some other module. Even frantically restoring the old situation was not amusing: for anyone in my own situation the sequence is:
sudo yum remove php54w
sudo yum remove php54w-common
sudo yum install php-common
sudo yum install php-mysql
sudo yum install php
It would be nice if someone submitted the full procedure to update all the php packet. That was my production server and my heart is still rapidly beating.
This is the easiest way that worked for me: To install PHP 5.6 on CentOS 6 or 7:
CentOS 6. Enter the following commands in the order shown:
yum -y update
yum -y install epel-release
wget https://dl.fedoraproject.org/pub/epel/epel-release-latest-6.noarch.rpm
wget https://centos6.iuscommunity.org/ius-release.rpm
rpm -Uvh ius-release*.rpm
yum -y update
yum -y install php56u php56u-opcache php56u-xml php56u-mcrypt php56u-gd php56u-devel php56u-mysql php56u-intl php56u-mbstring php56u-bcmath
CentOS 7. Enter the following commands in the order shown:
yum -y update
yum -y install epel-release
wget https://dl.fedoraproject.org/pub/epel/epel-release-latest-7.noarch.rpm
wget https://centos7.iuscommunity.org/ius-release.rpm
rpm -Uvh ius-release*.rpm
yum -y update
yum -y install php56u php56u-opcache php56u-xml php56u-mcrypt php56u-gd php56u-devel php56u-mysql php56u-intl php56u-mbstring php56u-bcmath
Sorry - I'm unable to post the source URL - due to reputation
Verify current version of PHP
Type in the following to see the current PHP version:
php -v
Should output something like:
PHP 5.3.3 (cli) (built: Jul 9 2015 17:39:00)
Copyright (c) 1997-2010 The PHP Group
Zend Engine v2.3.0, Copyright (c) 1998-2010 Zend Technologies
Install the Remi and EPEL RPM repositories
If you haven’t already done so, install the Remi and EPEL repositories
wget https://dl.fedoraproject.org/pub/epel/epel-release-latest-6.noarch.rpm && rpm -Uvh epel-release-latest-6.noarch.rpm
wget http://rpms.famillecollet.com/enterprise/remi-release-6.rpm && rpm -Uvh remi-release-6*.rpm
Enable the REMI repository globally:
nano /etc/yum.repos.d/remi.repo
Under the section that looks like [remi] make the following changes:
[remi]
name=Remi's RPM repository for Enterprise Linux 6 - $basearch
#baseurl=http://rpms.remirepo.net/enterprise/6/remi/$basearch/
mirrorlist=http://rpms.remirepo.net/enterprise/6/remi/mirror
enabled=1
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-remi
Also, under the section that looks like [remi-php55] make the following changes:
[remi-php56]
name=Remi's PHP 5.6 RPM repository for Enterprise Linux 6 - $basearch
#baseurl=http://rpms.remirepo.net/enterprise/6/php56/$basearch/
mirrorlist=http://rpms.remirepo.net/enterprise/6/php56/mirror
# WARNING: If you enable this repository, you must also enable "remi"
enabled=1
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-remi
Type CTRL-O to save and CTRL-X to close the editor
Upgrade PHP 5.3 to PHP 5.6
Now we can upgrade PHP. Simply type in the following command:
yum -y upgrade php*
Once the update has completed, let’s verify that you have PHP 5.6 installed:
php -v
Should see output similar to the following:
PHP 5.6.14 (cli) (built: Sep 30 2015 14:07:43)
Copyright (c) 1997-2015 The PHP Group
Zend Engine v2.6.0, Copyright (c) 1998-2015 Zend Technologies
Steps for upgrading to PHP7 on CentOS 6 system. Taken from install-php-7-in-centos-6
To install latest PHP 7, you need to add EPEL and Remi repository to your CentOS 6 system
yum install https://dl.fedoraproject.org/pub/epel/epel-release-latest-6.noarch.rpm
yum install http://rpms.remirepo.net/enterprise/remi-release-6.rpm
Now install yum-utils, a group of useful tools that enhance yum’s default package management features
yum install yum-utils
In this step, you need to enable Remi repository using yum-config-manager utility, as the default repository for installing PHP.
yum-config-manager --enable remi-php70
If you want to install PHP 7.1 or PHP 7.2 on CentOS 6, just enable it as shown.
yum-config-manager --enable remi-php71
yum-config-manager --enable remi-php72
Then finally install PHP 7 on CentOS 6 with all necessary PHP modules using the following command.
yum install php php-mcrypt php-cli php-gd php-curl php-mysql php-ldap php-zip php-fileinfo
Double check the installed version of PHP on your system as follows.
php -V
IUS offers an installation script for subscribing to their repository and importing associated GPG keys. Make sure you’re in your home directory, and retrieve the script using curl:
curl 'https://setup.ius.io/' -o setup-ius.sh
sudo bash setup-ius.sh
Install Required Packages-:
sudo yum install -y mod_php70u php70u-cli php70u-mysqlnd php70u-json php70u-gd php70u-dom php70u-simplexml php70u-mcrypt php70u-intl
How do I install the bcmath module on a server? I tried
yum update php-bcmath
but it said it found nothing.
Try yum install php-bcmath.
If you still can't find anything, try yum search bcmath to find the package name
ubuntu and php7.1
sudo apt install php7.1-bcmath
ubuntu and php without version specification
sudo apt install php-bcmath
yum install php72-php-bcmath.x86_64
cp /etc/opt/remi/php72/php.d/20-bcmath.ini /etc/php.d/
cp /opt/remi/php72/root/usr/lib64/php/modules/bcmath.so /usr/lib64/php/modules/
systemctl restart httpd
Not sure why I had to go so deep considering the yum install gave me bcmath in phpinfo()
Worked great on CentOS 6.5
yum install bcmath
All my calls to bcmath functions started working right after an apache restart
service httpd restart
Sweet!
When using the official PHP images of Docker, use docker-php-ext-install bcmath.
Source: https://hub.docker.com/_/php?tab=description#php-core-extensions
Was getting call to undefined function bcmod()
yum install php-bcmath
systemctl restart httpd.service
you should then see something similar to /etc/php.d/bcmath.ini listed under phpinfo.
Centos 7
Plesk 12
PHP 5.4.16
If you have installed php 7.1
then this line work on your system.
sudo apt install php7.1-bcmath
check your php version in your system on ubuntu 16.04
php -v
and then result show there..
PHP 7.1.x+ubuntu16.04.1+deb.sury.org+1 (cli) (built: Aug 19 2018
07:16:12) ( NTS ) Copyright (c) 1997-2018 The PHP Group Zend Engine
v3.2.0, Copyright (c) 1998-2018 Zend Technologies
with Zend OPcache v7.2.9-1+ubuntu16.04.1+deb.sury.org+1, Copyright (c) 1999-2018, by Zend Technologies
The following worked for me on Centos 7.4 with PHP 7.1 using remi repository.
First find out which PHP version I have:
[kiat#reporting ~]$ php --version
PHP 7.1.33 (cli) (built: Oct 23 2019 07:28:45) ( NTS )
Copyright (c) 1997-2018 The PHP Group
Zend Engine v3.1.0, Copyright (c) 1998-2018 Zend Technologies
with Zend OPcache v7.1.33, Copyright (c) 1999-2018, by Zend Technologies
Then search for bcmath extension in remi-php71 repository:
[kiat#reporting ~]$ yum search php71 | grep bcmath
php71-php-bcmath.x86_64 : A module for PHP applications for using the bcmath
php71u-bcmath.x86_64 : A module for PHP applications for using the bcmath
Now install the first matching extension:
[kiat#reporting ~]$ sudo yum --enablerepo=remi-php71 install php-bcmath
Loaded plugins: fastestmirror, langpacks
base | 3.6 kB 00:00
.
.
.
Finally, restart php and nginx:
[kiat#reporting ~]$ sudo systemctl restart php-fpm nginx
I found that the repo that had the package was not enabled. On OEL7,
$ vi /etc/yum.repos.d/ULN-Base.repo
Set enabled to 1 for ol7_optional_latest
$ yum install php-bcmath
and that worked...
I used the following command to find where the package was
$ yum --noplugins --showduplicates --enablerepo \* --disablerepo \*-source --disablerepo C5.\*,c5-media,\*debug\*,\*-source list \*bcmath
If you want to enable any extension then you have to install an extension first, extension maybe enabled but not installed, so taking the example of bcmath
yum search php-bcmath
Then ensure the php version in which u want to install this extension
You will get output like after yum search command>>
yum search php-bcmath**
Loaded plugins: fastestmirror, universal-hooks
Loading mirror speeds from cached hostfile
EA4: 66.71.244.18
cpanel-addons-production-feed: 66.71.244.18
base: mirror.nodesdirect.com
epel: mirror.coastal.edu
extras: www.gtlib.gatech.edu
nux-dextop: mirror.li.nux.ro
updates: mirror.jaleco.com
**============================================================== N/S matched: php-bcmath ===============================================================
ea-php54-php-bcmath.x86_64 : A module for PHP applications for using the bcmath library
ea-php55-php-bcmath.x86_64 : A module for PHP applications for using the bcmath library
ea-php56-php-bcmath.x86_64 : A module for PHP applications for using the bcmath library
ea-php70-php-bcmath.x86_64 : A module for PHP applications for using the bcmath library
ea-php71-php-bcmath.x86_64 : A module for PHP applications for using the bcmath library
ea-php72-php-bcmath.x86_64 : A module for PHP applications for using the bcmath library
If I wanna install for php71 then the command will be like yum install ea-php71-php-bcmath.x86_64 or yum install php71-bcmath.
You can install any extension from the above steps.
In Ubuntu PHP 7.3
sudo apt install php7.3-bcmath
To enable bcmath in Arch Linux or Manjaro
Edit php.ini
nano /etc/php/php.ini
Uncomment bcmath (remove semicolon)
extension=bcmath
If you are using Apache server reload the server by
sudo systemctl reload apache.server
Or
sudo systemctl realod httpd
If you don't use Apache
sudo systemctl reload php-fpm.service
To see the activated modules
php -m
To make sure the bcmath is installed and activated, search for it
php -m | grep bcmath
This worked for me install php72-php-bcmath.x86_64
Then,
systemctl restart php72-php-fpm.service
For PHP 7+ version you can use only:
sudo apt install php-bcmath
I just tried below package for php v5.6 and it worked for me.
yum install php56w-bcmath
apt repo have this extension, just run the below command from your terminal ::
sudo apt-get install php7.2-bcmath*
If still anyone is not getting how to install bcmath as it has lots of other dependant modules to install like php7.2-common, etc.
Try using synaptic application, to install the same. fire command.\
sudo apt-get install synaptic
Open the synaptic application and then click on search tab.
search for bcmath
search results will show all the packages depends on php.
Install as per your convenience.
and install with all auto populated dependancies it required to install.
That's it.
For Centos 7 with php7.0
Install CentOS SCLo RH repository: yum install centos-release-scl-rh
Install rh-php71-php-bcmath rpm package: yum install rh-php71-php-bcmath
systemctl restart httpd.service
If you want to install PHP extensions in ubuntu.
first know which PHP version is active.
php -v
After that install needed plugin using this command.
sudo apt install php7.0-bcmath
you can replace php7.0-bcmath to php-PHPVersion-extensionName