php-fpm : disabling a php extension for a specific pool - php

I have configured a new FPM pool (config file www.conf in pool.d), now let's say I want to disable mysql support for that specific pool ? Or maybe there is a way not to load that extension for that pool ?
I'm using debian 9 and here is how the file structure looks like this:
/etc/php/7.0/fpm$ tree
.
├── conf.d
│ ├── 10-mysqlnd.ini -> /etc/php/7.0/mods-available/mysqlnd.ini
│ ├── 10-opcache.ini -> /etc/php/7.0/mods-available/opcache.ini
│ ├── 10-pdo.ini -> /etc/php/7.0/mods-available/pdo.ini
│ ├── 20-calendar.ini -> /etc/php/7.0/mods-available/calendar.ini
│ ├── 20-ctype.ini -> /etc/php/7.0/mods-available/ctype.ini.ini
(...)
├── php-fpm.conf
├── php.ini
└── pool.d
├── forgewww.conf
└── www.conf
extension=thing.so can be found in files conf.d/<extension>.ini. Problem is all those extensions once configured seem common to all pools...
I've also tried to disable mysql extensions globally with phpdismod then append a line in www.conf with:
php_admin_value[extension] = mysqli.so
Which doesn't seems to work (the above doesn't enable mysqli for that pool)

You can't load different extension per-pool, the extensions are defined in an .ini file, loaded by master process. php-fpm master process forks into children, meaning that they share what's been loaded by the master process. You can't have a child load a different set of extensions after forking, or unload them. It probably is possible to develop a solution, but there's really no need for that seeing that you can solve your problem via different approach.
In order to achieve what you're after, simply set up entirely different php-fpm process on a different port / unix socket and load extensions you require, set up your pools and you're done. It's actually a lot less work than it sounds, it probably won't take you more than a few minutes.

Related

How to automate deployment of ngnix configuration on Amazon AWS?

i have a created project using symfony 5.
For hosting website i am using amazon AWS.
Amazon AWS instance is using nginx.
Everytime i deploy code using Elastic beanstalk i have to add following lines to the etc/nginx/nginx.conf file
location / {
try_files $uri $uri/ /index.php?$args;
}
if i don't add following configuration and don't restart nginx server then only page of my website is visible . Whenever i try to open another page of website excepts homepage i get following error :
404 Not Found
nginx/1.18.0
How can i automate deployment of the ngnix configuration whenever i upload code using elasticbeanstalk ?
If you want to modify your nginx configuration, you should modify your Configuration Files by extending ElasticBeanstalk as explained here
I will assume you are using Amazon Linux 2, if not the ElasticBeanstalk is working completely differently as documented here.
Elastic Beanstalk (using Amazon Linux 2) will automatically look for a .platform directory at the root of your zip file.
By adding .platform/nginx/conf.d/elasticbeanstalk/php-custom.conf with the following content, you should be good to go (assuming you are using the default configuration). Note that you could overwrite the nginx.conf by adding this file .platform/nginx/nginx.conf to your project, but since what you want to do is fairly simple, I would only add a file that will be automatically loaded by nginx.
location / {
try_files $uri $uri/ /index.php?$args;
}
So your project tree should look something like this.
project root
├── .platform
│   └── nginx
│   └── conf.d
│   └── elasticbeanstalk
│   └── php-custom.conf
└── your project files

Deploy Multiple Laravel Apps with a Single Domain

I have two Laravel applications with one domain. Let say the domain is mydomain.com.
I want those two applications can be accessed via the following urls:
mydomain.com/firstapp
mydomain.com/secondapp
To realize this, this is what I have done.
configured Apache so that the starting directory is /var/www/html/
<VirtualHost *:80>
DocumentRoot "/var/www/html/"
ServerName mydomain.com
</VirtualHost>
Then I put the first app source code in the /var/www/html/firstapp directory, and the second app in the /var/html/secondapp directory.
The directory structure became like this:
var
└── www
└── html
├── firstapp
│   ├── app
│   ├── bootstrap
│   ├── config
│   ├── database
│ ├── ...
│ ├── index.php
│ └── .htaccess
└── secondapp
├── app
├── bootstrap
├── config
├── database
├── ...
├── index.php
└── .htaccess
Finally, I moved the index.php and .htaccess from the corresponding public folder in the root directory of each Laravel app and modified the corresponding path in those index.php files.
So far, it is working as I expected, but I am worried about the security.
Can anyone explain to me the right way to do it.
Note: I am using Centos 7 in the server.

.user.ini for sendmail_path will not apply to subdirectories

I have confirmed the config
sendmail_path = xxxx
in .user.ini will not apply to subdirectories only the parent directly. ( the other configs will )
If I place another .user.ini in subfolder, it works. php.ini in subfolder will work as well.
That will lose the purpose of using .user.ini. for me in this case. May I ask is this PHP bug ?? and the possible reason of cause?
My environment is Linux with WHM, php version 5.6.
Given this structure:
.
└── a
├── a.php
├── b
│   ├── b.php
│   └── .user.ini <== [1]
└── .user.ini <== [2]
b.php will see settings from [1] merged with [2], where values in [2] replace those from [1]. a.php will see settings only from [2].
sendmail_path is defined as being PHP_INI_SYSTEM, meaning it can only be set in the system level settings file, e.g. php.ini.

Codeception Gherkin, defining the step implementation path

I’m new to php and codeception and I wanted to use Gherkin with Codeception, and I’ve already setup the bare minimum to make feature files run in Codeception. I now find myself trying to make a scalable structure and make use of the PageObject framework. I created a Steps Folder and I wanted my step implementations kept in that folder. By default running codecept run some.feature loads the class defined in the acceptance.suite.yml file.
Motivation: I want to be able keep my step implementations into it’s own separate folder
Given I have an acceptance.suite.yml file configuration of:
gherkin:
contexts:
default:
- AcceptanceTester
modules:
enabled:
- WebDriver:
url: https://www.google.com/
browser: chrome
- \Helper\Acceptance
And I have a codeception.yml file configuration of:
paths:
tests: tests
output: tests/_output
data: tests/_data
support: tests/_support
envs: tests/_envs
actor_suffix: Tester
extensions:
enabled:
- Codeception\Extension\RunFailed
And I have my Steps folder under _support:
How do I change the configuration to allow my step implementation to be
called from the Steps folder?
In the gherkin: section of the suite configuration, you need to list your steps classes organised under default:, role: and/or tag: sections. There are example configurations in the official documentation: Gherkin options.
Below is an example from a recent project (using Codeception 2.5.6):
file structure
/app/common
├── codeception.yml
├── tests
│   ├── acceptance.suite.yml
│ ├── _bootstrap.php
│ ├── _data
│ │ └── user.php
│ ├── _support
│ │ ├── AcceptanceTester.php
│ │ ├── Step
│ │ │ └── Acceptance
│ │ │ └── CuratorSteps.php
The layout above for the step class is the default one when generating step object using codecept generate:stepobject command like so:
$ /app/vendor/bin/codecept -c /app/common generate:stepobject acceptance CuratorSteps
acceptance.suite.yml:
# acceptance.suite.yml
namespace: common\tests
suite_namespace: common\tests\acceptance
bootstrap: false
actor: AcceptanceTester
modules:
enabled:
- PhpBrowser:
url: http://example.com/
gherkin:
contexts:
default:
- common\tests\AcceptanceTester
role:
curator:
- common\tests\Step\Acceptance\CuratorSteps
The documentation doesn't mention it, but I notice I have to list the full namespace of the step classes, otherwise I'll get "Step definition for ... not found in contexts" errors when running the tests and the gherkin:steps codecept command won't return the step definitions.
output
$ /app/vendor/bin/codecept -vvv -c /app/common gherkin:steps acceptance
Steps from role:curator context:
+--------------------------------------------------------------------+------------------------------------------------------------------------------------------+
| Step | Implementation |
+--------------------------------------------------------------------+------------------------------------------------------------------------------------------+
| I sign in as an admin | common\tests\Step\Acceptance\CuratorSteps::iSignInAsAnAdmin |
| I should see a :arg1 button | common\tests\Step\Acceptance\CuratorSteps::iShouldSeeAButton |
+--------------------------------------------------------------------+------------------------------------------------------------------------------------------+
Steps from default context:
+-------------------------------------+---------------------------------------------------------+
| Step | Implementation |
+-------------------------------------+---------------------------------------------------------+
| I take a screenshot with name :arg1 | common\tests\AcceptanceTester::itakeAScreenshotWithName |
+-------------------------------------+---------------------------------------------------------+

app.yaml apparently not redirecting correctly

I've been trying to set up a basic Wordpress site with Google App Engine's new PHP SDK, following these instructions.
From what I understand, app.yaml is where the process kicks off and should work similar to .htaccess (re routing).
Google instruct you to drop your wordpress files into a wordpress folder, so your directory structure looks like this:
.
├── app.yaml
├── cron.yaml
├── php.ini
└── wordpress
├── index.php
├── license.txt
├── readme.html
└── (etc)
So their template app.yaml should work, including the following lines:
- url: /wp-cron.php
script: wordpress/wp-cron.php
login: admin
- url: /xmlrpc.php
script: wordpress/xmlrpc.php
- url: /(.+)?/?
script: wordpress/index.php
But localhost:8080 gives me my app folder's directory structure, instead of the anticipated wordpress/index.php. I tried this as well:
- url: /.*
script: wordpress/index.php
Any ideas?
Note: I verified that wordpress/index.php exists, by the way.
GAE's dev_appserver will never list the directory structure. Sounds like you might be hitting some other web server running on your localhost?

Categories