Skip to main content

PHP CLI vs PHP web (CGI ) diferrent --with-config-file-scan-dir=

 https://serverfault.com/questions/968402/load-specific-php-module-for-directory-apache-2-4-centos-7

You can't load two different PHP modules at the same time. Full stop. This is why you must use php-fpm to run different PHP versions.

https://medium.com/@pushpendrachauhan/how-migrating-apache-mpm-from-prefork-to-event-based-using-php-fpm-saved-our-day-8a6e371d94fd


=> note more

https://forums.aws.amazon.com/thread.jspa?threadID=283215

https://stackoverflow.com/questions/30446904/how-to-allow-custom-built-scan-this-dir-for-additional-ini-files-php-ini-file

https://www.php.net/manual/en/configuration.file.php

The configuration file ¶

The configuration file (php.ini) is read when PHP starts up. For the server module versions of PHP, this happens only once when the web server is started. For the CGI and CLI versions, it happens on every invocation.


php.ini is searched for in these locations (in order):

https://github.com/brefphp/bref/issues/355

AWSTemplateFormatVersion: '2010-09-09'

Transform: AWS::Serverless-2016-10-31


Globals:

    Function:

        Environment:

            Variables:

                APP_ENV: prod

                APP_SECRET: 'foobar'

                PHP_INI_SCAN_DIR: /var/task/custom-php-folder-in-project-dir

               

Resources:

    Website:

        Type: AWS::Serverless::Function

        Code: ..

        Properties:

            FunctionName: 'my app'

       # ...


Bryan,

The CLI/(Fast)CGI versions do load the .ini files each time they are fired up; however, the apache module loads them once into memory when the server is started. You can test this behavior by changing a value in any of the .ini files and running the CLI binary. Notice that you need a server restart before you can see the changes in the server module version.

Does this tell the PHP binary to do a file system scan every time the PHP module is loaded to respond to a request?
No. When you compile --with-config-file-scan-dir=/path/to/dir all you're doing is telling PHP combine all files in this directory into its configuration. This is a method often used in system configuration where package management systems need to be able to add/remove package specific configuration from an application without potentially destroying a end-user modified config file. An example here would be, on a Debian based system, when you apt-get install php-pgsql, it will create a /etc/php/conf.d/pgsql.ini which will contain the extension=pgsql.so line, as well as any module-specific options.

Does enabling the configuration option with-config-file-scan-dir when compiling PHP lead to performance issues?
Not really. In practice, it is simply a concatenation of all the .ini files in that particular directory.

I can tell you that Debian, CentOS, and Zend Server all use this option by default.

Also, just off the top of my head, *nix RC files, Apache2, Courier, Emacs, and Cron all use (or can use) similar approaches to loading configurations.

After install php56 and httpd24 in default Amazon AMI Linux 2018.03 (community image since AMI 1 now not available on Amazon).
It show default config dir (ini) same with PHP CLI and web:



Only php 5.6.40 available, not 5.6.37 and it seem no ZTS (Zend Thread Safe) version available.

We can trace -with-config-file-scan-dir= in source code of php source:
https://github.com/php/php-src/tree/PHP-5.6.37
(Huge .git folder => after clone you can remove this folder).
And we only care about config, core folders so extension folder can be removed (about 200MB).
grep -rn "with-config-file" .
./configure.ac:879:  [AS_HELP_STRING([--with-config-file-path=PATH],
./configure.ac:897:  [AS_HELP_STRING([--with-config-file-scan-dir=PATH],
./azure/macos/job.yml:69:            --with-config-file-path=/etc \
./azure/macos/job.yml:70:            --with-config-file-scan-dir=/etc/php.d
./azure/configure.yml:70:        --with-config-file-path=/etc \
./azure/configure.yml:71:        --with-config-file-scan-dir=/etc/php.d
./azure/i386/job.yml:70:            --with-config-file-path=/etc \
./azure/i386/job.yml:71:            --with-config-file-scan-dir=/etc/php.d
./azure/msan_job.yml:54:            --with-config-file-path=/etc \
./azure/msan_job.yml:55:            --with-config-file-scan-dir=/etc/php.d

=> Default is empty (or DEFAULT).
Or may be it get from $libdir or something deep in core of PHP.
With azure we can clearly see default value is '/etc/php.d'

Hello,

I have a Centos 5.7 x86_64 which at the moment run apache prefork but this mode uses a lot of memory per processes and I want to switch to worker.

So I installed via yum php-zts and all works great when I start the worker instead of the prefork, except the fact that eAccelerator doesn't load.

I know that I have to have the zts version of eaccelerator, but because I have installed zts via yum my php-config and phpize are for the normal non-zts php(I think) so I can't compile the zts version, so now the worker consumes less memory but is much slower then the prefork because it's not cached by eA.
Is there a way to get a hold of a eAccelerator zts enabled module for centos?
xCache will be goood too.

apache, php are all the latest repo versions.

sudo ./php-zts-installer.sh

content of php-zts-install.sh

#!/bin/bash

mkdir -p /etc/php7
mkdir -p /etc/php7/cli

git clone https://github.com/php/php-src.git -b PHP-7.0.17 --depth=1
cd php-src/ext
git clone https://github.com/krakjoe/pthreads -b master pthreads

cd ..

./buildconf --force

./configure --prefix=/etc/php7 --with-bz2 --with-zlib --enable-zip --disable-cgi \
    --enable-soap --enable-intl --with-mcrypt --with-openssl --with-readline --with-curl \
    --enable-ftp --enable-mysqlnd --with-mysqli=mysqlnd --with-pdo-mysql=mysqlnd \
    --enable-sockets --enable-pcntl --with-pspell --with-enchant --with-gettext \
    --with-gd --enable-exif --with-jpeg-dir --with-png-dir --with-freetype-dir --with-xsl \
    --enable-bcmath --enable-mbstring --enable-calendar --enable-simplexml --enable-json \
    --enable-hash --enable-session --enable-xml --enable-wddx --enable-opcache \
    --with-pcre-regex --with-config-file-path=/etc/php7/cli \
    --with-config-file-scan-dir=/etc/php7/etc --enable-cli --enable-maintainer-zts \
    --with-tsrm-pthreads --enable-debug --enable-fpm \
    --with-fpm-user=www-data --with-fpm-group=www-data

make && make install

chmod o+x /etc/php7/bin/phpize
chmod o+x /etc/php7/bin/php-config

cd ext/pthreads*
/etc/php7/bin/phpize

./configure --prefix=/etc/php7 --with-libdir=/lib/x86_64-linux-gnu --enable-pthreads=shared --with-php-config=/etc/php7/bin/php-config

make && make install

cd ../../
cp -r php.ini-development /etc/php7/cli/php.ini

cp php.ini-development /etc/php7/cli/php-cli.ini
echo "extension=pthreads.so" > /etc/php7/cli/php-cli.ini
echo "zend_extension=opcache.so" >> /etc/php7/cli/php.ini

ln --symbolic /etc/php7/bin/php /usr/bin/php

export USE_ZEND_ALLOC=0



Comments


  1. As a leading Top Mobile App Development Company in India, Appsinvo company is well known to design and build customized web and mobile app solutions for the clients. Complete integration of the mobile app and the website gives the businesses a boost not only in their growth but also in the revenue.
    Top Mobile App Development Company in Qatar

    ReplyDelete

Post a Comment

Popular posts from this blog

AWS Elasticache Memcached connection

https://docs.aws.amazon.com/AmazonElastiCache/latest/mem-ug/accessing-elasticache.html#access-from-outside-aws http://hourlyapps.blogspot.com/2010/06/examples-of-memcached-commands.html Access memcached https://docs.aws.amazon.com/AmazonElastiCache/latest/mem-ug/GettingStarted.AuthorizeAccess.html Zip include hidden file https://stackoverflow.com/questions/12493206/zip-including-hidden-files phpmemcachedadmin ~ phpMyAdmin or phpPgAdmin ... telnet mycachecluster.eaogs8.0001.usw2.cache.amazonaws.com 11211 stats items stats cachedump 27 100 https://docs.aws.amazon.com/AmazonElastiCache/latest/mem-ug/VPCs.EC.html https://lzone.de/cheat-sheet/memcached VPC ID Security Group ID (sg-...) Cluster: The identifier for the cluster memcached1 Creation Time: The time (UTC) when the cluster was created January 9, 2019 at 11:47:16 AM UTC+7 Configuration Endpoint: The configuration endpoint of the cluster memcached1.ahgofe.cfg.usw1.cache.amazonaws.com:11211 St...

Notes Windows 10 Virtualbox config, PHP Storm Japanese, custom PHP, Apache build, Postgresql

 cmd => Ctrl + Shift + Enter mklink "C:\Users\HauNT\Videos\host3" "C:\Windows\System32\drivers\etc\hosts" https://www.quora.com/How-to-create-a-router-in-php https://serverfault.com/questions/225155/virtualbox-how-to-set-up-networking-so-both-host-and-guest-can-access-internet 1 NAT + 1 host only config https://unix.stackexchange.com/questions/115464/how-to-properly-set-up-2-network-interfaces-in-centos-running-in-virtualbox DEVICE=eth0 TYPE=Ethernet #BOOTPROTO=dhcp BOOTPROTO=none #IPADDR=10.9.11.246 #PREFIX=24 #GATEWAY=10.9.11.1 #IPV4_FAILURE_FATAL=yes #HWADDR=08:00:27:CC:AC:AC ONBOOT=yes NAME="System eth0" [root@localhost www]# cat /etc/sysconfig/network-scripts/ifcfg-eth1 # Advanced Micro Devices, Inc. [AMD] 79c970 [PCnet32 LANCE] DEVICE=eth1 IPADDR=192.168.56.28 <= no eff => auto like DHCP #GATEWAY=192.168.56.1 #BOOTPROTO=dhcp BOOTPROTO=static <= no eff ONBOOT=yes HWADDR=08:00:27:b4:20:10 [root@localhost www]# ...

Rocket.Chat DB schema

_raix_push_notifications avatars.chunks avatars.files instances meteor_accounts_loginServiceConfiguration meteor_oauth_pendingCredentials meteor_oauth_pendingRequestTokens migrations rocketchat__trash rocketchat_cron_history rocketchat_custom_emoji rocketchat_custom_sounds rocketchat_import rocketchat_integration_history rocketchat_integrations rocketchat_livechat_custom_field rocketchat_livechat_department rocketchat_livechat_department_agents rocketchat_livechat_external_message rocketchat_livechat_inquiry rocketchat_livechat_office_hour rocketchat_livechat_page_visited rocketchat_livechat_trigger rocketchat_message rocketchat_oauth_apps rocketchat_oembed_cache rocketchat_permissions rocketchat_raw_imports rocketchat_reports rocketchat_roles rocketchat_room rocketchat_settings rocketchat_smarsh_history rocketchat_statistics rocketchat_subscription rocketchat_uploads system.indexes users usersSessions https://rocket.chat/docs/developer-guides/sc...