Install Specific PHP Version with Puppet & Vagrant - php

First time puppet user, and I'm having trouble getting an install of a specified version of PHP using Vagrant. I'm using the example42/php module, and I keep running into ensure problems.
Error: Could not update: Execution of '/usr/bin/yum -d 0 -e 0 -y install php-5.5.12' returned 1: Error: Nothing to do
Error: /Stage[main]/Php/Package[php]/ensure: change from absent to 5.5.12 failed: Could not update: Execution of '/usr/bin/yum -d 0 -e 0 -y install php-5.5.12' returned 1: Error: Nothing to do
Warning: /Stage[main]/Php/File[php.conf]: Skipping because of failed dependencies
spits out of my console, followed by another attempt that's identical.
My .pp file I'm provisioning with:
class lamp {
# package {'php':
# ensure => present,
# }
}
node 'node1' {
include lamp
file { '/php':
ensure => directory,
# I read that I may need to have a directory in order for the install to work...
}
class { 'php':
version => '5.5.12',
}
}
As far as I can tell, I'm referencing correctly to the modules, which I store inside /puppet/modules/ and it's finding them, but I'm having a hard time getting a specific version of PHP to install. I could use a very simple "getting started LAMP" for Puppet but that only install 5.3.3 even if I ensure => latest,

The puppet module only uses your system's package manager (yum) to download specific php packages. If it cannot find the required packages, it will not work. 5.3.3 is latest version in your repository, so it install that. I wouldn't be surprised if this is the only version of php available in your repositories.
You need to configure yum with some repositories which have the required PHP packages and then try the puppet module with that.

Related

Composer require ext-zip fails

I am told by PHPStorm that I need to composer require ext-zip, however, that command is failing...
PHPStorm says
The command I am issuing is
composer require ext-zip
results in
Your requirements could not be resolved to an installable set of packages.
and
Installation failed, reverting ./composer.json to its original content.
Solution #1 - add ext-zip to your required section of composer.json:
{
"require" : {
"ext-zip": "*"
}
}
Solution #2 - install php-zip extension:
Windows:
Uncomment this line in your php.ini
;extension=php_zip.dll
Linux:
sudo apt-get install php-zip
or
sudo apt-get install php7.0-zip (make sure you typed YOUR php version, you can check your version by doing php -v command)
Then, you need to restart your web server.
sudo service apache2 restart
If your code runs OK - you've already got the zip extension installed on your machine. PHPStorm adds this suggestion to ensure that anywhere else that the project is deployed also has the right extensions too.
Manually adding the line in your composer.json file (require block) "ext-zip": "*", (and others that it can suggest, such as ext-apc, ext-redis and ext-json, as well as any others that you might be using) will make sure that when you deploy it composer can also check that the appropriate extra items are installed.
It's only a warning though, and you could ignore it - or you can allow composer to make sure that your servers are setup as they would be needed to run your code, and do things with zip-files. If your server doesn't have ext-zip installed, composer install would complain, and stop - saving issues later when you discover that code fails without the zip extension, et al.
The given hint comes from PhpStorm, not from composer itself: your IDE has detected that your code uses a method (or in this case: the ZipArchive class) that is only available when the ZIP extension is enabled. But your composer.json did not contain that requirement so far.
So, PhpStorm asks you to add this requirement to the JSON file to make the requirements to run your code more precise. How you solve that requirement is up to you: the best way would be to install that extension, but that is out of composer's scope

How can I get a PHP extension name as known by composer?

I need to set up a composer.json with server requirements (e.g. php >= 5.6, lib-xml, etc). There are some examples in composer documentation, but what I need is a method to get a composer alias (ext-xxx, lib-yyy, etc) for a given PHP extension or library (e.g. php7.1-curl - Ubuntu package name).
Partial answer
composer show -p
Gives a list of extensions/libraries installed on the current system. So the solution is:
On a local linux/unix, install the library/extension in question (eg. apt install php-curl)
Filter the list of libraries recognized by composer to find the right result
composer show -p | grep curl

Class MongoDB\Driver\Query' not found, MongoDB installed

For this installation:
Nginx 1.11.10
Yii Framework 2.0.12 ("yiisoft/yii2-mongodb": "^2.0")
PHP MongoDB library (mongodb 1.2.9, compatible with PHP Version: PHP 5.4.0 or newer)
PHP 5.4.16
Plesk Onyx 17.0.17
No IPTables rules
Strangely enough they function when you visit the website the first time. I can also see data pulled from the Mongo database. But when visiting another page within 10-20 seconds, this error will appear:
25403#0: *170 FastCGI sent in stderr: "PHP message: PHP Fatal error: Class 'MongoDB\Driver\Query' not found in /var/www/vhosts/website.com/website.com/vendor/yiisoft/yii2-mongodb/Command.php on line 284" while reading response header from upstream
PHP Fatal Error – yii\base\ErrorException
Class 'MongoDB\Driver\Query' not found
1. in /var/www/vhosts/website.com/website.com/vendor/yiisoft/yii2-mongodb/Command.php at line 284
try {
$this->beginProfile($token, __METHOD__);
$query = new \MongoDB\Driver\Query($this->document, $options);
However, if you wait another 10-20 seconds, the website works just fine.
I solved it in a yii2 docker alpine nginx image, doing this:
FROM local/dmstr/php-yii2:latest-alpine-nginx
RUN apk --update add autoconf g++ make && \
pecl install mongodb
RUN echo "extension=mongodb.so" > /usr/local/etc/php/conf.d/docker-php-ext-mongodb.ini
You must install mongodb and then create an ini file for the extension on your system's php extensions directory, like I did. Remember to put extension=mongodb.so on it.

Pyrus problems on Ubuntu 12 installing ZF2

I tried to install zend framework 2 on Ubuntu 12.04.1 64 bit but have run into difficulties.
# sudo pyrus install zf2/Zend_Framework-beta#Standard
failed mid transaction with no other previous errors that I can recall other than warnings about timezone not being set. ( Unfortuantely my terminal history has lost the original output)
Pyrus\Installer\Exception: Installation failed
Pyrus\AtomicFileTransaction\MultiException: ERROR: commit failed
Pyrus\IOException: CRITICAL - unable to complete transaction, rename of actual to backup path failed
Pyrus\AtomicFileTransaction\RuntimeException: Cannot rollback - not in a transaction
Now when I try to rerun
# sudo pyrus install -f zf2/Zend_Framework-beta#Standard
it fails with
Pyrus\Registry\Exception: Cannot retrieve package file object for package packages.zendframework.com/zend_framework, it is not installed
Uninstall just tells me that it's not installed.
I restored /usr/share/.old-php to /usr/share/php however I still get the same error.
Please help.
You can just try to download and unzip Zend Framework 2 archive into your project's library folder.
It looks like it's a problem with the metapackage according the Matthew. I'm having the same problem.
Error Installing full framework with Pyrus
So if I installed pyrus here: "/usr/share/pear/pyrus" , then should I create a directory "/usr/share/pear/pyrus/zf2" and download and unzip the full Zend Framework in zf2 and it should work?
thanks

PEAR/Digg2: PHP/Linux Installation Issue

I have a VPS running a VPS optimized Debian distro.
I am very new to utilizing a VPS and have next to zero Linux background.
A little background to help:
I went through and apt-get install pear which went through fine.
I attempted to install the dependent services for the Digg api as such:
pear install HTTP_Request2
This provided an error, I had to install it with:
pear install HTTP_Request2-alpha
Then I attempted:
pear install HTTP_OAuth
This provided the same error as above, I installed it eventually with:
pear install HTTP_OAuth-alpha
So I then successfully installed Digg2 with pear install Services_Digg2
Okay, background over. My issue is that it will not initiate the class as it says the file is not there. The PHP is as simple as this:
require_once 'Services/Digg2.php';
$api = new Services_Digg2;
I checked my include path as per the error in PHP:
Fatal error: require_once() [function.require]:
Failed opening required 'Services/Digg2.php' (include_path='/usr/share/php')
in /var/www/redacted1/data/www/redacted2/index.php on line 3
So I verified that the file was there in Terminal:
http://snapplr.com/tk9r
And I verified that the include path was proper via PHP_Info():
http://snapplr.com/dwk7 (sorry I can only post one hyperlink as I'm new)
The error remains.
Hopefully my lengthy intro isn't a hassle and actually helps.
Any incite?
Thanks
Jeff
To install a PEAR/PECL package that is in a state other than "stable", you have to specify the full spec for the package:
pear install Services_Digg2-alpha #alpha state
pecl install ssh2-0.11.2 #beta state
PEAR also takes care of dependencies (usually, but I can confirm in that specific case that it does). You don't have to manually install them.
Now that you have it installed, it should work like you did:
include_once 'Services/Digg2.php'
However, I'm a little concerned that your code shows include_once while the error message you have shows you are using require_once. This leads me to believe that the code you posted is not the actual code.

Categories