I am trying to install some PHP packages that I use for my application in Alpine Linux. The packages that I am currently using come from the Remi repo and I install them successfully on CentOS 7, but when I try to install tthe same packages on Alpine, it says not found. An example of a package is php-cli.
Am I doing it right or is there a recommended way of installing packages in Alpine? I am using php7 and Alpine 3.8.
Note: I am using php7- prefix when I am installing a package in Alpine.
Thanks in advance.
For locating packages for Alpine Linux, the Alpine package search engine is the best place to look for.
Querying for php7*, we can see that there are indeed no matches on the main Alpine V3.8 repository, but many matches on the community repository: php7* package search.
For installing these packages, you'll first need to add the community repository to your /etc/apk/repositories file (uncomment it, if it is commented out):
http://dl-cdn.alpinelinux.org/alpine/v3.8/community
Then, run apk update and apk add php7 [additional packages...] for installing the desired PHP 7 packages.
Specifically, php7-cli seems to be missing. For PHP 7 CLI tools, you could try installing php7-dev from the edge community repository. Similar to above, add the following to your /etc/apk/repositories, then update and install:
http://dl-cdn.alpinelinux.org/alpine/edge/community
Related
centOS 7, when I try
yum install -y php7-devel
I got No package php7-devel available.Error: Nothing to do.
I want use php-x, it say I should install php7-devel. Anyone advice?
need to add yum repo. in my case i am using Webtatic repo.
what php yum rep you select?
i recommend remi php repo https://rpms.remirepo.net/
i can find php-devel in my vm
>
xxxx git:(change_format) ✗ yum search php70-php-devel
rh-php70-php-devel.x86_64 : Files needed for building PHP extensions
Which is you current PHP provider ?
CentOS provides PHP 5.4, and package name is php-devel
For more recent version, official solution (from Red Hat) is to use Software Collection which provide php 5.6, 7.0 and 7.1 which can be installed beside default version (without altering the base system).
You can read PHP Configuration Tips. In this case, package name is rh-php71-php-devel
Else you have to use some 3rd party repository.
Mine being a solution (dedicated PHP repository, with most extensions already packaged), see the Configuration Wizard. In this case, package name is php-devel (with the simplest "Single version" installation).
P.S. php-x not there for now, as I don't need it, no other extension use it.
I want to install the following PECL package (PDO-4D) on a Red Hat 7 server running PHP 7.1:
https://pecl.php.net/package/PDO_4D
The documentation doesn't seem to explain how to do this, so how do I do this?
The PDO_4D package available on PECL is not the most up-to-date.
You will find updated packages on Github, for example, here. The github repository has instructions for installing from source:
BUILDING ON UNIX etc.
To compile your new extension, you will have to execute the following steps:
$ phpize
$ ./configure --with-pdo_4d
$ make clean
$ make
$ make test
$ [sudo] make install
You could follow these same instructions for the source files downloaded from PECL.
An alternative approach for installing the PECL extension is to use PEAR like this:
pear install PECL/PDO_4D
You may need to make sure that pear is setup first before running that.
There is also a Technical Note that was published in 2011 regarding installing PDO_4D on Linux, although the document was written for Debian, not Red Hat.
My application is based on Laravel framework, and I need to build a Docker container with these specifications:
CentOS/RHEL 7.x
PHP 7.x
PHP extensions:
OpenSSL
PDO
Mbstring
Tokenizer
XML
But the problems are:
The official PHP image on the DockerHub is based on Ubuntu, but I rather have PHP on RHEL/CentOS instead of Ubuntu.
The latest PHP version on CentOS official Yum repositories is 5.4.16 which is lower than the version Laravel requires. Based on distrowatch.com, it seems like RHEL also still has the same old version of PHP on its repositories.
I cannot trust unofficial images, so the solution should be based on official images only.
I want to use this container in my production environment, so I rather rely on trusted resources instead of third-party repositories like Webtatic.
Is there any way to have the latest version of PHP on a Docker container based on CentOS? For example, is it possible to make an image based on both CentOS and PHP official images?
Sorry if my question sounds stupid, I am still new to Docker and after reading the documents and a number of articles online I haven't found my answer yet.
I followed following steps and successfully created CentOS image with php 7.0.
Pull down and run CentOS image with interactive mode.
docker run -it centos
I followed these steps mentioned at webtatic to setup php7. To install, first you must add the Webtatic EL yum repository information corresponding to your CentOS/RHEL version to yum
rpm -Uvh https://dl.fedoraproject.org/pub/epel/epel-release-latest-7.noarch.rpm
rpm -Uvh https://mirror.webtatic.com/yum/el7/webtatic-release.rpm
To install PHP 7
yum install php70w php70w-opcache
Install packages by
yum install OpenSSL PDO Mbstring Tokenizer xml zip unzip curl
I additionally added zip unzip curl as they are required to install composer.
Exit out from container by typing exit and list down available containers.
docker ps -a
copy the container id and commit it as a new image by using following command.
docker commit -m "setup centos image with php7.0 and composer" -a "Your Name" 2b252ba66277 yourname/centos-php7.0-composer
list down available images and you'll see the newly created image.
docker image ls
Run the newly created image
docker run -it yourname/centos-php7.0-composer
Edit
You can also pull down gayansanjeewa/centos-php7.0-composer which I have created with these steps.
I've downloaded and installed Imagick and Imagick-devel. I now want to use it with PHP but every guide I've found has the following steps:
pecl install imagick
echo "extension=imagick.so" > /etc/php.d/imagick.ini
The first step pecl is part of PEAR, a package that I don't need and don't want to install. How would I install and hook Imagick to PHP without that pecl command?
OS: CentOS 6
Either your package manager has a php-imagick package, or you simply have to install pear/pecl to install the php extension.
PEAR is the only php package manager that supports installing php/pecl extensions, so unless your linux distribution provides a package itself, you have to use it.
Alternatively, you can download the tgz, extract it, compile it, install it and activate it manually. You have to know what you're doing in this case, though.
phpinfo() function shows that my PHP version (5.1.6) is installed --without-pear in the configure command section.
How do I install pear?
The Getting and installing the PEAR package manager page should help you : it gives informations on how to install the PEAR package manager, on both windows, Linux, and Mac.
Basically, if your Linux distribution comes with a PEAP package, you should install it.
For instance, on Ubuntu1, there is a php-pear package ; so, you'd use :
apt-get install php-pear
Else, if it doesn't, with a version of PHP >= 5.3, you should be able to use this :
$ wget http://pear.php.net/go-pear.phar
$ php go-pear.phar
With PHP 5.1, though, this is not going to work, as phar support has been added in PHP 5.3...
As a sidenote : PHP 5.1 is really outdated !
PHP 5.3 is more than one year and a half old ; even PHP 5.2 is not maintained anymore... maybe you should consider upgrading ?
1It seems you are running some kind of Redhat-based distribution, but I don't have one of those, so I cannot say if there is a PEAR package for it -- there is probably one, though.
--without-pear only means that the PEAR bits were not immediately created when PHP was compiled.
This usually happens when an operating system vendor that provides packages and wants to split off bits and pieces into their own individually installable parts.
Given the age of the PHP you're talking about, you're probably on RHEL or a derivative like CentOS. Check the package manager for a php-pear package.