Cannot install PHP7 to AWS EC2 instance? - php

I have successfully installed apache 2.4.34 onto my instance but I am unable to install PHP7. I have tried the following:
sudo yum install php70
But I get the following error:
Loaded plugins: extras_suggestions, langpacks, priorities, update-motd
No package php70 available.
Error: Nothing to do

It could be possible that you are missing the right name. Check what php version is there with the command:
yum search php70
After that you should see a php version name. Copy and paste it to your command like:
yum install <php version name>
Make sure you put the whole php version name and don't forget to restart your apache!!!

apt-get update && apt-get upgrade
apt-get install software-properties-common
add-apt-repository ppa:ondrej/php
apt-get update
apt-get install php<Your desired version>
Confirm it installed by running:
php -V

Related

curl and mbstring php 7.1 installation on ubuntu 17.04

I'm using php7.1 on Ubuntu 17.04, I have tried to install cURL using this command:
sudo apt-get install php-curl
but I get this:
Package 'php-curl' has no installation candidate
I tried also to specify the cURL version using:
sudo apt-get install php7.1-curl
but i got
E: Couldn't find any package by regex 'php7.1-curl
So, please, how do I install curl for PHP 7.1?
You need to add PHP ppa first, update, and install
sudo add-apt-repository ppa:ondrej/php
sudo apt-get update
sudo apt install php7.1-curl
While it seems strange that you are not able to find php-curl, you should search for php curl package version available on your system:
sudo apt update
sudo apt search ^php
Between the results, it should display something like this (the output was taken from Ubuntu 17.10, yours will be different):
php7.1-curl/artful-updates,artful-security 7.1.15-0ubuntu0.17.10.1 amd64
CURL module for PHP
then, you just install it as usual:
sudo apt install php7.1-curl
happy coding!

Unable to locate package libapache2-mod-php7

I tried installing php in ubuntu 16.04 using following command:
sudo apt-get install php7.0-mysql php7.0-curl php7.0-json php7.0-cgi php7.0 libapache2-mod-php7
but it says
Unable to locate package libapache2-mod-php7
Should I skip this or install by an alternative way?
The name of the package is libapache2-mod-php7.0
Try again by having that .0 at the end and it should work.
On Ubuntu 18.04, I had to add the repository below first. Once the repo was added I was able to install the php7.x items.
sudo add-apt-repository ppa:ondrej/php
Source: https://websiteforstudents.com/apache2-with-php-7-1-support-on-ubuntu-18-04-lts-beta-server/
If you are using Ubuntu 17.04/17.10 or above use php7.1 instead of 7.0 since it is no longer available.
sudo apt-get install php7.1
At the time of the post Ubuntu 16.04 was one of the newer versions and as such the packages changed to php7.0 but as time goes on it will be 7.1 to 7.2 etc... and I don't have the time to figure out what was the latest package and I'm not dependent on a specific version.
So if you want the latest version of packages to install without having to know the correct version number just drop the version number and the latest applicable to the distribution you are using will be installed.
In my case I was using Ubuntu 17.10 and the php version is different so I used the following command line to get the latest.
sudo apt-get install apache2 php-mysql libapache2-mod-php mysql-server
It installed php 7.1 and all of the correct dependencies.
So if you don't require a specific version but just want the latest that works with the distribution drop the version number and use the command line above.
It is likely the case that your local package index is not updated; try
sudo apt-get update
and then run the previous command again.
As an aside, there is now a program apt that is supposedly more user-friendly than apt-get, apt-cache etc. (see this question on Ask Ubuntu). So your commands could have been replaced by
sudo apt update
sudo apt install <the packages>
to get a slightly nicer user interface.
Probably this question would have been better suited to the Ask Ubuntu community.
Apache server can't start because libapache2-mod-php7.0 is not installed:
by default aptitude or apt install php7.0-common version 7.8.13 which is not adaptable and libapache2-mod-php need 7.0.8
remove php-common
download http://packages.ubuntu.com/xenial/php7.0-common deb package and install it if it compains about php7.0-json, readline,cli,opache
then seatch in upper textbox about those library and install them in this manner
json
opach
cli
readline
install libapache2-mod-php7.0
RESTART APACHE 2
service apache2 restart
it must working probably
Good Luck!
Try for Ubuntu 16.04:
sudo apt-get update;
sudo apt-get install php7.0-fpm php7.0-mysql <other packages>;
for Ubuntu 14.04:
sudo apt-get update;
sudo apt-get install php5-mysql php5-mysql <other packages>;
It should be:
sudo apt-get install libapache2-mod-php7.0
sudo apt-get install libapache2-mod-php7.1
worked for me (16.04Ubuntu).
If you getting error like php7.2 php7.2-curl libapache2-mod-php doesn't have installable candidate or not locate any package or dependencies is php7.2-common Or libcurl3 Do this . Remeber Change your package name as per your requirements
You have to tackle in mature way. Install aptitude these ubuntu package manager will finds all dependencies, and will install one by one.
apt-get install aptitude
Now you have to check if aptitude can download it or not if download it follow instructions
sudo aptitude install php7.2-curl
If you have gotten any error like this
E: Unable to locate package php7.2-curl
E: Couldn't find any package by glob 'php7.2-curl'
Any type on error i'm not talking about proper these errors
Try to add php package again
sudo apt-add-repository ppa:ondrej/php
sudo apt-get update
Now try this command
sudo aptitude install php7.2-curl
Aptitude will ask you you want to keep current version of all dependencies
The following actions will resolve these dependencies:
Keep the following packages at their current version:
1) php7.2-curl [Not Installed]
Accept this solution? [Y/n/q/?]
Type n then Enter
Aptitude will find all dependencies and ask you to install all package type
y
Again
y
Then
systemctl restart apache2
For centos of rhel
systemctl restart httpd
It will Not enabling PHP 7.2 FPM by default.
NOTICE: To enable PHP 7.2 FPM in Apache2 do
a2enmod proxy_fcgi setenvif
a2enconf php7.2-fpm
This method is not only for this error you can find any of php apache2 or ubuntu system package solution using aptitude.
Upvote if you find your solution
Looks like we need to install the same version of libapache2-mod-php as the version of php present .I had php 7.4 installing libapache2-mod-php7.4 solved the problem.Thanks
just test upper versions of php
for example run:
sudo apt-get install php7.4-mysql php7.4-curl php7.4-json php7.4-cgi php7.0 libapache2-mod-php7.4

brew install homebrew/php/php56 giving me an error

Hi I am trying to install homebrew php56 on ubuntu 14.04
I installed php 5.6 and apache2 and other dependencies of installation like perl, curl , etc.
But still I am getting this error.
That's rather a freaky way — install something on Ubuntu Linux through homebrew — it's actually should not work.
You'd better use apt package manager. You can install php-5.6 binaries from PPA:
sudo apt-get update && sudo apt-get install python-software-properties
sudo add-apt-repository ppa:ondrej/php5-5.6
sudo apt-get update && sudo apt-get upgrade
sudo apt-get install php5

How to install/enable intl and xsl extensions after installing PHP 7

I installed php7/apache2.4/mysql5.6 via this script, but it turns out that the extensions xsl and intl are missing (need them to run Magento2).
I'm using Ubuntu 14.04.
If it is for dev purposes only, the easiest way would be use a PPA like ppa:ondrej/php-7.0 and then apt-get install php7.0-intl and apt-get install php7.0-xsl. PPAs should NEVER be used in production.
You can run sudo apt-get install php7.0-intl to get it installed.
You dont need PPA adding on 16.10 .
1st you need to add ppa repository to server
this can be done by :
sudo add-apt-repository ppa:ondrej/php
when PPA repo installed, update the local package cache by :
sudo apt-get update
after this you need to run following command to install intl & xsl extensions
sudo apt-get install php7.0-intl
sudo apt-get install php7.0-xsl
check the php extensions by :
php -m
if the extension does load on browser , than you need to check your php.ini for apache2
that can be found by calling <?php phpinfo();?> in info.php file

Installing PHP Zip Extension

I'm attempting to install the PHP Zip extension.
My server does not have external internet access, so I downloaded it myself from PECL: http://pecl.php.net/package/zip. I chose 1.10.2, the latest "stable" release, and transferred it to my server.
I ran:
pear install zip-1.10.2.tgz
and added
extension=zip.so
to php.ini as instructed. I can see that zip.so was created and placed in the right extension_dir folder as well. I restarted apache and then checked to see if it was loaded by running:
php -m
Despite all of this, "zip" is still not in that list.
Am I missing a step or doing something wrong? I thought this should be really simple, and I'm starting to feel pretty dumb, haha.
Other probably important stuff:
CentOS
Apache 2.2.3
PHP 5.2.16
This is how I installed it on my machine (ubuntu):
php 7:
sudo apt-get install php7.0-zip
php 5:
sudo apt-get install php5-zip
Edit:Make sure to restart your server afterwards.
sudo /etc/init.d/apache2 restart or sudo service nginx restart
PS: If you are using centOS, please check above cweiske's answer
But if you are using a Debian derivated OS, this solution should help you installing php zip extension.
You may have several php.ini files, one for CLI and one for apache. Run php --ini to see where the CLI ini location is.
Simply use sudo yum install php-zip
for PHP 7.3 / Ubuntu
sudo apt install php7.3-zip
for PHP 7.4
sudo apt install php7.4-zip
1 Step - Install a required extension
sudo apt-get install libz-dev libzip-dev -y
2 Step - Install the PHP extension
pecl install zlib zip
3 Step - Restart your Apache
sudo /etc/init.d/apache2 restart
If does not work you can check if the zip.ini is called in your phpinfo, to check if the zip.so was included.
For php 7.3 on ubuntu 16.04
sudo apt-get install php7.3-zip
The best way to install the Zip extension in php7.2 on CentOS would be as below:
Find the available extention by searching with yum command
yum search zip
This will list all the zip packages. We need to look for the php7.2 zip package
Then if your php version is 7.2 then run the command
yum install ea-php72-php-zip
This will definetly resolve your issue.
Cheers !!
On Amazon Linux 2 and PHP 7.4 I finally got PHP-ZIP to install and I hope it helps someone else - by the following (note the yum install command has extra common modules also included you may not need them all):
sudo yum -y install https://dl.fedoraproject.org/pub/epel/epel-release-latest-7.noarch.rpm
sudo yum -y install https://rpms.remirepo.net/enterprise/remi-release-7.rpm
sudo yum -y install yum-utils
sudo yum-config-manager --enable remi-php74
sudo yum update
sudo yum install php php-cli php-fpm php-mysqlnd php-zip php-devel php-gd php-mcrypt php-mbstring php-curl php-xml php-pear php-bcmath php-json
sudo pecl install zip
php --modules
sudo systemctl restart httpd
If you use php5.6 then execute this:
sudo apt-get install php5.6-zip
The PHP5 version do not support in Ubuntu 18.04+ versions, so you have to do that configure manually from the source files. If you are using php-5.3.29,
# cd /usr/local/src/php-5.3.29
# ./configure --with-apxs2=/usr/local/apache/bin/apxs --with-mysql=MySQL_LOCATION/mysql --prefix=/usr/local/apache/php --with-config-file-path=/usr/local/apache/php --disable-cgi --with-zlib --with-gettext --with-gdbm --with-curl --enable-zip --with-xml --with-json --enable-shmop
# make
# make install
Restart the Apache server and check phpinfo function on the browser <?php echo phpinfo(); ?>
Note: Please change the MySQL_Location: --with-mysql=MySQL_LOCATION/mysql
I tried changing the repository list with:
http://security.ubuntu.com/ubuntu bionic-security main universe http://archive.ubuntu.com/ubuntu bionic main restricted universe
But none of them seem to work, but I finally found a repository that works running the following command
add-apt-repository ppa:ondrej/php
And then updating and installing normally the package using apt-get
As you can see it's installed at last.
I was trying to install it on CentOS 7 for php 7.1. In my case yum package php-zip was unavailable in remi repo, but I could install it using different name
yum install php-pecl-zip
So if you can't find it by query php-zip, try searching for php-pecl-zip.
For those who need to install the zip extension in a Docker image being built.
Dockerfile:
FROM php:8.1-apache
RUN apt-get update \
&& apt-get install -y libzip-dev \
&& docker-php-ext-install zip

Categories