PHP-FPM and php_admin_value in virtualhost

interfasys

Verified User
Joined
Oct 31, 2003
Messages
1,731
Location
Switzerland
I'ts minor, but I think this block code should be rewritten, because php_admin_value in a virtualhost has no effect on PHP-FPM.
Code:
|*if HAVE_SAFE_MODE="1"|
		php_admin_flag safe_mode |SAFE_MODE|
|*endif|
|*if CLI="1"|
		php_admin_flag engine |PHP|
		php_admin_value sendmail_path '/usr/sbin/sendmail -t -i -f |PHP_EMAIL|'
		|CLI_PHP_MAIL_LOG|
|*endif|
|*if OPEN_BASEDIR="ON"|
		php_admin_value open_basedir |OPEN_BASEDIR_PATH|
|*endif|

But it highlights a bigger problem with the templates which are getting too long winded because of the lack of nesting if statements.

How about keeping all the templates separate and having DA pick the right ones to generate the virtualhost?

There would be a common file with all the variables
Code:
|?DOCROOT=`HOME`/domains/`DOMAIN`/public_html|
|?REALDOCROOT=`HOME`/domains/`DOMAIN`/public_html|

|?OBDP1=|
|*if PHP1_RELEASE!="0.000000"|
|?OBDP1=:/usr/local/php`PHP1_RELEASE`/lib/php/|
|*endif|
|?OBDP2=|
|*if PHP2_RELEASE!="0.000000"|
|?OBDP2=:/usr/local/php`PHP2_RELEASE`/lib/php/|
|*endif|

|?OPEN_BASEDIR_PATH=`HOME`/:/tmp:/var/tmp:/usr/local/lib/php/`OBDP1``OBDP2`|

|?FASTCGI_OPENBASEDIR=|
|*if OPEN_BASEDIR_ENABLED="ON"|
|?FASTCGI_OPENBASEDIR=-d open_basedir="`OPEN_BASEDIR_PATH`"|
|*endif|

|?PHP_MAIL_LOG=|
|?CLI_PHP_MAIL_LOG=|
|*if PHP_MAIL_LOG_ENABLED="1"|
|?PHP_MAIL_LOG=-d mail.log="`HOME`/.php/php-mail.log"|
|?CLI_PHP_MAIL_LOG=php_admin_value mail.log `HOME`/.php/php-mail.log|
|*endif|

|?PHP_EMAIL=`USER`@`DOMAIN`|
|?FASTCGI_SENDMAIL_FROM=-d sendmail_from="`PHP_EMAIL`"|

|?ALLOW_OVERRIDE=AllowOverride AuthConfig FileInfo Indexes Limit Options=Indexes,Includes,IncludesNOEXEC,MultiViews,SymLinksIfOwnerMatch,FollowSymLinks,None|

and then a php-fpm.vhost.conf
Code:
<VirtualHost |IP|:|PORT_80| |MULTI_IP|>
|CUSTOM|
	ServerName www.|DOMAIN|
	ServerAlias www.|DOMAIN| |DOMAIN| |SERVER_ALIASES|
	ServerAdmin |ADMIN|
	DocumentRoot |DOCROOT|

	|USECANONICALNAME|

	CustomLog /var/log/httpd/domains/|DOMAIN|.bytes bytes
	CustomLog /var/log/httpd/domains/|DOMAIN|.log combined
	ErrorLog /var/log/httpd/domains/|DOMAIN|.error.log

	|*if SUSPENDED_REASON|
	<IfModule mod_env.c>
		SetEnv reason |SUSPENDED_REASON|
	</IfModule>
	|*endif|

|*if HAVE_PHP1_FPM="1"|
	<FilesMatch "\.(inc|php|phtml|phps|php|PHP1_RELEASE|)$">
		AddHandler "proxy:fcgi://php-fpm|PHP1_RELEASE|.|USER|/" .inc .php .phtml .php|PHP1_RELEASE|
	</FilesMatch>
|*endif|

|*if HAVE_PHP2_FPM="1"|
	<FilesMatch "\.(inc|php|phtml|phps|php|PHP2_RELEASE|)$">
		AddHandler "proxy:fcgi://php-fpm|PHP2_RELEASE|.|USER|/" .php|PHP2_RELEASE|
	</FilesMatch>
|*endif|

|HANDLERS|
|MIMETYPES|

</VirtualHost>

same for the rest of the templates: php-cli.vhost.conf, etc.
 
Last edited:
As there are many mix-and-match php combinations, it might be tricky to do it that way, but I would agree that they're getting a little long.
Perhaps a future versions could replace chucks with other tokens/includes, but they'll likely still need to all be based one top-level template.

In any case, your original point about php_admin_value, it shouldn't be there if mod_php isn't set anywhere in the custombuild/options.conf.
If php_admin_value is showing up in the httpd.conf and you're not expecting it.. if the options.conf appears to be correct, let us know your options.conf settings so we can test with them.
I just set php1 and php2 to php-fpm, and no php_admin_value flags showed up.

DA also does things like sets OPEN_BASEDIR=OFF internally if CLI=0, but that's only confusing due to the backwards compatibility reasons, for back in the day when there were no other php types.
The php-fpm, suPhp, etc.. still support open basedir, just not with that token.
The actual global open_basedir token for all types is OPEN_BASEDIR_ENABLED=ON/OFF.

John
 
As there are many mix-and-match php combinations, it might be tricky to do it that way, but I would agree that they're getting a little long.
Perhaps a future versions could replace chucks with other tokens/includes, but they'll likely still need to all be based one top-level template.

In any case, your original point about php_admin_value, it shouldn't be there if mod_php isn't set anywhere in the custombuild/options.conf.
If php_admin_value is showing up in the httpd.conf and you're not expecting it.. if the options.conf appears to be correct, let us know your options.conf settings so we can test with them.
I just set php1 and php2 to php-fpm, and no php_admin_value flags showed up.

DA also does things like sets OPEN_BASEDIR=OFF internally if CLI=0, but that's only confusing due to the backwards compatibility reasons, for back in the day when there were no other php types.
The php-fpm, suPhp, etc.. still support open basedir, just not with that token.
The actual global open_basedir token for all types is OPEN_BASEDIR_ENABLED=ON/OFF.

John
You are correct, I should have checked the end result...All my <directory> directives were empty, so the hidden options are doing their job. I ended up removing whole blocks from the template for more clarity.
 
Back
Top