I'm trying to install pdo-mysql to PHP container
I tried to install it using command line as:
apt install pdo pdo_mysql
but the extension not installed and provide a lot of errors.
But When I use
docker-php-ext-install pdo pdo_mysql
The extension was installed successfully
So what is the difference between them, and when must use each of them?
apt is a softwar for Debian-like Linux distributions to manage packages. It can install pre-compiled packages for your distribution. It can do it for PHP-related packages as well. If you installed PHP using apt you can also install additional packages for it like that:
sudo apt install -y php-pdo-mysql
The exact package name will depend on the distribution you used and/or how you installed PHP in the first place.
The docker-php-ext-install is a special shell script in the official PHP Docker image where PHP was installed from the source. It will compile and install the necessary extensions.
Since you are using this Docker image docker-php-ext-install is the way to go.
To sum it up: it all depends on how PHP was installed in your Docker image in the first place. If a package manager was used - then apt is the way to go. If you use the official PHP Docker image it compiles PHP from the source code and provides a shortcut to compile additional extensions using docker-php-ext-install.
Related
I am using Ubuntu 17 with php 7.1 and am trying to install Laravel 5.5 but it is telling me to check the minimum requirements.
I can't install the recommended php extensions. I am using sudo add-apt-repository ppa:ondrej/php but it appears the extension are not there and there is a mismatch from the repo
Repository 'http://ppa.launchpad.net/ondrej/php/ubuntu artful InRelease' changed its 'Label' value from '***** The main PPA for PHP (5.6, 7.0, 7.1) with many PECL extensions *****' to '***** The main PPA for supported PHP versions with many PECL extensions *****'
Your composer should say what extensions you need.
You also check doc https://laravel.com/docs/master#installation
PHP >= 7.0.0
OpenSSL PHP Extension
PDO PHP Extension
Mbstring PHP Extension
Tokenizer PHP Extension
XML PHP Extension
sudo apt-get install curl php-curl php-mcrypt php-mbstring php-gettext
Install PHP 7.1 on Ubuntu
Use the following set of commands to add PPA for PHP 7 in your Ubuntu system and install it.
> sudo apt-get install python-software-properties
> sudo add-apt-repository ppa:ondrej/php
> sudo apt-get update
> sudo apt-get install -y php7.1
Now use the following command to check installed php version on your system.
> php -v
Install PHP 7 Modules/Extensions
Find all the available PHP 7 modules using the following command:
> sudo apt-cache search php7-*
Install required PHP extensions using the following command
> sudo apt-get install <extension-name>
You can install multiple extensions using the same command. Separate extension names by a space.
For example
> sudo apt-get install php7.1-xml php7.1-xmlrpc php7.1-zip
Laravel 5.5 System Requirements Checker
To verify system requirements for Laravel 5.5 you can then use the following simple app.
https://github.com/mitesh1409/laravel-system-requirements-checker
Do git clone of this repo inside your server's root directory and then execute it.
For example using Apache server on Ubuntu 16.04, do git clone of this repo inside "var/www/html". It will create an app folder named "laravel-system-requirements-checker". Now you can run this using the url "http://localhost/laravel-system-requirements-checker/".
I hope this will help everyone starting development on Laravel 5.5.
Thanks.
Laravel-Requirement-Checker from browser
https://github.com/hosamalzagh/Laravel-Requirement-Checker
I've installed PHP:latest Docker container using the docker-compose command. It installed php-7.1.6-fpm in my Docker. When I tried to install php7-pgsql extension it failed to find that package, instead found pdo and pdo_pgsql packages. That will not satisfy my need. When I search for the available packages in the installed PHP container, I could not find any related pgsql packages for php7, instead, I saw php5-pgsql package, that will not work with php7-fpm.
Finally, I installed php-5.6-fpm container after removing the old one targeting to use php5-pgsql package. But now I disappointed again that I could not find php5-pgsql package in the newly installed container.
I know I'll be missing some important points. Whether Alpine Linux does not have php-pgsql extension. What are the possible ways to include this extension in my PHP container. I've also included Nginx and Postgres in my docker-compose.yml
I've only 3-day theory knowledge in Docker and first-day practical experience.
Thanks for reading.
I ran into the same issue when I was settings up a new project to use pgsql.
I am using php7, so you should be able to use it as well. On your Dockerfile ensure you're covering the following steps.
Ensure you have the dependencies installed:
RUN apt-get update && apt-get install -y libpq-dev
Configure the extension:
RUN docker-php-ext-configure pgsql -with-pgsql=/usr/local/pgsql
Install the extension:
RUN docker-php-ext-install pdo pdo_pgsql
This is an old question i know, but i ran into this today and believe the above solution has changed with php:7.4-fpm-alpine
So where it used to be:
RUN apt-get update && apt-get install -y libpq-dev
Should now be:
RUN apt-get update && apt-get install -y postgresql-dev
Hopefully this helps anyone that runs into the same issue.
I was trying to find any information about using Memcached with PHP7, but I failed. The only valuable information is short Readme.md of php-memcached repo.
Unfortunately, its travis build failed as well as 30/126 tests on my machine.
However make install command was successful and created memcached.so file. Does it mean I can use this extension in production or it still has bugs and is not recommended for using?
I will very appreciate any advice or working solution.
You need to use the php7 branch; see here, Travis is passing.
This should be the complete set of steps to install the memcached extension on a Debian/Ubuntu OS:
sudo apt-get update
sudo apt-get install -y libmemcached-dev libmemcached11 git build-essential
git clone https://github.com/php-memcached-dev/php-memcached
cd php-memcached
git checkout php7
git pull
/usr/local/php7/bin/phpize
./configure --with-php-config=/usr/local/php7/bin/php-config
make
sudo make install
You may need to change some of the paths if you have them installed at different locations.
To install memcached on the latest ubuntu for the latest php use:
sudo apt-get install php-memcached
For Debian 8 users, you can use:
sudo apt-get install php7.0-memcached
I came to this question via an issue with getting artisan to work in the Laravel Lumen framework.
I'm using PHP 7. PHP 7.0.15-0ubuntu0.16.04.4 to be precise.
I found the only solution was to install what appears to be the PHP 5 version* with memcached†:
sudo apt install memcached php-memcached
*
php-memcached/xenial,now 2.2.0-51-ge573a6e+2.2.0-2build2 amd64 [installed]
memcached extension module for PHP5, uses libmemcached
†If you find you then get the error: [RuntimeException] Could not establish Memcached connection., you need to install the memcached extension as the above sudo apt install memcached (if you're on 16.04+, use apt-get if < 16.04)
I've installed PHP via Yum on RedHat (minimal install; no GUI), but in order for me to install an application on the system I need to install PHP Mcrypt extension. How does this work? Should I remove PHP via Yum and install from source and use the parameters in the above link (--with-mcrypt[=DIR])?
It's a separate package. In packaged Linux they break the separate compiled extensions into their own library and then include those. Try this
yum install php-mcrypt
I should also note that mcrypt may be deprecated in the future
I want to install the v8js extension for PHP5.5 on Ubuntu 12.04 but can't make it working.
When I try to install the v8js extension version 0.2.0 (latest) with PECL, I have this message:
configure: error: libv8 must be version 3.24.6 or greater
ERROR: `/tmp/pear/temp/v8js/configure --with-v8js' failed
If I try to install an old version, I have a compilation error. This message is very similar to my issue: Install v8js for php on ubuntu
How can I fix this issue?
EDIT: I couldn't install it on Ubuntu 14.04 with PHP5.5, even with a PHP downgrade with PHPbrew to PHP 5.4. However, using Ubuntu 12.04 with PHP 5.4 works great. I didn't try the downgrade from PHP 5.5 to 5.4 on Ubuntu 12.04.
in case you can't find libv8-dev or libv8-dbg, you can find the correct version by run command
~$ apt-cache search libv8
libv8-3.14-dbg - V8 JavaScript engine - debugging symbols
libv8-3.14-dev - V8 JavaScript engine - development files for 3.14 branch
libv8-3.14.5 - V8 JavaScript engine - runtime library
libv8-dev - V8 JavaScript engine - development files for latest branch
then you can run
~$ sudo apt-get install libv8-3.14-dev libv8-3.14-dbg g++ cpp
then you can try to install v8js via pecl by running
~$ sudo pecl install v8js-0.2.0
if that command return error like this
configure: error: libv8 must be version 3.24.6 or greater
ERROR: `/tmp/pear/temp/v8js/configure --with-v8js' failed
you can try to install v8js-0.1.3 instead by running
~$ sudo pecl install v8js-0.1.3
then edit your php.ini to add v8js extension
~$ echo "extension=v8js.so" >> /etc/php5/cli/php.ini
Open your terminal/console
sudo apt-get install libv8-dev libv8-dbg g++ cpp
Make an update sudo apt-get update
Try sudo pecl install v8js-0.2.0 (or other version i.e.: sudo pecl install v8js-0.1.3)
Edit your php.ini (Check: Where is my php.ini file?) file by adding: extension=v8js.so.
Restart server
If it the extension still doesn't work, try to edit /etc/php5/conf.d/v8js.ini and add extension=v8js.so and restart server again.
Hope this helps.
These other answers work well and I used v8js-0.1.3 for the past 1.5 years but after needing to upgrade to PHP 7 I needed a better solution as v0.1.3 doesn't compile with PHP 7 (something to do with php_smart_str being renamed to php_smart_string).
After a couple hours of frustrating research and compiling libv8 myself, I didn't want to have to go through this whole process on every server I provisioned.
Anyway, I found this site which points you to a launchpad PPA site that provides a couple different ubuntu packages with the 5.1 and 5.2 libv8 libraries.
I ran these commands (please don't add repositories of 3rd party devs without understanding the risks).
sudo apt-add-repository ppa:pinepain/libv8-5.2
sudo apt-get update
sudo apt-get install libv8-5.2-dev
sudo pecl install v8js-1.1.0
(Thanks #JeyKeu for suggesting to add "apt-get update" to these commands)
I couldn't get v8js-1.3.0 or 1.2.0 to build, but 1.1.0 worked well. I checked the changelog and found that the latest updates are not necessary in my circumstance anyway.