After compiling PHP from source are the devel libraries still needed? - php

After compiling PHP from source are the devel libraries still needed?
For example, I am building a newer version of PHP from source than is on our dev servers. I installed alot of [extension i.e. mysql, postgresql, curl, etc]-devel packages in order for the configure from the dev server setup to work. Do i still need these after php has compiled? For example could I make a distro and then distribute the PHP distro to another server without needing these devel dependencies?
I am a bit of a noob to this.

You don't need to ship the devel-libraries.
But my advice is to take some time and learn how the build system of your linux distribution works. And then build a new php package that can be installed by the package manager.
Take a look at how the "original" php packages were built for the distribution. Most likely you can simply copy and edit the existing rule file(s) and then make a new version of that package. This way you take advantage of the dependency mechanisms and the package manager will not remove/overwrite your version so easily when an update shows up in the "official" repositories.

Related

I've used composer to install drupal - why do I still have unresolved php dependencies?

I'm trying to build a drupal webserver using composer, which I am told is the right way to do it.
The command I've used to install drupal is this:
composer create-project drupal-composer/drupal-project:8.x-dev --stability dev mysite --no-interaction
However, when I start my apache server I get a bunch of errors about missing libraries, functions, etc. I can resolve these by googling each one and installing the required php library - but isn't composer supposed to do this for me? According to the composer docs;
Composer is a tool for dependency management in PHP. It allows you to
declare the libraries your project depends on and it will manage
(install/update) them for you.
When I navigate to the mysite/vendor directory I see a bunch of drupal-related packages, but as far as I can tell these are only drupal dependencies, not php dependencies. Am I missing something here?
I think the confusion here comes from the word 'libraries'.
Composer is a tool for dependency management written in PHP.
PHP itself relies on a scripting engine (originally Zend, but there are alternatives like Facebook's HHVM, etc.), it works as a compiler and runtime engine and it needs 'libraries' - think of it as modules or extensions. These modules are mostly written in C, some in C++.
Having 'missing libraries' errors when Apache starts up does not mean Composer has missed any Drupal dependencies, it means PHP needs to be configured or rebuilt properly with the missing modules.
There are 3 types of modules (PHP's extensions membership):
Core modules that cannot be left out of a PHP binary with compilation options.
Core extension modules that are bundled with PHP core but not necessarily enabled.
External modules that are not bundled with PHP core. These modules are available from a repository called PECL (PHP Extension Community Library).
For example, if you were to speedup Drupal or any PHP applications by caching both PHP code and user variables, you would need some opcode like APC. That said, adding APC settings to php.ini would not work as is without the corresponding module being compiled with PHP.

I have developed am application using PHP7 but on the server there is PHP5 and we cannot upgrade the PHP there

Please help me, I have developed an application using Yii2 Framework which requires PHP5.6 or greater, and while deployment of the application on the test server I have noticed that on the test server we are using PHP5.5, So please tell me what can I do? The test server is running Ubuntu.
(Minimum requirement of Yii2 is PHP5.6 and we are using PHP5.5)
Thank You.
if I recall correctly, PHP 5.5.X and 5.6.X are not that different. So if you can deploy your application and it runs properly, you should be fine. If you are using composer, it might be harder (or impossible) to spoof your PHP version, though.
My two cents:
You tagged AWS (and therefor probably EC2), so why don't you just update your PHP version? Why don't you run your application on PHP 7.X anyway? It is a great improvement - performance-wise.
You can try a few things...
1) Do you need to have the dev modules from Composer on the test server? If not do a composer install —no-dev
2) Another switch worth trying on the test server is “--ignore-platform-reqs” I don’t recommend it and even though composer install the files the application might not work.
3) If the above isn’t a fix for you, modify your Composer file to put in the constraints of your environments, change your local environment to match the test server, and re-factor the application if necessary. I’d do that instead of rewriting a whole app in Yii1.
You might want to edit your question and add the information about your composer.json file. Do you commit the composer.lock file to source control?
Additionally, not wise for your company to use anything older than PHP 5.6. And PHP 5.6 will have security support ended in Dec 2018. http://php.net/supported-versions.php
Read the following PHP documentation linked below, particularly the backward incompatibility changes and deprecated features. If you use any of those, you need to change your code. If you don't, then you should be fine. You need to test it.
http://php.net/manual/en/migration56.php

Reduce time to build PHP

Previously, I used package managers (i.e. YUM) to install and configure PHP. However, I would like to upgrade to PHP 7 and the package manager(s) available do not yet have PHP 7 available natively.
The plan is to use Chef to compile PHP on the server (during Setup) from original source. With that said, this process can take ~15 minutes on our server and will severely impact boot time.
Are there any techniques for increasing the speed at which the PHP
is compiled?
Can I create a tarball of final binaries and simply
download these to my servers?
There are some online resources that suggest adding the "webtatic" repo to YUM to access PHP 7. Is this safe/secure + reliable?
I am looking for freedom to upgrade my PHP version independent of when the package manager supports the version I am interested in
We ended up waiting for Ubuntu 16.04 which brings in PHP 7 via apt-get. Compiling PHP from scratch didn't turn out to be an efficient nor maintainable process

How do I specify Ansible PHP version?

How do I specify which version of PHP that Ansible loads up? Note: Ansible is software for managing the build of servers, you specify the recipe for how you want your server setup and then can fire up a new server in a few minutes. I am looking specifically for how to do this with "Ansible".
The version/s of PHP installed/available depends on your operating system and the repositories it has access to. If you're on a RHEL-based system, you might want to look at the IUS Repository and install php54 rather than the default php. I'm sure there are similar Debian repositories available.

Compile PHP on Linux or use apt-get / yum?

I have been compiling PHP for years with the configuration options I want. I compile extensions I use from source. Is there an advantage to doing this versus installing it from a package manager like apt-get or yum. I assumed it would also give me a leaner binary. I noticed that their are PHP modules in the repos such as "php53-gd". What if there wasn't a package available for something I wanted such as cURL for PHP?
I understand the disadvantages of compiling such as needing to download/install dependencies based on my configuration options. I'm not really concerned with that.
So the question is:
Compile PHP on Linux or just use apt-get / yum? Can I get all the things I need from the repos? Does anyone out there still compile it from source?
Any insight is appreciated! Thanks.
I compile from source every time. It's not hard to corral the mentioned issues with regards to compiling manually. For example, my ./configure settings are saved to a file which is version controlled, so when a new version of PHP is stable and I am ready to make the switch, I download and extract the file, then run this command:
./configure `sh /path/to/my/configure/php.sh`
Not too difficult. And because it's in version control, I can add notes as to why a module was added or removed.
Another benefit of manual compilation is it allows me to keep the PHP footprint as minimal as possible. I pass the --disable-all flag, then add the modules I need. However, there is a downside to this minimalist approach, recently I needed to install Magento, so I had to recompile with --enable-hash and --with-mcyrpt flags. Even though I needed to add new flags, it wasn't difficult to add to the configure file and recompile.
Compiling from source has a few quirks:
There are hundreds of config parameters and flags. And you might not know the optimal ones that need to be used.
if you rely on apt-get's PHP, then you can be assured that you will get the latest patches and security updates if you set up auto-upgrade on your server.
the configuration of php.ini varies a lot. Sometimes your OS may decide some defaults for you which may work better with the rest of the system.
installing extensions like xdebug or other packages are a lot easier with apt.
However, it's worth compiling php from scratch if you want to learn. Also if you don't use some portions of it, you can always disable them in configuration - but then again it might not make much difference to performance.
I compiled php for specific needs only, like :
very small hard disk space so required a minimalist php version
and/or
need only a few specific modules or extensions
and/or
needed for a specific application
and/or
needed to optimize performances: when compiling on the machine where it's used, this allows some performance improvements, if using compile options to get a real tuned version for your system,
and/or
needed multiple and different php versions on the same machine.
and/or
I had a specific nux distro like only a busybox, so no other options than compiling.
But for common usage, e.g. in 80% of the cases, it's not worth spending time to compile and better using the repository version. But I learned a lot by compiling.
Personally, it's a matter of opinion. If you are in a hurry, apt-get it, if you have time to learn and possibly need to reinstall 20 times...compile it.
There are tons of guides out there for PHP compiling. It has a ton of flags for configuration, especially for GD and other libraries. Personally if this is for learning and development, just get LAMP or use apt-get...especially if you need to use Apache
I feel the primary reason for compiling is to have latest version binary (stable or nightly). package managers (most distors) are often annoyingly slow in this respect.
The other reason is that its very common problem that production systems are not wholesale upgraded using package managers. Even if that can be easy. Since package managers create dependency chains and you may not want to upgrade those items. So just to pick one item, compiling is an option. It keeps everything else as it is. You ofcourse have to always study the upgrade issues and make sure nothing else will fail.

Categories