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.
Related
I have a problem, I just want to uncomment extension=php_intl.dll in my php.ini file
but that extension doesn't exist, I'm using Centos with Nginx configuration.
Linux servers don't use .dll files. You need a .so instead.
To install php_intl on CentOS , you should enable remi repo . Open the terminal and run the following commands:
wget https://rhel7.iuscommunity.org/ius-release.rpm
sudo rpm -Uvh ius-release*.rpm
Update your system then install the php-intl:
sudo yum update
sudo yum --enablerepo=remi install php-intl
To permanently enable remi repo , open the terminal and run the following command:
sudo nano /etc/yum.repos.d/remi.repo
Set enabled=1.
How did you install PHP ?
PHP 5.6.3 is terribly old, and affected by tons of security issues, latest version is 5.6.40 but have reached its end of life a few months ago
If installed from sources, you have to rebuild it, location of php command usually gives useful information (ex, when installed in /usr/local)
which php
or remove this build from sources, and switch to RPM provided binaries.
If installed from a 3rd party repository, you should find the intl extension in the same repository.
see information provided by the yum command
yum info php-cli
While I heartily recommends to upgrade to a supported version (7.1+), if you want to keep 5.6, "remi" is the only repository which still provides this version (with security backports).
To upgrade your installation (to latest 5.6.40 or any other version, 7.0, 7.1, 7.2, 7.3), simply follow the wizard instructions.
With RPM, you never have to change php.ini to enable installed extension, each package provides its own configuration file (ex: /etc/php.d/20-intl.ini) which
enable it.
With proper provider, for any needed extension (ex xxx), a simple
yum install php-xxx
will install the package with this extension (package name may be different, as some packages provide various extensions).
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
I have installed MongoDB PHP lib
but despite this I can't connect to MongoDB database
Error of rockmonogo :
To make things right, you must install php_mongo module. Here for installation documents on PHP.net.
Error of phpmoadmin :
PHP cannot access MongoDB, you need to install the Mongo extension for PHP.
Error of Laravel with Jenssegers\Mongodb lib :
Unsupported driver [mongodb]
Make sure that it is in fact properly installed. The errors you're getting seem to indicate that your environment can't find the extension. I've compiled installation instructions for you.
Unix-like Systems
Open a terminal emulator and run wget http://pear.php.net/go-pear.phar
Then start the installation of PECL with php go-pear.phar
Install the PHP MongoDB extension sudo pecl install mongodb.
Add extension=mongodb.so to the php.ini file.
Mac OS X
Install homebrew by running /usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)" in a terminal.
Run brew update
Run brew tap homebrew/php
Install the extension according to your PHP version.
PHP 5.4: brew install php54-mongodb
PHP 5.5: brew install php55-mongodb
PHP 5.6: brew install php56-mongodb
PHP 7.0: brew install php70-mongodb
Windows
Open your web browser to http://pecl.php.net/package/mongodb
Open the latest version from the DLL link (with the Windows icon).
Choose the appropriate version from the DLL list. They are sorted by PHP version, system architecture (i.e. 32-bit vs 64-bit), and thread safety.
Extract the downloaded archive and place php_mongodb.dll in your PHP extensions directory.
Add extension=php_mongodb.dll to the php.ini file.
For mac system, the homebrew php tap mechanism is deprecated and it won't work. You need to manually install it or you need to install Ampps which contains all the packages in built.
The following error might be thrown for the user with new version of the system
Error: homebrew/php was deprecated. This tap is now empty as all its formulae were migrated.
Everything is in the title : can I use https and the Auth:: class whithout having installed php mcrypt ? (I'm on a redhat enterprise linux 6.1 on architecture s390x, it's just impossible to find pre-compiled packages).
If it's possible then I would just use Laravel whithout Mcrypt...
mcrypt is a requirement of Laravel, you simply cannot run a laravel app without having mcrypt installed.
The following link may help with installing mcrypt:
http://injustfiveminutes.com/2012/11/23/install-php-mcrypt-extension-on-rhel-6/
Excerpt:
The php-mcrypt extension is not available on Redhat Enterprise Linux 6
although some applications such as Magento or phpMyAdmin require it to
work properly. We can easily install it though from the Fedora Project
repositories.
1) Download the following RPM pacakges:
wget http://dl.fedoraproject.org/pub/epel/6/x86_64/php-mcrypt-5.3.3-1.el6.x86_64.rpm
wget http://dl.fedoraproject.org/pub/epel/6/x86_64/libmcrypt-2.5.8-9.el6.x86_64.rpm
2) Install them using YUM:
$ yum localinstall php-mcrypt-5.3.3-1.el6.x86_64.rpm
$ libmcrypt-2.5.8-9.el6.x86_64.rpm
3) Reload Apache server to load the extension up:
$ service httpd restart
I want to update my php 5.3.3 to php 5.3.8, I already downloaded PHP5.3.8.tar.gzip.
My PHP 5.3.3 located in /usr/bin/php. When I try to install PHP5.3.8.tar.gzip and do this command:
./configure
make
make install
It installed in different location /usr/local/bin/php.
So now I have 2 php 5.3.3 and php 5.3.8. So I try to install it again and run this
./configure -prefix=/usr/bin/php
make
make install
This time an error occurred:
Installing PHP SAPI module: cgi
mkdir: cannot create directory `/usr/bin/php': File exists
mkdir: cannot create directory `/usr/bin/php/bin': Not a directory
make: [install-sapi] Error 1 (ignored)
Installing PHP CGI binary: /usr/bin/php/bin/
cp: accessing `/usr/bin/php/bin/#INST#29239#': Not a directory
make: *** [install-sapi] Error 1
Please help me, I want to delete the php5.3.8 I installed in /usr/local/bin/php
and update the /usr/bin/php to php5.3.8. I need php5.3.8 version only.
Thanks.
Generally on CentOS, you want to leave this sort of thing to yum.
yum update php
or
sudo yum update php
You can also replace the installation with a newer version. 5.3.X is not supported any longer, so you could do:
yum install yum-plugin-replace
yum replace php --replace-with php55
If you don't have php 5.5 in yum, first do this:
cd ~
wget http://dl.iuscommunity.org/pub/ius/stable/CentOS/6/x86_64/epel-release-6-5.noarch.rpm
wget http://dl.iuscommunity.org/pub/ius/stable/CentOS/6/x86_64/ius-release-1.0-11.ius.centos6.noarch.rpm
rpm -Uvh epel-release-6-5.noarch.rpm ius-release-1.0-11.ius.centos6.noarch.rpm
If you don't have wget installed:
yum install wget
PLEASE NOTE FOR ALL OTHERS FINDING THIS THROUGH GOOGLE!!!
The URL's that I linked in the wget commands are the current releases of the epel and ius repos for CentOS 6. (It may also be out of date.)
If you have RHEL or CentOS 5, you can find the specific link for your RPM here: http://dl.iuscommunity.org/pub/ius/stable/
Why do you need 5.3.8 specifically? The last version of 5.3 was 5.3.27. 5.3 is end-of-life. I would find a modern repo like remi and install 5.4 or later using yum