Skip to content
Snippets Groups Projects

Compare revisions

Changes are shown as if the source revision was being merged into the target revision. Learn more about comparing revisions.

Source

Select target project
No results found

Target

Select target project
  • ansible/roles/php
  • ericzillmann/php
2 results
Show changes
Commits on Source (89)
Showing with 1162 additions and 695 deletions
php_install_redis: true ---
php_version: 7.0
php_version_main: 7
php_fpm: yes
php_fpm_socket: no
php_install_redis: yes
php_hold_version: no
php_repositories: [] php_repositories: []
php_packages: php_packages:
- php-apc - php-apc
- php-imagick
- php-pear - php-pear
- php-soap - php-soap
- php-uploadprogress
- php5 - php5
- php5-cgi - php5-cgi
- php5-cli
- php5-curl - php5-curl
- php5-dev - php5-dev
- php5-fpm - php5-fpm
- php5-gd - php5-gd
- php5-imagick
- php5-imap - php5-imap
- php5-mcrypt - php5-mcrypt
- php5-mysql - php5-mysql
- php5-xdebug - php5-xdebug
- php5-xmlrpc - php5-xmlrpc
- imagemagick
php_base_dir: 'php5' php_base_dir: php5
php_conf_dir: 'conf.d' php_conf_dir: conf.d
php_allow_call_time_pass_reference: 'on' php_allow_call_time_pass_reference: 'on'
php_browscap: false php_browscap: no
php_date_timezone: 'Europe/Berlin' php_date_timezone: Europe/Berlin
php_display_errors: 'Off' php_display_errors: 'Off'
php_display_startup_errors: 'Off' php_display_startup_errors: 'Off'
php_error_reporting: 'E_ALL & ~E_NOTICE' php_error_reporting: E_ALL & ~E_NOTICE
php_expose_php: 'Off' php_expose_php: 'Off'
php_filter_default: 'unsafe_raw' php_filter_default: unsafe_raw
php_html_errors: 'Off' php_html_errors: 'Off'
php_log_errors: 'On' php_log_errors: 'On'
php_magic_quotes_gpc: 'On' php_magic_quotes_gpc: 'On'
php_max_execution_time: '30' php_max_execution_time: 30
php_max_input_vars: '1000' php_max_file_uploads: 20
php_memory_limit: '32M' php_max_input_time: 60
php_needs_oci8: false php_max_input_vars: 1000
php_post_max_size: '32M' php_memory_limit: 32M
php_needs_mcrypt: no
php_needs_msodbc: no
php_needs_oci8: no
php_output_buffering: 4096
php_post_max_size: 32M
php_register_globals: 'Off' php_register_globals: 'Off'
php_register_long_arrays: 'On' php_register_long_arrays: 'On'
php_sendmail_path: '/usr/sbin/sendmail -t -i' php_sendmail_path: /usr/sbin/sendmail -t -i
php_session_cache_expire: '180' php_session_cache_expire: 180
php_session_cookie_lifetime: '0' php_session_cookie_lifetime: 0
php_session_gc_divisor: '1000' php_session_gc_divisor: 1000
php_session_gc_maxlifetime: '1440' php_session_gc_maxlifetime: 1440
php_short_open_tag: 'Off' php_short_open_tag: 'Off'
php_upload_max_filesize: '2M' php_upload_max_filesize: 2M
php_zend_assertions: '-1' php_zend_assertions: -1
# PHP FPM
php_fpm_max_children: 10
php_fpm_start_servers: 4
php_fpm_min_spare_servers: 2
php_fpm_max_spare_servers: 6
php_fpm_max_requests: 2000
# apc.ini # apc.ini
apc_rfc1867: '1' apc_rfc1867: 1
apc_shm_size: '256M' apc_shm_size: 32M
apc_shm_segments: '1' apc_shm_segments: 1
apc_num_files_hint: '0' apc_num_files_hint: 0
apc_ttl: '7200' apc_ttl: 7200
apc_user_ttl: '7200' apc_user_ttl: 7200
apc_gc_ttl: '3600' apc_gc_ttl: 3600
# opcache.ini # opcache.ini
opcache_memory_consumption: '128' opcache_memory_consumption: 128
opcache_max_accelerated_files: '7963' opcache_max_accelerated_files: 7963
opcache_revalidate_freq: '30' opcache_revalidate_freq: 30
opcache_interned_strings_buffer: '16' opcache_interned_strings_buffer: 16
# php 5.3 # php 5.3
php53: php53:
libraries: libraries:
- file: 'libgd.so.2.0.0' - file: libgd.so.2.0.0
link: 'libgd.so.2' link: libgd.so.2
- file: 'liblcms.so.1.0.19' - file: liblcms.so.1.0.19
link: 'liblcms.so.1' link: liblcms.so.1
- file: 'libMagickCore.so.4.0.1' - file: libMagickCore.so.4.0.1
link: 'libMagickCore.so.4' link: libMagickCore.so.4
- file: 'libMagickWand.so.4.0.1' - file: libMagickWand.so.4.0.1
link: 'libMagickWand.so.4' link: libMagickWand.so.4
- file: 'libt1.so.5.1.2' - file: libt1.so.5.1.2
link: 'libt1.so.5' link: libt1.so.5
liblinks: liblinks:
- src: '/lib/x86_64-linux-gnu/libpng12.so.0' - src: /lib/x86_64-linux-gnu/libpng12.so.0
link: 'libpng12.so.0' link: libpng12.so.0
modules: modules:
- 'apc' - apc
- 'curl' - curl
- 'gd' - gd
- 'imagick' - imagick
- 'imap' - imap
#- 'json' # - json
- 'mcrypt' - mcrypt
#- 'memcached' # - memcached
- 'mysql' - mysql
- 'mysqli' - mysqli
- 'pdo_mysql' - pdo_mysql
#- 'readline' # - readline
- 'redis' - redis
- 'xmlrpc' - xmlrpc
extdir: '/usr/local/lib/php/extensions/no-debug-non-zts-20090626' extdir: /usr/local/lib/php/extensions/no-debug-non-zts-20090626
libdir: '/usr/lib/x86_64-linux-gnu' libdir: /usr/lib/x86_64-linux-gnu
...@@ -22,7 +22,7 @@ ...@@ -22,7 +22,7 @@
*/ */
$VERSION='$Id: apc.php 307048 2011-01-03 23:53:17Z kalle $'; $VERSION='$Id$';
////////// READ OPTIONAL CONFIGURATION FILE //////////// ////////// READ OPTIONAL CONFIGURATION FILE ////////////
if (file_exists("apc.conf.php")) include("apc.conf.php"); if (file_exists("apc.conf.php")) include("apc.conf.php");
...@@ -30,10 +30,10 @@ if (file_exists("apc.conf.php")) include("apc.conf.php"); ...@@ -30,10 +30,10 @@ if (file_exists("apc.conf.php")) include("apc.conf.php");
////////// BEGIN OF DEFAULT CONFIG AREA /////////////////////////////////////////////////////////// ////////// BEGIN OF DEFAULT CONFIG AREA ///////////////////////////////////////////////////////////
defaults('USE_AUTHENTICATION',1); // Use (internal) authentication - best choice if defaults('USE_AUTHENTICATION',1); // Use (internal) authentication - best choice if
// no other authentication is available // no other authentication is available
// If set to 0: // If set to 0:
// There will be no further authentication. You // There will be no further authentication. You
// will have to handle this by yourself! // will have to handle this by yourself!
// If set to 1: // If set to 1:
// You need to change ADMIN_PASSWORD to make // You need to change ADMIN_PASSWORD to make
...@@ -41,7 +41,7 @@ defaults('USE_AUTHENTICATION',1); // Use (internal) authentication - best choi ...@@ -41,7 +41,7 @@ defaults('USE_AUTHENTICATION',1); // Use (internal) authentication - best choi
defaults('ADMIN_USERNAME','apc'); // Admin Username defaults('ADMIN_USERNAME','apc'); // Admin Username
defaults('ADMIN_PASSWORD','password'); // Admin Password - CHANGE THIS TO ENABLE!!! defaults('ADMIN_PASSWORD','password'); // Admin Password - CHANGE THIS TO ENABLE!!!
// (beckerr) I'm using a clear text password here, because I've no good idea how to let // (beckerr) I'm using a clear text password here, because I've no good idea how to let
// users generate a md5 or crypt password in a easy way to fill it in above // users generate a md5 or crypt password in a easy way to fill it in above
//defaults('DATE_FORMAT', "d.m.Y H:i:s"); // German //defaults('DATE_FORMAT', "d.m.Y H:i:s"); // German
...@@ -61,7 +61,7 @@ function defaults($d,$v) { ...@@ -61,7 +61,7 @@ function defaults($d,$v) {
// rewrite $PHP_SELF to block XSS attacks // rewrite $PHP_SELF to block XSS attacks
// //
$PHP_SELF= isset($_SERVER['PHP_SELF']) ? htmlentities(strip_tags($_SERVER['PHP_SELF'],''), ENT_QUOTES, 'UTF-8') : ''; $PHP_SELF= isset($_SERVER['PHP_SELF']) ? htmlentities(strip_tags($_SERVER['PHP_SELF'],''), ENT_QUOTES, 'UTF-8') : ;
$time = time(); $time = time();
$host = php_uname('n'); $host = php_uname('n');
if($host) { $host = '('.$host.')'; } if($host) { $host = '('.$host.')'; }
...@@ -71,10 +71,8 @@ if (isset($_SERVER['SERVER_ADDR'])) { ...@@ -71,10 +71,8 @@ if (isset($_SERVER['SERVER_ADDR'])) {
// operation constants // operation constants
define('OB_HOST_STATS',1); define('OB_HOST_STATS',1);
define('OB_SYS_CACHE',2); define('OB_USER_CACHE',2);
define('OB_USER_CACHE',3); define('OB_VERSION_CHECK',3);
define('OB_SYS_CACHE_DIR',4);
define('OB_VERSION_CHECK',9);
// check validity of input variables // check validity of input variables
$vardom=array( $vardom=array(
...@@ -91,12 +89,9 @@ $vardom=array( ...@@ -91,12 +89,9 @@ $vardom=array(
'SORT1' => '/^[AHSMCDTZ]$/', // first sort key 'SORT1' => '/^[AHSMCDTZ]$/', // first sort key
'SORT2' => '/^[DA]$/', // second sort key 'SORT2' => '/^[DA]$/', // second sort key
'AGGR' => '/^\d+$/', // aggregation by dir level 'AGGR' => '/^\d+$/', // aggregation by dir level
'SEARCH' => '~^[a-zA-Z0-1/_.-]*$~' // aggregation by dir level 'SEARCH' => '~^[a-zA-Z0-9/_.-]*$~' // aggregation by dir level
); );
// default cache mode
$cache_mode='opcode';
// cache scope // cache scope
$scope_list=array( $scope_list=array(
'A' => 'cache_list', 'A' => 'cache_list',
...@@ -169,34 +164,30 @@ if (!USE_AUTHENTICATION) { ...@@ -169,34 +164,30 @@ if (!USE_AUTHENTICATION) {
</body></html> </body></html>
EOB; EOB;
exit; exit;
} else { } else {
$AUTHENTICATED=1; $AUTHENTICATED=1;
} }
} }
} }
// select cache mode
if ($AUTHENTICATED && $MYREQUEST['OB'] == OB_USER_CACHE) {
$cache_mode='user';
}
// clear cache // clear cache
if ($AUTHENTICATED && isset($MYREQUEST['CC']) && $MYREQUEST['CC']) { if ($AUTHENTICATED && isset($MYREQUEST['CC']) && $MYREQUEST['CC']) {
apc_clear_cache($cache_mode); apcu_clear_cache();
} }
if ($AUTHENTICATED && !empty($MYREQUEST['DU'])) { if ($AUTHENTICATED && !empty($MYREQUEST['DU'])) {
apc_delete($MYREQUEST['DU']); apcu_delete($MYREQUEST['DU']);
} }
if(!function_exists('apc_cache_info') || !($cache=@apc_cache_info($cache_mode))) { if(!function_exists('apcu_cache_info')) {
echo "No cache info available. APC does not appear to be running."; echo "No cache info available. APC does not appear to be running.";
exit; exit;
} }
$cache_user = apc_cache_info('user', 1); $cache = apcu_cache_info();
$mem=apc_sma_info();
if(!$cache['num_hits']) { $cache['num_hits']=1; $time++; } // Avoid division by 0 errors on a cache clear $mem=apcu_sma_info();
// don't cache this page // don't cache this page
// //
...@@ -241,7 +232,7 @@ if (isset($MYREQUEST['IMG'])) ...@@ -241,7 +232,7 @@ if (isset($MYREQUEST['IMG']))
$r=$diameter/2; $r=$diameter/2;
$w=deg2rad((360+$start+($end-$start)/2)%360); $w=deg2rad((360+$start+($end-$start)/2)%360);
if (function_exists("imagefilledarc")) { if (function_exists("imagefilledarc")) {
// exists only if GD 2.0.1 is avaliable // exists only if GD 2.0.1 is avaliable
imagefilledarc($im, $centerX+1, $centerY+1, $diameter, $diameter, $start, $end, $color1, IMG_ARC_PIE); imagefilledarc($im, $centerX+1, $centerY+1, $diameter, $diameter, $start, $end, $color1, IMG_ARC_PIE);
...@@ -258,13 +249,13 @@ if (isset($MYREQUEST['IMG'])) ...@@ -258,13 +249,13 @@ if (isset($MYREQUEST['IMG']))
if ($text) { if ($text) {
if ($placeindex>0) { if ($placeindex>0) {
imageline($im,$centerX + $r*cos($w)/2, $centerY + $r*sin($w)/2,$diameter, $placeindex*12,$color1); imageline($im,$centerX + $r*cos($w)/2, $centerY + $r*sin($w)/2,$diameter, $placeindex*12,$color1);
imagestring($im,4,$diameter, $placeindex*12,$text,$color1); imagestring($im,4,$diameter, $placeindex*12,$text,$color1);
} else { } else {
imagestring($im,4,$centerX + $r*cos($w)/2, $centerY + $r*sin($w)/2,$text,$color1); imagestring($im,4,$centerX + $r*cos($w)/2, $centerY + $r*sin($w)/2,$text,$color1);
} }
} }
} }
function text_arc($im, $centerX, $centerY, $diameter, $start, $end, $color1,$text,$placeindex=0) { function text_arc($im, $centerX, $centerY, $diameter, $start, $end, $color1,$text,$placeindex=0) {
$r=$diameter/2; $r=$diameter/2;
...@@ -272,13 +263,13 @@ if (isset($MYREQUEST['IMG'])) ...@@ -272,13 +263,13 @@ if (isset($MYREQUEST['IMG']))
if ($placeindex>0) { if ($placeindex>0) {
imageline($im,$centerX + $r*cos($w)/2, $centerY + $r*sin($w)/2,$diameter, $placeindex*12,$color1); imageline($im,$centerX + $r*cos($w)/2, $centerY + $r*sin($w)/2,$diameter, $placeindex*12,$color1);
imagestring($im,4,$diameter, $placeindex*12,$text,$color1); imagestring($im,4,$diameter, $placeindex*12,$text,$color1);
} else { } else {
imagestring($im,4,$centerX + $r*cos($w)/2, $centerY + $r*sin($w)/2,$text,$color1); imagestring($im,4,$centerX + $r*cos($w)/2, $centerY + $r*sin($w)/2,$text,$color1);
} }
} }
function fill_box($im, $x, $y, $w, $h, $color1, $color2,$text='',$placeindex='') { function fill_box($im, $x, $y, $w, $h, $color1, $color2,$text='',$placeindex='') {
global $col_black; global $col_black;
$x1=$x+$w-1; $x1=$x+$w-1;
...@@ -290,15 +281,15 @@ if (isset($MYREQUEST['IMG'])) ...@@ -290,15 +281,15 @@ if (isset($MYREQUEST['IMG']))
imagerectangle($im, $x, $y1, $x1, $y, $color1); imagerectangle($im, $x, $y1, $x1, $y, $color1);
if ($text) { if ($text) {
if ($placeindex>0) { if ($placeindex>0) {
if ($placeindex<16) if ($placeindex<16)
{ {
$px=5; $px=5;
$py=$placeindex*12+6; $py=$placeindex*12+6;
imagefilledrectangle($im, $px+90, $py+3, $px+90-4, $py-3, $color2); imagefilledrectangle($im, $px+90, $py+3, $px+90-4, $py-3, $color2);
imageline($im,$x,$y+$h/2,$px+90,$py,$color2); imageline($im,$x,$y+$h/2,$px+90,$py,$color2);
imagestring($im,2,$px,$py-6,$text,$color1); imagestring($im,2,$px,$py-6,$text,$color1);
} else { } else {
if ($placeindex<31) { if ($placeindex<31) {
$px=$x+40*2; $px=$x+40*2;
...@@ -309,7 +300,7 @@ if (isset($MYREQUEST['IMG'])) ...@@ -309,7 +300,7 @@ if (isset($MYREQUEST['IMG']))
} }
imagefilledrectangle($im, $px, $py+3, $px-4, $py-3, $color2); imagefilledrectangle($im, $px, $py+3, $px-4, $py-3, $color2);
imageline($im,$x+$w,$y+$h/2,$px,$py,$color2); imageline($im,$x+$w,$y+$h/2,$px,$py,$color2);
imagestring($im,2,$px+2,$py-6,$text,$color1); imagestring($im,2,$px+2,$py-6,$text,$color1);
} }
} else { } else {
imagestring($im,4,$x+5,$y1-16,$text,$color1); imagestring($im,4,$x+5,$y1-16,$text,$color1);
...@@ -331,7 +322,7 @@ if (isset($MYREQUEST['IMG'])) ...@@ -331,7 +322,7 @@ if (isset($MYREQUEST['IMG']))
imagecolortransparent($image,$col_white); imagecolortransparent($image,$col_white);
switch ($MYREQUEST['IMG']) { switch ($MYREQUEST['IMG']) {
case 1: case 1:
$s=$mem['num_seg']*$mem['seg_size']; $s=$mem['num_seg']*$mem['seg_size'];
$a=$mem['avail_mem']; $a=$mem['avail_mem'];
...@@ -342,7 +333,7 @@ if (isset($MYREQUEST['IMG'])) ...@@ -342,7 +333,7 @@ if (isset($MYREQUEST['IMG']))
// would expect because we try to visualize any memory fragmentation as well. // would expect because we try to visualize any memory fragmentation as well.
$angle_from = 0; $angle_from = 0;
$string_placement=array(); $string_placement=array();
for($i=0; $i<$mem['num_seg']; $i++) { for($i=0; $i<$mem['num_seg']; $i++) {
$ptr = 0; $ptr = 0;
$free = $mem['block_lists'][$i]; $free = $mem['block_lists'][$i];
uasort($free, 'block_sort'); uasort($free, 'block_sort');
...@@ -369,7 +360,7 @@ if (isset($MYREQUEST['IMG'])) ...@@ -369,7 +360,7 @@ if (isset($MYREQUEST['IMG']))
$angle_from = $angle_to; $angle_from = $angle_to;
$ptr = $block['offset']+$block['size']; $ptr = $block['offset']+$block['size'];
} }
if ($ptr < $mem['seg_size']) { // memory at the end if ($ptr < $mem['seg_size']) { // memory at the end
$angle_to = $angle_from + ($mem['seg_size'] - $ptr)/$s; $angle_to = $angle_from + ($mem['seg_size'] - $ptr)/$s;
if(($angle_to+$fuzz)>1) $angle_to = 1; if(($angle_to+$fuzz)>1) $angle_to = 1;
fill_arc($image,$x,$y,$size,$angle_from*360,$angle_to*360,$col_black,$col_red); fill_arc($image,$x,$y,$size,$angle_from*360,$angle_to*360,$col_black,$col_red);
...@@ -382,15 +373,15 @@ if (isset($MYREQUEST['IMG'])) ...@@ -382,15 +373,15 @@ if (isset($MYREQUEST['IMG']))
text_arc($image,$x,$y,$size,$angle[0]*360,$angle[1]*360,$col_black,bsize($s*($angle[1]-$angle[0]))); text_arc($image,$x,$y,$size,$angle[0]*360,$angle[1]*360,$col_black,bsize($s*($angle[1]-$angle[0])));
} }
break; break;
case 2: case 2:
$s=$cache['num_hits']+$cache['num_misses']; $s=$cache['num_hits']+$cache['num_misses'];
$a=$cache['num_hits']; $a=$cache['num_hits'];
fill_box($image, 30,$size,50,-$a*($size-21)/$s,$col_black,$col_green,sprintf("%.1f%%",$cache['num_hits']*100/$s)); fill_box($image, 30,$size,50,$s ? (-$a*($size-21)/$s) : 0,$col_black,$col_green,sprintf("%.1f%%",$s ? $cache['num_hits']*100/$s : 0));
fill_box($image,130,$size,50,-max(4,($s-$a)*($size-21)/$s),$col_black,$col_red,sprintf("%.1f%%",$cache['num_misses']*100/$s)); fill_box($image,130,$size,50,$s ? -max(4,($s-$a)*($size-21)/$s) : 0,$col_black,$col_red,sprintf("%.1f%%",$s ? $cache['num_misses']*100/$s : 0));
break; break;
case 3: case 3:
$s=$mem['num_seg']*$mem['seg_size']; $s=$mem['num_seg']*$mem['seg_size'];
$a=$mem['avail_mem']; $a=$mem['avail_mem'];
...@@ -400,7 +391,7 @@ if (isset($MYREQUEST['IMG'])) ...@@ -400,7 +391,7 @@ if (isset($MYREQUEST['IMG']))
// This block of code creates the bar chart. It is a lot more complex than you // This block of code creates the bar chart. It is a lot more complex than you
// would expect because we try to visualize any memory fragmentation as well. // would expect because we try to visualize any memory fragmentation as well.
for($i=0; $i<$mem['num_seg']; $i++) { for($i=0; $i<$mem['num_seg']; $i++) {
$ptr = 0; $ptr = 0;
$free = $mem['block_lists'][$i]; $free = $mem['block_lists'][$i];
uasort($free, 'block_sort'); uasort($free, 'block_sort');
...@@ -423,7 +414,7 @@ if (isset($MYREQUEST['IMG'])) ...@@ -423,7 +414,7 @@ if (isset($MYREQUEST['IMG']))
$y+=$h; $y+=$h;
$ptr = $block['offset']+$block['size']; $ptr = $block['offset']+$block['size'];
} }
if ($ptr < $mem['seg_size']) { // memory at the end if ($ptr < $mem['seg_size']) { // memory at the end
$h = (GRAPH_SIZE-5) * ($mem['seg_size'] - $ptr) / $s; $h = (GRAPH_SIZE-5) * ($mem['seg_size'] - $ptr) / $s;
if ($h > 0) { if ($h > 0) {
fill_box($image,$x,$y,50,$h,$col_black,$col_red,bsize($mem['seg_size']-$ptr),$j++); fill_box($image,$x,$y,50,$h,$col_black,$col_red,bsize($mem['seg_size']-$ptr),$j++);
...@@ -431,15 +422,16 @@ if (isset($MYREQUEST['IMG'])) ...@@ -431,15 +422,16 @@ if (isset($MYREQUEST['IMG']))
} }
} }
break; break;
case 4:
$s=$cache['num_hits']+$cache['num_misses']; case 4:
$a=$cache['num_hits']; $s=$cache['num_hits']+$cache['num_misses'];
$a=$cache['num_hits'];
fill_box($image, 30,$size,50,-$a*($size-21)/$s,$col_black,$col_green,sprintf("%.1f%%",$cache['num_hits']*100/$s));
fill_box($image,130,$size,50,-max(4,($s-$a)*($size-21)/$s),$col_black,$col_red,sprintf("%.1f%%",$cache['num_misses']*100/$s)); fill_box($image, 30,$size,50,$s ? -$a*($size-21)/$s : 0,$col_black,$col_green,sprintf("%.1f%%", $s ? $cache['num_hits']*100/$s : 0));
fill_box($image,130,$size,50,$s ? -max(4,($s-$a)*($size-21)/$s) : 0,$col_black,$col_red,sprintf("%.1f%%", $s ? $cache['num_misses']*100/$s : 0));
break; break;
} }
header("Content-type: image/png"); header("Content-type: image/png");
imagepng($image); imagepng($image);
exit; exit;
...@@ -458,15 +450,15 @@ function bsize($s) { ...@@ -458,15 +450,15 @@ function bsize($s) {
// sortable table header in "scripts for this host" view // sortable table header in "scripts for this host" view
function sortheader($key,$name,$extra='') { function sortheader($key,$name,$extra='') {
global $MYREQUEST, $MY_SELF_WO_SORT; global $MYREQUEST, $MY_SELF_WO_SORT;
if ($MYREQUEST['SORT1']==$key) { if ($MYREQUEST['SORT1']==$key) {
$MYREQUEST['SORT2'] = $MYREQUEST['SORT2']=='A' ? 'D' : 'A'; $MYREQUEST['SORT2'] = $MYREQUEST['SORT2']=='A' ? 'D' : A;
} }
return "<a class=sortable href=\"$MY_SELF_WO_SORT$extra&SORT1=$key&SORT2=".$MYREQUEST['SORT2']."\">$name</a>"; return "<a class=sortable href=\"$MY_SELF_WO_SORT$extra&SORT1=$key&SORT2=".$MYREQUEST['SORT2']."\">$name</a>";
} }
// create menu entry // create menu entry
function menu_entry($ob,$title) { function menu_entry($ob,$title) {
global $MYREQUEST,$MY_SELF; global $MYREQUEST,$MY_SELF;
if ($MYREQUEST['OB']!=$ob) { if ($MYREQUEST['OB']!=$ob) {
...@@ -474,7 +466,7 @@ function menu_entry($ob,$title) { ...@@ -474,7 +466,7 @@ function menu_entry($ob,$title) {
} else if (empty($MYREQUEST['SH'])) { } else if (empty($MYREQUEST['SH'])) {
return "<li><span class=active>$title</span></li>"; return "<li><span class=active>$title</span></li>";
} else { } else {
return "<li><a class=\"child_active\" href=\"$MY_SELF&OB=$ob\">$title</a></li>"; return "<li><a class=\"child_active\" href=\"$MY_SELF&OB=$ob\">$title</a></li>";
} }
} }
...@@ -514,7 +506,7 @@ function block_sort($array1, $array2) ...@@ -514,7 +506,7 @@ function block_sort($array1, $array2)
?> ?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html> <html>
<head><title>APC INFO <?php echo $host ?></title> <head><title>APCu INFO <?php echo $host ?></title>
<style><!-- <style><!--
body { background:white; font-size:100.01%; margin:0; padding:0; } body { background:white; font-size:100.01%; margin:0; padding:0; }
body,p,td,th,input,submit { font-size:0.8em;font-family:arial,helvetica,sans-serif; } body,p,td,th,input,submit { font-size:0.8em;font-family:arial,helvetica,sans-serif; }
...@@ -626,8 +618,8 @@ ol.menu a:hover { ...@@ -626,8 +618,8 @@ ol.menu a:hover {
background:rgb(193,193,244); background:rgb(193,193,244);
text-decoration:none; text-decoration:none;
} }
div.info { div.info {
background:rgb(204,204,204); background:rgb(204,204,204);
border:solid rgb(204,204,204) 1px; border:solid rgb(204,204,204) 1px;
...@@ -700,7 +692,7 @@ div.authneeded { ...@@ -700,7 +692,7 @@ div.authneeded {
padding:2em; padding:2em;
text-align:center; text-align:center;
} }
input { input {
background:rgb(153,153,204); background:rgb(153,153,204);
border:solid rgb(102,102,153) 2px; border:solid rgb(102,102,153) 2px;
...@@ -715,35 +707,29 @@ input { ...@@ -715,35 +707,29 @@ input {
<body> <body>
<div class="head"> <div class="head">
<h1 class="apc"> <h1 class="apc">
<div class="logo"><span class="logo"><a href="http://pecl.php.net/package/APC">APC</a></span></div> <div class="logo"><span class="logo"><a href="http://pecl.php.net/package/APCu">APCu</a></span></div>
<div class="nameinfo">Opcode Cache</div> <div class="nameinfo">User Cache</div>
</h1> </h1>
<div class="login"> <div class="login">
<?php put_login_link(); ?> <?php put_login_link(); ?>
</div> </div>
<hr class="apc"> <hr class="apc">
</div> </div>
<?php
<?php
// Display main Menu // Display main Menu
echo <<<EOB echo <<<EOB
<ol class=menu> <ol class=menu>
<li><a href="$MY_SELF&OB={$MYREQUEST['OB']}&SH={$MYREQUEST['SH']}">Refresh Data</a></li> <li><a href="$MY_SELF&OB={$MYREQUEST['OB']}&SH={$MYREQUEST['SH']}">Refresh Data</a></li>
EOB; EOB;
echo echo
menu_entry(1,'View Host Stats'), menu_entry(OB_HOST_STATS,'View Host Stats'),
menu_entry(2,'System Cache Entries'); menu_entry(OB_USER_CACHE,'User Cache Entries'),
if ($AUTHENTICATED) { menu_entry(OB_VERSION_CHECK,'Version Check');
echo menu_entry(4,'Per-Directory Entries');
}
echo
menu_entry(3,'User Cache Entries'),
menu_entry(9,'Version Check');
if ($AUTHENTICATED) { if ($AUTHENTICATED) {
echo <<<EOB echo <<<EOB
<li><a class="aright" href="$MY_SELF&CC=1&OB={$MYREQUEST['OB']}" onClick="javascript:return confirm('Are you sure?');">Clear $cache_mode Cache</a></li> <li><a class="aright" href="$MY_SELF&CC=1&OB={$MYREQUEST['OB']}" onClick="javascript:return confirm('Are you sure?');">Clear Cache</a></li>
EOB; EOB;
} }
echo <<<EOB echo <<<EOB
...@@ -756,14 +742,9 @@ echo <<<EOB ...@@ -756,14 +742,9 @@ echo <<<EOB
<div class=content> <div class=content>
EOB; EOB;
// MAIN SWITCH STATEMENT // MAIN SWITCH STATEMENT
switch ($MYREQUEST['OB']) { switch ($MYREQUEST['OB']) {
// ----------------------------------------------- // -----------------------------------------------
// Host Stats // Host Stats
// ----------------------------------------------- // -----------------------------------------------
...@@ -772,77 +753,58 @@ case OB_HOST_STATS: ...@@ -772,77 +753,58 @@ case OB_HOST_STATS:
$mem_avail= $mem['avail_mem']; $mem_avail= $mem['avail_mem'];
$mem_used = $mem_size-$mem_avail; $mem_used = $mem_size-$mem_avail;
$seg_size = bsize($mem['seg_size']); $seg_size = bsize($mem['seg_size']);
$req_rate = sprintf("%.2f",($cache['num_hits']+$cache['num_misses'])/($time-$cache['start_time'])); $req_rate_user = sprintf("%.2f", $cache['num_hits'] ? (($cache['num_hits']+$cache['num_misses'])/($time-$cache['start_time'])) : 0);
$hit_rate = sprintf("%.2f",($cache['num_hits'])/($time-$cache['start_time'])); $hit_rate_user = sprintf("%.2f", $cache['num_hits'] ? (($cache['num_hits'])/($time-$cache['start_time'])) : 0);
$miss_rate = sprintf("%.2f",($cache['num_misses'])/($time-$cache['start_time'])); $miss_rate_user = sprintf("%.2f", $cache['num_misses'] ? (($cache['num_misses'])/($time-$cache['start_time'])) : 0);
$insert_rate = sprintf("%.2f",($cache['num_inserts'])/($time-$cache['start_time'])); $insert_rate_user = sprintf("%.2f", $cache['num_inserts'] ? (($cache['num_inserts'])/($time-$cache['start_time'])) : 0);
$req_rate_user = sprintf("%.2f",($cache_user['num_hits']+$cache_user['num_misses'])/($time-$cache_user['start_time'])); $apcversion = phpversion('apcu');
$hit_rate_user = sprintf("%.2f",($cache_user['num_hits'])/($time-$cache_user['start_time']));
$miss_rate_user = sprintf("%.2f",($cache_user['num_misses'])/($time-$cache_user['start_time']));
$insert_rate_user = sprintf("%.2f",($cache_user['num_inserts'])/($time-$cache_user['start_time']));
$apcversion = phpversion('apc');
$phpversion = phpversion(); $phpversion = phpversion();
$number_files = $cache['num_entries']; $number_vars = $cache['num_entries'];
$size_files = bsize($cache['mem_size']); $size_vars = bsize($cache['mem_size']);
$number_vars = $cache_user['num_entries'];
$size_vars = bsize($cache_user['mem_size']);
$i=0; $i=0;
echo <<< EOB echo <<< EOB
<div class="info div1"><h2>General Cache Information</h2> <div class="info div1"><h2>General Cache Information</h2>
<table cellspacing=0><tbody> <table cellspacing=0><tbody>
<tr class=tr-0><td class=td-0>APC Version</td><td>$apcversion</td></tr> <tr class=tr-0><td class=td-0>APCu Version</td><td>$apcversion</td></tr>
<tr class=tr-1><td class=td-0>PHP Version</td><td>$phpversion</td></tr> <tr class=tr-1><td class=td-0>PHP Version</td><td>$phpversion</td></tr>
EOB; EOB;
if(!empty($_SERVER['SERVER_NAME'])) if(!empty($_SERVER['SERVER_NAME']))
echo "<tr class=tr-0><td class=td-0>APC Host</td><td>{$_SERVER['SERVER_NAME']} $host</td></tr>\n"; echo "<tr class=tr-0><td class=td-0>APCu Host</td><td>{$_SERVER['SERVER_NAME']} $host</td></tr>\n";
if(!empty($_SERVER['SERVER_SOFTWARE'])) if(!empty($_SERVER['SERVER_SOFTWARE']))
echo "<tr class=tr-1><td class=td-0>Server Software</td><td>{$_SERVER['SERVER_SOFTWARE']}</td></tr>\n"; echo "<tr class=tr-1><td class=td-0>Server Software</td><td>{$_SERVER['SERVER_SOFTWARE']}</td></tr>\n";
echo <<<EOB echo <<<EOB
<tr class=tr-0><td class=td-0>Shared Memory</td><td>{$mem['num_seg']} Segment(s) with $seg_size <tr class=tr-0><td class=td-0>Shared Memory</td><td>{$mem['num_seg']} Segment(s) with $seg_size
<br/> ({$cache['memory_type']} memory, {$cache['locking_type']} locking) <br/> ({$cache['memory_type']} memory)
</td></tr> </td></tr>
EOB; EOB;
echo '<tr class=tr-1><td class=td-0>Start Time</td><td>',date(DATE_FORMAT,$cache['start_time']),'</td></tr>'; echo '<tr class=tr-1><td class=td-0>Start Time</td><td>',date(DATE_FORMAT,$cache['start_time']),'</td></tr>';
echo '<tr class=tr-0><td class=td-0>Uptime</td><td>',duration($cache['start_time']),'</td></tr>'; echo '<tr class=tr-0><td class=td-0>Uptime</td><td>',duration($cache['start_time']),'</td></tr>';
echo '<tr class=tr-1><td class=td-0>File Upload Support</td><td>',$cache['file_upload_progress'],'</td></tr>';
echo <<<EOB echo <<<EOB
</tbody></table> </tbody></table>
</div> </div>
<div class="info div1"><h2>File Cache Information</h2> <div class="info div1"><h2>Cache Information</h2>
<table cellspacing=0><tbody> <table cellspacing=0>
<tr class=tr-0><td class=td-0>Cached Files</td><td>$number_files ($size_files)</td></tr> <tbody>
<tr class=tr-1><td class=td-0>Hits</td><td>{$cache['num_hits']}</td></tr> <tr class=tr-0><td class=td-0>Cached Variables</td><td>$number_vars ($size_vars)</td></tr>
<tr class=tr-0><td class=td-0>Misses</td><td>{$cache['num_misses']}</td></tr> <tr class=tr-1><td class=td-0>Hits</td><td>{$cache['num_hits']}</td></tr>
<tr class=tr-1><td class=td-0>Request Rate (hits, misses)</td><td>$req_rate cache requests/second</td></tr> <tr class=tr-0><td class=td-0>Misses</td><td>{$cache['num_misses']}</td></tr>
<tr class=tr-0><td class=td-0>Hit Rate</td><td>$hit_rate cache requests/second</td></tr> <tr class=tr-1><td class=td-0>Request Rate (hits, misses)</td><td>$req_rate_user cache requests/second</td></tr>
<tr class=tr-1><td class=td-0>Miss Rate</td><td>$miss_rate cache requests/second</td></tr> <tr class=tr-0><td class=td-0>Hit Rate</td><td>$hit_rate_user cache requests/second</td></tr>
<tr class=tr-0><td class=td-0>Insert Rate</td><td>$insert_rate cache requests/second</td></tr> <tr class=tr-1><td class=td-0>Miss Rate</td><td>$miss_rate_user cache requests/second</td></tr>
<tr class=tr-1><td class=td-0>Cache full count</td><td>{$cache['expunges']}</td></tr> <tr class=tr-0><td class=td-0>Insert Rate</td><td>$insert_rate_user cache requests/second</td></tr>
</tbody></table> <tr class=tr-1><td class=td-0>Cache full count</td><td>{$cache['expunges']}</td></tr>
</div> </tbody>
</table>
<div class="info div1"><h2>User Cache Information</h2>
<table cellspacing=0><tbody>
<tr class=tr-0><td class=td-0>Cached Variables</td><td>$number_vars ($size_vars)</td></tr>
<tr class=tr-1><td class=td-0>Hits</td><td>{$cache_user['num_hits']}</td></tr>
<tr class=tr-0><td class=td-0>Misses</td><td>{$cache_user['num_misses']}</td></tr>
<tr class=tr-1><td class=td-0>Request Rate (hits, misses)</td><td>$req_rate_user cache requests/second</td></tr>
<tr class=tr-0><td class=td-0>Hit Rate</td><td>$hit_rate_user cache requests/second</td></tr>
<tr class=tr-1><td class=td-0>Miss Rate</td><td>$miss_rate_user cache requests/second</td></tr>
<tr class=tr-0><td class=td-0>Insert Rate</td><td>$insert_rate_user cache requests/second</td></tr>
<tr class=tr-1><td class=td-0>Cache full count</td><td>{$cache_user['expunges']}</td></tr>
</tbody></table>
</div> </div>
<div class="info div2"><h2>Runtime Settings</h2><table cellspacing=0><tbody> <div class="info div2"><h2>Runtime Settings</h2><table cellspacing=0><tbody>
EOB; EOB;
$j = 0; $j = 0;
foreach (ini_get_all('apc') as $k => $v) { foreach (ini_get_all('apcu') as $k => $v) {
echo "<tr class=tr-$j><td class=td-0>",$k,"</td><td>",str_replace(',',',<br />',$v['local_value']),"</td></tr>\n"; echo "<tr class=tr-$j><td class=td-0>",$k,"</td><td>",str_replace(',',',<br />',$v['local_value']),"</td></tr>\n";
$j = 1 - $j; $j = 1 - $j;
} }
...@@ -860,7 +822,7 @@ EOB; ...@@ -860,7 +822,7 @@ EOB;
<table cellspacing=0><tbody> <table cellspacing=0><tbody>
EOB; EOB;
$size='width='.(GRAPH_SIZE+50).' height='.(GRAPH_SIZE+10); $size='width='.(GRAPH_SIZE+50).' height='.(GRAPH_SIZE+10);
echo <<<EOB echo <<<EOB
<tr> <tr>
<td class=td-0>$mem_note</td> <td class=td-0>$mem_note</td>
<td class=td-1>Hits &amp; Misses</td> <td class=td-1>Hits &amp; Misses</td>
...@@ -868,18 +830,18 @@ EOB; ...@@ -868,18 +830,18 @@ EOB;
EOB; EOB;
echo echo
graphics_avail() ? graphics_avail() ?
'<tr>'. '<tr>'.
"<td class=td-0><img alt=\"\" $size src=\"$PHP_SELF?IMG=1&$time\"></td>". "<td class=td-0><img alt=\"\" $size src=\"$PHP_SELF?IMG=1&$time\"></td>".
"<td class=td-1><img alt=\"\" $size src=\"$PHP_SELF?IMG=2&$time\"></td></tr>\n" "<td class=td-1><img alt=\"\" $size src=\"$PHP_SELF?IMG=2&$time\"></td></tr>\n"
: "", : "",
'<tr>', '<tr>',
'<td class=td-0><span class="green box">&nbsp;</span>Free: ',bsize($mem_avail).sprintf(" (%.1f%%)",$mem_avail*100/$mem_size),"</td>\n", '<td class=td-0><span class="green box">&nbsp;</span>Free: ',bsize($mem_avail).sprintf(" (%.1f%%)",$mem_avail*100/$mem_size),"</td>\n",
'<td class=td-1><span class="green box">&nbsp;</span>Hits: ',$cache['num_hits'].sprintf(" (%.1f%%)",$cache['num_hits']*100/($cache['num_hits']+$cache['num_misses'])),"</td>\n", '<td class=td-1><span class="green box">&nbsp;</span>Hits: ,$cache['num_hits'].@sprintf(" (%.1f%%)",$cache['num_hits']*100/($cache['num_hits']+$cache['num_misses])),"</td>\n",
'</tr>', '</tr>',
'<tr>', '<tr>',
'<td class=td-0><span class="red box">&nbsp;</span>Used: ',bsize($mem_used ).sprintf(" (%.1f%%)",$mem_used *100/$mem_size),"</td>\n", '<td class=td-0><span class="red box">&nbsp;</span>Used: ',bsize($mem_used).sprintf(" (%.1f%%)",$mem_used *100/$mem_size),"</td>\n",
'<td class=td-1><span class="red box">&nbsp;</span>Misses: ',$cache['num_misses'].sprintf(" (%.1f%%)",$cache['num_misses']*100/($cache['num_hits']+$cache['num_misses'])),"</td>\n"; '<td class=td-1><span class="red box">&nbsp;</span>Misses: ,$cache['num_misses'].@sprintf(" (%.1f%%)",$cache['num_misses']*100/($cache['num_hits']+$cache['num_misses])),"</td>\n";
echo <<< EOB echo <<< EOB
</tr> </tr>
</tbody></table> </tbody></table>
...@@ -906,7 +868,7 @@ EOB; ...@@ -906,7 +868,7 @@ EOB;
} }
$freeseg += count($mem['block_lists'][$i]); $freeseg += count($mem['block_lists'][$i]);
} }
if ($freeseg > 1) { if ($freeseg > 1) {
$frag = sprintf("%.2f%% (%s out of %s in %d fragments)", ($fragsize/$freetotal)*100,bsize($fragsize),bsize($freetotal),$freeseg); $frag = sprintf("%.2f%% (%s out of %s in %d fragments)", ($fragsize/$freetotal)*100,bsize($fragsize),bsize($freetotal),$freeseg);
} else { } else {
...@@ -936,7 +898,7 @@ EOB; ...@@ -936,7 +898,7 @@ EOB;
</tbody></table> </tbody></table>
</div> </div>
EOB; EOB;
break; break;
...@@ -954,71 +916,13 @@ case OB_USER_CACHE: ...@@ -954,71 +916,13 @@ case OB_USER_CACHE:
$fieldheading='User Entry Label'; $fieldheading='User Entry Label';
$fieldkey='info'; $fieldkey='info';
// -----------------------------------------------
// System Cache Entries
// -----------------------------------------------
case OB_SYS_CACHE:
if (!isset($fieldname))
{
$fieldname='filename';
$fieldheading='Script Filename';
if(ini_get("apc.stat")) $fieldkey='inode';
else $fieldkey='filename';
}
if (!empty($MYREQUEST['SH']))
{
echo <<< EOB
<div class="info"><table cellspacing=0><tbody>
<tr><th>Attribute</th><th>Value</th></tr>
EOB;
$m=0;
foreach($scope_list as $j => $list) {
foreach($cache[$list] as $i => $entry) {
if (md5($entry[$fieldkey])!=$MYREQUEST['SH']) continue;
foreach($entry as $k => $value) {
if (!$AUTHENTICATED) {
// hide all path entries if not logged in
$value=preg_replace('/^.*(\\/|\\\\)/','<i>&lt;hidden&gt;</i>/',$value);
}
if ($k == "num_hits") {
$value=sprintf("%s (%.2f%%)",$value,$value*100/$cache['num_hits']);
}
if ($k == 'deletion_time') {
if(!$entry['deletion_time']) $value = "None";
}
echo
"<tr class=tr-$m>",
"<td class=td-0>",ucwords(preg_replace("/_/"," ",$k)),"</td>",
"<td class=td-last>",(preg_match("/time/",$k) && $value!='None') ? date(DATE_FORMAT,$value) : htmlspecialchars($value, ENT_QUOTES, 'UTF-8'),"</td>",
"</tr>";
$m=1-$m;
}
if($fieldkey=='info') {
echo "<tr class=tr-$m><td class=td-0>Stored Value</td><td class=td-last><pre>";
$output = var_export(apc_fetch($entry[$fieldkey]),true);
echo htmlspecialchars($output, ENT_QUOTES, 'UTF-8');
echo "</pre></td></tr>\n";
}
break;
}
}
echo <<<EOB
</tbody></table>
</div>
EOB;
break;
}
$cols=6; $cols=6;
echo <<<EOB echo <<<EOB
<div class=sorting><form>Scope: <div class=sorting><form>Scope:
<input type=hidden name=OB value={$MYREQUEST['OB']}> <input type=hidden name=OB value={$MYREQUEST['OB']}>
<select name=SCOPE> <select name=SCOPE>
EOB; EOB;
echo echo
"<option value=A",$MYREQUEST['SCOPE']=='A' ? " selected":"",">Active</option>", "<option value=A",$MYREQUEST['SCOPE']=='A' ? " selected":"",">Active</option>",
"<option value=D",$MYREQUEST['SCOPE']=='D' ? " selected":"",">Deleted</option>", "<option value=D",$MYREQUEST['SCOPE']=='D' ? " selected":"",">Deleted</option>",
"</select>", "</select>",
...@@ -1032,7 +936,7 @@ EOB; ...@@ -1032,7 +936,7 @@ EOB;
"<option value=D",$MYREQUEST['SORT1']=='D' ? " selected":"",">Deleted at</option>"; "<option value=D",$MYREQUEST['SORT1']=='D' ? " selected":"",">Deleted at</option>";
if($fieldname=='info') echo if($fieldname=='info') echo
"<option value=D",$MYREQUEST['SORT1']=='T' ? " selected":"",">Timeout</option>"; "<option value=D",$MYREQUEST['SORT1']=='T' ? " selected":"",">Timeout</option>";
echo echo
'</select>', '</select>',
'<select name=SORT2>', '<select name=SORT2>',
'<option value=D',$MYREQUEST['SORT2']=='D' ? ' selected':'','>DESC</option>', '<option value=D',$MYREQUEST['SORT2']=='D' ? ' selected':'','>DESC</option>',
...@@ -1081,16 +985,17 @@ EOB; ...@@ -1081,16 +985,17 @@ EOB;
// builds list with alpha numeric sortable keys // builds list with alpha numeric sortable keys
// //
$list = array(); $list = array();
foreach($cache[$scope_list[$MYREQUEST['SCOPE']]] as $i => $entry) { foreach($cache[$scope_list[$MYREQUEST['SCOPE']]] as $i => $entry) {
switch($MYREQUEST['SORT1']) { switch($MYREQUEST['SORT1']) {
case 'A': $k=sprintf('%015d-',$entry['access_time']); break; case 'A': $k=sprintf('%015d-',$entry['access_time']); break;
case 'H': $k=sprintf('%015d-',$entry['num_hits']); break; case 'H': $k=sprintf('%015d-',$entry['num_hits']); break;
case 'Z': $k=sprintf('%015d-',$entry['mem_size']); break; case 'Z': $k=sprintf('%015d-',$entry['mem_size']); break;
case 'M': $k=sprintf('%015d-',$entry['mtime']); break; case 'M': $k=sprintf('%015d-',$entry['mtime']); break;
case 'C': $k=sprintf('%015d-',$entry['creation_time']); break; case 'C': $k=sprintf('%015d-',$entry['creation_time']); break;
case 'T': $k=sprintf('%015d-',$entry['ttl']); break; case 'T': $k=sprintf('%015d-',$entry['ttl']); break;
case 'D': $k=sprintf('%015d-',$entry['deletion_time']); break; case 'D': $k=sprintf('%015d-',$entry['deletion_time']); break;
case 'S': $k=''; break; case 'S': $k=$entry["info"]; break;
} }
if (!$AUTHENTICATED) { if (!$AUTHENTICATED) {
// hide all path entries if not logged in // hide all path entries if not logged in
...@@ -1101,22 +1006,22 @@ EOB; ...@@ -1101,22 +1006,22 @@ EOB;
} }
if ($list) { if ($list) {
// sort list // sort list
// //
switch ($MYREQUEST['SORT2']) { switch ($MYREQUEST['SORT2']) {
case "A": krsort($list); break; case "A": krsort($list); break;
case "D": ksort($list); break; case "D": ksort($list); break;
} }
// output list // output list
$i=0; $i=0;
foreach($list as $k => $entry) { foreach($list as $k => $entry) {
if(!$MYREQUEST['SEARCH'] || preg_match($MYREQUEST['SEARCH'], $entry[$fieldname]) != 0) { if(!$MYREQUEST['SEARCH'] || preg_match($MYREQUEST['SEARCH'], $entry[$fieldname]) != 0) {
$sh=md5($entry["info"]);
$field_value = htmlentities(strip_tags($entry[$fieldname],''), ENT_QUOTES, 'UTF-8'); $field_value = htmlentities(strip_tags($entry[$fieldname],''), ENT_QUOTES, 'UTF-8');
echo echo
'<tr class=tr-',$i%2,'>', '<tr id="key-'. $sh .'" class=tr-',$i%2,'>',
"<td class=td-0><a href=\"$MY_SELF&OB=",$MYREQUEST['OB'],"&SH=",md5($entry[$fieldkey]),"\">",$field_value,'</a></td>', "<td class=td-0><a href=\"$MY_SELF&OB=",$MYREQUEST['OB'],"&SH=",$sh,"#key-". $sh ."\">",$field_value,'</a></td>',
'<td class="td-n center">',$entry['num_hits'],'</td>', '<td class="td-n center">',$entry['num_hits'],'</td>',
'<td class="td-n right">',$entry['mem_size'],'</td>', '<td class="td-n right">',$entry['mem_size'],'</td>',
'<td class="td-n center">',date(DATE_FORMAT,$entry['access_time']),'</td>', '<td class="td-n center">',date(DATE_FORMAT,$entry['access_time']),'</td>',
...@@ -1141,141 +1046,19 @@ EOB; ...@@ -1141,141 +1046,19 @@ EOB;
echo '<td class="td-last center"> &nbsp; </td>'; echo '<td class="td-last center"> &nbsp; </td>';
} }
echo '</tr>'; echo '</tr>';
if ($sh == $MYREQUEST["SH"]) {
echo '<tr>';
echo '<td colspan="7"><pre>'.htmlentities(print_r(apcu_fetch($entry['info']), 1)).'</pre></td>';
echo '</tr>';
}
$i++; $i++;
if ($i == $MYREQUEST['COUNT']) if ($i == $MYREQUEST['COUNT'])
break; break;
} }
} }
} else {
echo '<tr class=tr-0><td class="center" colspan=',$cols,'><i>No data</i></td></tr>';
}
echo <<< EOB
</tbody></table>
EOB;
if ($list && $i < count($list)) {
echo "<a href=\"$MY_SELF&OB=",$MYREQUEST['OB'],"&COUNT=0\"><i>",count($list)-$i,' more available...</i></a>';
}
echo <<< EOB
</div>
EOB;
break;
// -----------------------------------------------
// Per-Directory System Cache Entries
// -----------------------------------------------
case OB_SYS_CACHE_DIR:
if (!$AUTHENTICATED) {
break;
}
echo <<<EOB
<div class=sorting><form>Scope:
<input type=hidden name=OB value={$MYREQUEST['OB']}>
<select name=SCOPE>
EOB;
echo
"<option value=A",$MYREQUEST['SCOPE']=='A' ? " selected":"",">Active</option>",
"<option value=D",$MYREQUEST['SCOPE']=='D' ? " selected":"",">Deleted</option>",
"</select>",
", Sorting:<select name=SORT1>",
"<option value=H",$MYREQUEST['SORT1']=='H' ? " selected":"",">Total Hits</option>",
"<option value=Z",$MYREQUEST['SORT1']=='Z' ? " selected":"",">Total Size</option>",
"<option value=T",$MYREQUEST['SORT1']=='T' ? " selected":"",">Number of Files</option>",
"<option value=S",$MYREQUEST['SORT1']=='S' ? " selected":"",">Directory Name</option>",
"<option value=A",$MYREQUEST['SORT1']=='A' ? " selected":"",">Avg. Size</option>",
"<option value=C",$MYREQUEST['SORT1']=='C' ? " selected":"",">Avg. Hits</option>",
'</select>',
'<select name=SORT2>',
'<option value=D',$MYREQUEST['SORT2']=='D' ? ' selected':'','>DESC</option>',
'<option value=A',$MYREQUEST['SORT2']=='A' ? ' selected':'','>ASC</option>',
'</select>',
'<select name=COUNT onChange="form.submit()">',
'<option value=10 ',$MYREQUEST['COUNT']=='10' ? ' selected':'','>Top 10</option>',
'<option value=20 ',$MYREQUEST['COUNT']=='20' ? ' selected':'','>Top 20</option>',
'<option value=50 ',$MYREQUEST['COUNT']=='50' ? ' selected':'','>Top 50</option>',
'<option value=100',$MYREQUEST['COUNT']=='100'? ' selected':'','>Top 100</option>',
'<option value=150',$MYREQUEST['COUNT']=='150'? ' selected':'','>Top 150</option>',
'<option value=200',$MYREQUEST['COUNT']=='200'? ' selected':'','>Top 200</option>',
'<option value=500',$MYREQUEST['COUNT']=='500'? ' selected':'','>Top 500</option>',
'<option value=0 ',$MYREQUEST['COUNT']=='0' ? ' selected':'','>All</option>',
'</select>',
", Group By Dir Level:<select name=AGGR>",
"<option value='' selected>None</option>";
for ($i = 1; $i < 10; $i++)
echo "<option value=$i",$MYREQUEST['AGGR']==$i ? " selected":"",">$i</option>";
echo '</select>',
'&nbsp;<input type=submit value="GO!">',
'</form></div>',
'<div class="info"><table cellspacing=0><tbody>',
'<tr>',
'<th>',sortheader('S','Directory Name', "&OB=".$MYREQUEST['OB']),'</th>',
'<th>',sortheader('T','Number of Files',"&OB=".$MYREQUEST['OB']),'</th>',
'<th>',sortheader('H','Total Hits', "&OB=".$MYREQUEST['OB']),'</th>',
'<th>',sortheader('Z','Total Size', "&OB=".$MYREQUEST['OB']),'</th>',
'<th>',sortheader('C','Avg. Hits', "&OB=".$MYREQUEST['OB']),'</th>',
'<th>',sortheader('A','Avg. Size', "&OB=".$MYREQUEST['OB']),'</th>',
'</tr>';
// builds list with alpha numeric sortable keys
//
$tmp = $list = array();
foreach($cache[$scope_list[$MYREQUEST['SCOPE']]] as $entry) {
$n = dirname($entry['filename']);
if ($MYREQUEST['AGGR'] > 0) {
$n = preg_replace("!^(/?(?:[^/\\\\]+[/\\\\]){".($MYREQUEST['AGGR']-1)."}[^/\\\\]*).*!", "$1", $n);
}
if (!isset($tmp[$n])) {
$tmp[$n] = array('hits'=>0,'size'=>0,'ents'=>0);
}
$tmp[$n]['hits'] += $entry['num_hits'];
$tmp[$n]['size'] += $entry['mem_size'];
++$tmp[$n]['ents'];
}
foreach ($tmp as $k => $v) {
switch($MYREQUEST['SORT1']) {
case 'A': $kn=sprintf('%015d-',$v['size'] / $v['ents']);break;
case 'T': $kn=sprintf('%015d-',$v['ents']); break;
case 'H': $kn=sprintf('%015d-',$v['hits']); break;
case 'Z': $kn=sprintf('%015d-',$v['size']); break;
case 'C': $kn=sprintf('%015d-',$v['hits'] / $v['ents']);break;
case 'S': $kn = $k; break;
}
$list[$kn.$k] = array($k, $v['ents'], $v['hits'], $v['size']);
}
if ($list) {
// sort list
//
switch ($MYREQUEST['SORT2']) {
case "A": krsort($list); break;
case "D": ksort($list); break;
}
// output list
$i = 0;
foreach($list as $entry) {
echo
'<tr class=tr-',$i%2,'>',
"<td class=td-0>",$entry[0],'</a></td>',
'<td class="td-n center">',$entry[1],'</td>',
'<td class="td-n center">',$entry[2],'</td>',
'<td class="td-n center">',$entry[3],'</td>',
'<td class="td-n center">',round($entry[2] / $entry[1]),'</td>',
'<td class="td-n center">',round($entry[3] / $entry[1]),'</td>',
'</tr>';
if (++$i == $MYREQUEST['COUNT']) break;
}
} else { } else {
echo '<tr class=tr-0><td class="center" colspan=6><i>No data</i></td></tr>'; echo '<tr class=tr-0><td class="center" colspan=',$cols,'><i>No data</i></td></tr>';
} }
echo <<< EOB echo <<< EOB
</tbody></table> </tbody></table>
...@@ -1295,7 +1078,7 @@ EOB; ...@@ -1295,7 +1078,7 @@ EOB;
// ----------------------------------------------- // -----------------------------------------------
case OB_VERSION_CHECK: case OB_VERSION_CHECK:
echo <<<EOB echo <<<EOB
<div class="info"><h2>APC Version Information</h2> <div class="info"><h2>APCu Version Information</h2>
<table cellspacing=0><tbody> <table cellspacing=0><tbody>
<tr> <tr>
<th></th> <th></th>
...@@ -1303,24 +1086,24 @@ case OB_VERSION_CHECK: ...@@ -1303,24 +1086,24 @@ case OB_VERSION_CHECK:
EOB; EOB;
if (defined('PROXY')) { if (defined('PROXY')) {
$ctxt = stream_context_create( array( 'http' => array( 'proxy' => PROXY, 'request_fulluri' => True ) ) ); $ctxt = stream_context_create( array( 'http' => array( 'proxy' => PROXY, 'request_fulluri' => True ) ) );
$rss = @file_get_contents("http://pecl.php.net/feeds/pkg_apc.rss", False, $ctxt); $rss = @file_get_contents("http://pecl.php.net/feeds/pkg_apcu.rss", False, $ctxt);
} else { } else {
$rss = @file_get_contents("http://pecl.php.net/feeds/pkg_apc.rss"); $rss = @file_get_contents("http://pecl.php.net/feeds/pkg_apcu.rss");
} }
if (!$rss) { if (!$rss) {
echo '<tr class="td-last center"><td>Unable to fetch version information.</td></tr>'; echo '<tr class="td-last center"><td>Unable to fetch version information.</td></tr>';
} else { } else {
$apcversion = phpversion('apc'); $apcversion = phpversion('apcu');
preg_match('!<title>APC ([0-9.]+)</title>!', $rss, $match); preg_match('!<title>APCu ([0-9.]+)</title>!', $rss, $match);
echo '<tr class="tr-0 center"><td>'; echo '<tr class="tr-0 center"><td>';
if (version_compare($apcversion, $match[1], '>=')) { if (version_compare($apcversion, $match[1], '>=')) {
echo '<div class="ok">You are running the latest version of APC ('.$apcversion.')</div>'; echo '<div class="ok">You are running the latest version of APCu ('.$apcversion.')</div>';
$i = 3; $i = 3;
} else { } else {
echo '<div class="failed">You are running an older version of APC ('.$apcversion.'), echo '<div class="failed">You are running an older version of APCu ('.$apcversion.'),
newer version '.$match[1].' is available at <a href="http://pecl.php.net/package/APC/'.$match[1].'"> newer version '.$match[1].' is available at <a href="http://pecl.php.net/package/APCu/'.$match[1].'">
http://pecl.php.net/package/APC/'.$match[1].'</a> http://pecl.php.net/package/APCu/'.$match[1].'</a>
</div>'; </div>';
$i = -1; $i = -1;
} }
...@@ -1328,18 +1111,19 @@ EOB; ...@@ -1328,18 +1111,19 @@ EOB;
echo '<tr class="tr-0"><td><h3>Change Log:</h3><br/>'; echo '<tr class="tr-0"><td><h3>Change Log:</h3><br/>';
preg_match_all('!<(title|description)>([^<]+)</\\1>!', $rss, $match); preg_match_all('!<(title|description)>([^<]+)</\\1>!', $rss, $match);
next($match[2]); next($match[2]); $changelog = $match[2];
while (list(,$v) = each($match[2])) { for ($j = 2; $j + 1 < count($changelog); $j += 2) {
list(,$ver) = explode(' ', $v, 2); $v = $changelog[$j];
if ($i < 0 && version_compare($apcversion, $ver, '>=')) { if ($i < 0 && version_compare($apcversion, $ver, '>=')) {
break; break;
} else if (!$i--) { } else if (!$i--) {
break; break;
} }
echo "<b><a href=\"http://pecl.php.net/package/APC/$ver\">".htmlspecialchars($v, ENT_QUOTES, 'UTF-8')."</a></b><br><blockquote>"; list($unused, $ver) = $v;
echo nl2br(htmlspecialchars(current($match[2]), ENT_QUOTES, 'UTF-8'))."</blockquote>"; $changes = $changelog[$j + 1];
next($match[2]); echo "<b><a href=\"http://pecl.php.net/package/APCu/$ver\">".htmlspecialchars($v, ENT_QUOTES, 'UTF-8')."</a></b><br><blockquote>";
echo nl2br(htmlspecialchars($changes, ENT_QUOTES, 'UTF-8'))."</blockquote>";
} }
echo '</td></tr>'; echo '</td></tr>';
} }
......
---
# file: roles/php/handlers/main.yml
- name: Restart PHP-FPM
service:
name: '{{ phpFpmService }}'
state: restarted
- name: Initial Logrotate
shell: logrotate -f /etc/logrotate.d/php{{ phpLogRotatePrefix }}-fpm
...@@ -2,3 +2,4 @@ ...@@ -2,3 +2,4 @@
dependencies: dependencies:
- { role: apache } - { role: apache }
- { role: imagemagick }
...@@ -5,17 +5,36 @@ ...@@ -5,17 +5,36 @@
--- ---
# file: roles/php/tasks/main.yml # file: roles/php/tasks/main.yml
- name: "PHP Role" - name: PHP Role
set_fact: role_php_started=true set_fact:
tags: always role_php_started: yes
tags:
- always
- block: - block:
- include: php.yml - name: Include variables
when: role_php_completed is not defined include_tasks: variables.yml
tags:
- always
- name: 'PHP | Remember that this role had been run' - name: Import php
set_fact: role_php_completed=true import_tasks: php.yml
tags: always
when: '"php" not in excluded_roles' - name: Link PhpEnMod for PHP 5.3
file:
dest: /usr/local/bin/php{{ item }}
src: /usr/sbin/php5{{ item }}
state: link
with_items:
- enmod
- dismod
when: php_version|default("5.5") == "5.3"
- name: PHP | Remember that this role had been run
set_fact:
role_php_completed: yes
tags:
- always
when: (not excluded_roles or "php" not in excluded_roles) and role_php_completed is not defined
---
# file: roles/php/tasks/mcrypt-7.2.yml
- name: Check MCrypt Requirement
stat:
path: /usr/lib/php/20170718/mcrypt.so
register: mcrypt_file
- block:
- name: Enable MCrypt for PHP
copy:
content: extension={{ item }}.so
dest: /etc/{{ php_base_dir }}/{{ php_conf_dir }}/{{ item }}.ini
owner: root
group: root
mode: 0644
with_items:
- mcrypt
- name: Install packages
apt:
pkg: '{{ packages }}'
state: present
update_cache: yes
vars:
packages:
- libmcrypt-dev
- libreadline-dev
- name: Install PECL packages
shell: pecl install --soft --ignore-errors mcrypt-1.0.1
when: php_version_main|default(7) == 7
ignore_errors: yes
- name: Enable extension
shell: phpenmod {{ item }}
with_items:
- mcrypt
notify:
- Restart Apache
when: not mcrypt_file.stat.exists
---
# file: roles/php/tasks/msodbc.yml
- name: Apt Key
apt_key:
keyring: /etc/apt/trusted.gpg.d/microsoft.gpg
url: 'https://packages.microsoft.com/keys/microsoft.asc'
state: present
- name: Apt Repository
apt_repository:
repo: 'deb [arch=amd64] https://packages.microsoft.com/ubuntu/18.04/prod {{ ansible_distribution_release }} main'
state: present
mode: 0644
- name: Accept licenses
debconf:
name: "{{ item }}-installer"
question: "{{ item }}/accept_eula"
value: "true"
vtype: "select"
with_items:
- mssql-tools
- name: Install Packages
apt:
pkg: '{{ packages }}'
state: present
update_cache: yes
vars:
packages:
- mssql-tools
- unixodbc-dev
notify:
- Restart Apache
- name: PHP | Install PECL packages
shell: pecl install --soft {{ item }}
with_items:
- sqlsrv
- pdo_sqlsrv
when: false
- name: Configuration files
copy:
content: extension={{ item }}.so
dest: /etc/{{ php_base_dir }}/{{ php_conf_dir }}/{{ item }}.ini
owner: root
group: root
mode: 0644
with_items:
- sqlsrv
- pdo_sqlsrv
notify:
- Restart Apache
when: false
- name: Enable extensions
shell: phpenmod {{ item }}
with_items:
- sqlsrv
- pdo_sqlsrv
notify:
- Restart Apache
when: false
---
# file: roles/php/tasks/oci-5.3.yml
#
# @see OCI8 Install: https://help.ubuntu.com/community/PHPOracle
# Better:
# @see PDO_OCI Install: https://drupal.org/comment/5572626#comment-5572626
- name: PHP | Check OCI Requirement
stat:
path: /usr/lib/php5/20090626/pdo_oci.so
register: oci_file
- block:
- name: PHP | OCI | Enable OCI for PHP
copy:
content: extension={{ item }}.so
dest: /etc/{{ php_base_dir }}/{{ php_conf_dir }}/{{ item }}.ini
owner: root
group: root
mode: 0644
with_items:
- oci8
- pdo_oci
- name: PHP | OCI | Remove possible components in /tmp
file:
path: /tmp/{{ item }}
state: absent
with_items:
- instantclient_11_2
- oracle_x64_11_2_0_3_0_oci8_so
- oracle_x64_11_2_0_3_0_pdo_oci_so
- name: PHP | OCI | Make available Oracle InstantClient
command: scp -r {{ repository }}{{ item }} /tmp/
become: no
with_items:
- instantclient_11_2
- oracle_x64_11_2_0_3_0_oci8_so
- oracle_x64_11_2_0_3_0_pdo_oci_so
- name: PHP | OCI | Remove /usr/local/lib/instantclient_11_2
file:
path: /usr/local/lib/instantclient_11_2
state: absent
- name: PHP | OCI | Move Oracle InstantClient to /usr/local/lib
command: mv /tmp/instantclient_11_2 /usr/local/lib/
- name: PHP | OCI | Move oci8 to /usr/lib/php5
command: mv /tmp/oracle_x64_11_2_0_3_0_oci8_so /usr/lib/php5/20090626/oci8.so
- name: PHP | OCI | Move pdo_oci to /usr/lib/php5
command: mv /tmp/oracle_x64_11_2_0_3_0_pdo_oci_so /usr/lib/php5/20090626/pdo_oci.so
- name: PHP | OCI | Change ownership for Oracle InstantClient
file:
path: '{{ item }}'
owner: root
group: root
recurse: yes
follow: no
with_items:
- /usr/local/lib/instantclient_11_2
- name: Ensure log directories
file:
path: /usr/local/lib/instantclient_11_2/log/diag/clients
owner: www-data
group: root
state: directory
mode: 0775
follow: no
- name: Set permissions in log directories
file:
path: /usr/local/lib/instantclient_11_2/log
owner: www-data
group: root
mode: 0775
recurse: yes
follow: no
- name: PHP | OCI | Make available libclntsh.so
file:
src: /usr/local/lib/instantclient_11_2/libclntsh.so.11.1
dest: /usr/local/lib/instantclient_11_2/libclntsh.so
state: link
when: not oci_file.stat.exists
---
# file: roles/php/tasks/oci-5.5.yml
- debug: msg="OCI8 for PHP 5.5 not implemented yet"
---
# file: roles/php/tasks/oci-5.6.yml
- name: Check OCI Requirement
stat:
path: /usr/lib/php/20131226/oci8.so
register: oci_file
- block:
- name: Enable OCI for PHP
copy:
content: extension={{ item }}.so
dest: /etc/{{ php_base_dir }}/{{ php_conf_dir }}/{{ item }}.ini
owner: root
group: root
mode: 0644
with_items:
- oci8
- name: Remove possible components in /tmp
file:
path: /tmp/{{ item }}
state: absent
with_items:
- instantclient_11_2
- oracle_x64_11_2_0_3_0_oci8_so_php_5_6
- name: Make available Oracle InstantClient
command: scp -r {{ repository }}{{ item }} /tmp/
become: no
with_items:
- instantclient_11_2
- oracle_x64_11_2_0_3_0_oci8_so_php_5_6
- name: Remove /usr/local/lib/instantclient_11_2
file:
path: /usr/local/lib/instantclient_11_2
state: absent
- name: Move Oracle InstantClient to /usr/local/lib
command: mv /tmp/instantclient_11_2 /usr/local/lib/
- name: Move oci8 to /usr/lib/php
command: mv /tmp/oracle_x64_11_2_0_3_0_oci8_so_php_4_5 /usr/lib/php/20131226/oci8.so
- name: Change ownership for Oracle InstantClient
file:
path: '{{ item }}'
owner: root
group: root
recurse: yes
follow: no
with_items:
- /usr/local/lib/instantclient_11_2
- name: Ensure log directories
file:
path: /usr/local/lib/instantclient_11_2/log/diag/clients
owner: www-data
group: root
state: directory
mode: 0775
follow: no
- name: Set permissions in log directories
file:
path: /usr/local/lib/instantclient_11_2/log
owner: www-data
group: root
mode: 0775
recurse: yes
follow: no
- name: Make available libclntsh.so
file:
src: /usr/local/lib/instantclient_11_2/libclntsh.so.11.1
dest: /usr/local/lib/instantclient_11_2/libclntsh.so
state: link
when: not oci_file.stat.exists
---
# file: roles/php/tasks/oci-7.0.yml
- name: Check OCI Requirement
stat:
path: /usr/lib/php/20151012/oci8.so
register: oci_file
- block:
- name: Enable OCI for PHP
copy:
content: extension={{ item }}.so
dest: /etc/{{ php_base_dir }}/{{ php_conf_dir }}/{{ item }}.ini
owner: root
group: root
mode: 0644
with_items:
- oci8
- name: Remove possible components in /tmp
file:
path: /tmp/{{ item }}
state: absent
with_items:
- instantclient_11_2
- oracle_x64_11_2_0_3_0_oci8_so_php_7
- name: Make available Oracle InstantClient
command: scp -r {{ repository }}{{ item }} /tmp/
become: no
with_items:
- instantclient_11_2
- oracle_x64_11_2_0_3_0_oci8_so_php_7
- name: Remove /usr/local/lib/instantclient_11_2
file:
path: /usr/local/lib/instantclient_11_2
state: absent
- name: Move Oracle InstantClient to /usr/local/lib
command: mv /tmp/instantclient_11_2 /usr/local/lib/
- name: Move oci8 to /usr/lib/php
command: mv /tmp/oracle_x64_11_2_0_3_0_oci8_so_php_7 /usr/lib/php/20151012/oci8.so
- name: Change ownership for Oracle InstantClient
file:
path: '{{ item }}'
owner: root
group: root
recurse: yes
follow: no
with_items:
- /usr/local/lib/instantclient_11_2
- name: Ensure log directories
file:
path: /usr/local/lib/instantclient_11_2/log/diag/clients
owner: www-data
group: root
state: directory
mode: 0775
follow: no
- name: Set permissions in log directories
file:
path: /usr/local/lib/instantclient_11_2/log
owner: www-data
group: root
mode: 0775
recurse: yes
follow: no
- name: Make available libclntsh.so
file:
src: /usr/local/lib/instantclient_11_2/libclntsh.so.11.1
dest: /usr/local/lib/instantclient_11_2/libclntsh.so
state: link
when: not oci_file.stat.exists
---
# file: roles/php/tasks/oci-7.1.yml
- debug: msg="OCI8 for PHP 7.1 not implemented yet"
---
# file: roles/php/tasks/oci-7.2.yml
#
# https://gist.github.com/Yukibashiri/cebaeaccbe531665a5704b1b34a3498e
- name: Check OCI Requirement
stat:
path: /usr/lib/php/20170718/oci8.so
register: oci_file
- block:
- name: Enable OCI for PHP
copy:
content: extension={{ item }}.so
dest: /etc/{{ php_base_dir }}/{{ php_conf_dir }}/{{ item }}.ini
owner: root
group: root
mode: 0644
with_items:
- oci8
- name: Remove possible components in /tmp
file:
path: /tmp/{{ item }}
state: absent
with_items:
- instantclient_18_5
- oracle_x64_18_5_0_0_0_oci8_so_php_7
- name: Make available Oracle InstantClient
command: scp -r {{ repository }}{{ item }} /tmp/
become: no
with_items:
- instantclient_18_5
- oracle_x64_18_5_0_0_0_oci8_so_php_7
- name: Remove /opt/oracle/instantclient_18_5
file:
path: /opt/oracle/instantclient_18_5
state: absent
- name: Ensure directory /opt/oracle
file:
path: /opt/oracle
state: directory
- name: Move Oracle InstantClient to /opt/oracle
command: mv /tmp/instantclient_18_5 /opt/oracle/instantclient_18_5
- name: Move oci8 to /usr/lib/php
command: mv /tmp/oracle_x64_18_5_0_0_0_oci8_so_php_7 /usr/lib/php/20170718/oci8.so
- name: Change ownership for Oracle InstantClient
file:
path: '{{ item }}'
owner: root
group: root
recurse: yes
follow: no
with_items:
- /opt/oracle/instantclient_18_5
- name: Ensure log directories
file:
path: /opt/oracle/instantclient_18_5/log/diag/clients
owner: www-data
group: root
state: directory
mode: 0775
follow: no
- name: Set permissions in log directories
file:
path: /opt/oracle/instantclient_18_5/log
owner: www-data
group: root
mode: 0775
recurse: yes
follow: no
- name: Create symlinks
file:
src: /opt/oracle/instantclient_18_5/{{ item }}.so.18.1
dest: /opt/oracle/instantclient_18_5/{{ item }}.so
state: link
with_items:
- libclntsh
- libocci
- name: Configure libraries
template:
src: etc-ld-oracle
dest: /etc/ld.so.conf.d/oracle-instantclient.conf
owner: root
group: root
mode: 0644
- name: Update libraries
command: ldconfig
when: not oci_file.stat.exists
---
# file: roles/php/tasks/oci-7.3.yml
- debug: msg="OCI8 for PHP 7.3 not implemented yet"
---
# file: roles/php/tasks/oci-7.4.yml
#
# https://gist.github.com/Yukibashiri/cebaeaccbe531665a5704b1b34a3498e
- name: Check OCI Requirement
stat:
path: /usr/lib/php/20190902/oci8.so
register: oci_file
- block:
- name: Enable OCI for PHP
copy:
content: extension={{ item }}.so
dest: /etc/{{ php_base_dir }}/{{ php_conf_dir }}/{{ item }}.ini
owner: root
group: root
mode: 0644
with_items:
- oci8
- name: Remove possible components in /tmp
file:
path: /tmp/{{ item }}
state: absent
with_items:
- instantclient_18_5
- oracle_x64_18_5_0_0_0_oci8_so_php_7
- name: Make available Oracle InstantClient
command: scp -r {{ repository }}{{ item }} /tmp/
become: no
with_items:
- instantclient_18_5
- oracle_x64_18_5_0_0_0_oci8_so_php_7_4
- name: Remove /opt/oracle/instantclient_18_5
file:
path: /opt/oracle/instantclient_18_5
state: absent
- name: Ensure directory /opt/oracle
file:
path: /opt/oracle
state: directory
- name: Move Oracle InstantClient to /opt/oracle
command: mv /tmp/instantclient_18_5 /opt/oracle/instantclient_18_5
- name: Move oci8 to /usr/lib/php
command: mv /tmp/oracle_x64_18_5_0_0_0_oci8_so_php_7_4 /usr/lib/php/20190902/oci8.so
- name: Change ownership for Oracle InstantClient
file:
path: '{{ item }}'
owner: root
group: root
recurse: yes
follow: no
with_items:
- /opt/oracle/instantclient_18_5
- name: Ensure log directories
file:
path: /opt/oracle/instantclient_18_5/log/diag/clients
owner: www-data
group: root
state: directory
mode: 0775
follow: no
- name: Set permissions in log directories
file:
path: /opt/oracle/instantclient_18_5/log
owner: www-data
group: root
mode: 0775
recurse: yes
follow: no
- name: Create symlinks
file:
src: /opt/oracle/instantclient_18_5/{{ item }}.so.18.1
dest: /opt/oracle/instantclient_18_5/{{ item }}.so
state: link
with_items:
- libclntsh
- libocci
- name: Configure libraries
template:
src: etc-ld-oracle
dest: /etc/ld.so.conf.d/oracle-instantclient.conf
owner: root
group: root
mode: 0644
- name: Update libraries
command: ldconfig
when: not oci_file.stat.exists
---
# file: roles/php/tasks/oci8.yml
#
# @see OCI8 Install: https://help.ubuntu.com/community/PHPOracle
# Better:
# @see PDO_OCI Install: https://drupal.org/comment/5572626#comment-5572626
- name: "PHP | OCI | Enable OCI for PHP"
copy:
content='extension={{ item }}.so'
dest=/etc/{{ php_base_dir }}/{{ php_conf_dir }}/{{ item }}.ini
owner=root
group=root
mode=0644
with_items:
- oci8
- pdo_oci
- name: "PHP | OCI | Remove possible components in /tmp"
command: rm -Rf /tmp/{{ item }}
with_items:
- instantclient_11_2
- oracle_x64_11_2_0_3_0_oci8_so
- oracle_x64_11_2_0_3_0_pdo_oci_so
- name: "PHP | OCI | Make available Oracle InstantClient"
command: scp -r {{ repository }}{{ item }} /tmp/
become: no
with_items:
- instantclient_11_2
- oracle_x64_11_2_0_3_0_oci8_so
- oracle_x64_11_2_0_3_0_pdo_oci_so
- name: "PHP | OCI | Remove /usr/local/lib/instantclient_11_2"
command: rm -Rf /usr/local/lib/instantclient_11_2
- name: "PHP | OCI | Move Oracle InstantClient to /usr/local/lib"
command: mv /tmp/instantclient_11_2 /usr/local/lib/
- name: "PHP | OCI | Move oci8 to /usr/lib/php5"
command: mv /tmp/oracle_x64_11_2_0_3_0_oci8_so /usr/lib/php5/20090626/oci8.so
- name: "PHP | OCI | Move pdo_oci to /usr/lib/php5"
command: mv /tmp/oracle_x64_11_2_0_3_0_pdo_oci_so /usr/lib/php5/20090626/pdo_oci.so
- name: "PHP | OCI | Change ownership for Oracle InstantClient"
file:
path="{{ item }}"
owner="root"
group="root"
recurse=yes
with_items:
- /usr/local/lib/instantclient_11_2
- /usr/lib/php5/20090626/oci8.so
- /usr/lib/php5/20090626/pdo_oci.so
- name: "PHP | OCI | Make available libclntsh.so"
file:
src=/usr/local/lib/instantclient_11_2/libclntsh.so.11.1
dest=/usr/local/lib/instantclient_11_2/libclntsh.so
state=link
--- ---
# file: roles/php/tasks/php.yml # file: roles/php/tasks/php.yml
- name: "PHP | Apt Repository" - name: Apt Repository
apt_repository: apt_repository:
repo='{{ item }}' repo: '{{ item }}'
state='present' state: present
mode=644 mode: 0644
with_items: '{{ php_repositories }}' with_items: '{{ php_repositories }}'
- name: "PHP | Install required packages." - name: Install required packages.
apt: apt:
pkg={{ item }} pkg: '{{ php_packages }}'
state=installed state: present
with_items: '{{ php_packages }}' force: yes
notify: notify:
- "Apache | Restart Apache" - Restart Apache
- name: "PHP | Install PECL packages" - name: Hold em all
shell: 'pecl install oauth' shell: dpkg --get-selections | grep ^sed s/install/hold/g | sudo dpkg --set-selections
when: php_hold_version
- name: "PHP | Ensure Apache config directory" - name: Install PECL packages
shell: pecl install --soft imagick-3.3.0
when: php_version_main|default(7) != 7
ignore_errors: yes
# NOTE: If oauth is already installed and we install a new PHP 7 version then this fails and we need --force as well
- name: Install PECL packages
shell: pecl install --soft --force oauth
when: php_version_main|default(7) == 7
ignore_errors: yes
- name: Ensure Apache config directory
file: file:
dest=/etc/{{ php_base_dir }}/apache2 dest: /etc/{{ php_base_dir }}/apache2
state=directory state: directory
owner=root owner: root
group=root group: root
mode=0755 mode: 0755
- name: "PHP | Configuration file, php.ini" - name: Configuration file, php.ini
template: template:
src=etc-php5-apache2-php.ini src: etc-php5-apache2-php.ini
dest=/etc/{{ php_base_dir }}/apache2/php.ini dest: /etc/{{ php_base_dir }}/apache2/php.ini
owner=root owner: root
group=root group: root
mode=0644 mode: 0644
notify: notify:
- "Apache | Restart Apache" - Restart Apache
- include: php53.yml - name: Import php53
import_tasks: php53.yml
when: php_version|default('5.5') == '5.3' when: php_version|default('5.5') == '5.3'
- name: "PHP | Configuration file, fcgid.conf" - name: Configuration file, fcgid.conf
template: template:
src=fcgid.conf src: fcgid.conf
dest=/etc/apache2/mods-available/fcgid.conf dest: /etc/apache2/mods-available/fcgid.conf
owner=root owner: root
group=root group: root
mode=0644 mode: 0644
notify: notify:
- "Apache | Restart Apache" - Restart Apache
- name: "PHP | Cache configuration file, opcache.ini" - name: Configuration files
template: template:
src=etc-php5-conf-d-opcache.ini src: etc-php5-conf-d-{{ item }}.ini
dest=/etc/{{ php_base_dir }}/{{ php_conf_dir }}/opcache.ini dest: /etc/{{ php_base_dir }}/{{ php_conf_dir }}/{{ item }}.ini
owner=root owner: root
group=root group: root
mode=0644 mode: 0644
with_items:
- apcu
- opcache
notify: notify:
- "Apache | Restart Apache" - Restart Apache
- name: "PHP | Create extra directory for browscap" - name: Create extra directory for browscap
file: file:
dest=/etc/{{ php_base_dir }}/apache2/extra dest: /etc/{{ php_base_dir }}/apache2/extra
state=directory state: directory
owner=root owner: root
group=root group: root
when: php_browscap when: php_browscap
- name: "PHP | browscap.ini" - name: browscap.ini
copy: copy:
src=browscap.ini src: browscap.ini
dest=/etc/{{ php_base_dir }}/apache2/extra/browscap.ini dest: /etc/{{ php_base_dir }}/apache2/extra/browscap.ini
owner=root owner: root
group=root group: root
when: php_browscap when: php_browscap
notify: notify:
- "Apache | Restart Apache" - Restart Apache
- name: "PHP | Enable PHP modules"
shell: php5enmod {{ item }}
with_items:
- mcrypt
- imap
- imagick
when: php_version|default('5.5') != '7' and php_conf_dir == 'mods-available'
notify:
- "Apache | Restart Apache"
- name: "PHP | Create htdocs directory for apc status" - name: Create htdocs directory for apc status
file: file:
dest=/var/www/apc dest: /var/www/apc
state=directory state: directory
owner=www-data owner: www-data
group=www-data group: www-data
- name: "PHP | Copy APC status php script" - name: Copy APC status php script
copy: copy:
src=apc.php src: apc.php
dest=/var/www/apc dest: /var/www/apc
owner=www-data owner: www-data
group=www-data group: www-data
- name: "PHP | Check OCI Requirement" - name: Include oci version
shell: ls /usr/lib/php5/20090626/pdo_oci.so include_tasks: oci-{{ php_version|default('5.5') }}.yml
register: oci_available when: repository is defined and php_needs_oci8
when: php_needs_oci8
ignore_errors: yes - name: Include mcrypt
changed_when: oci_available.stdout != '/usr/lib/php5/20090626/pdo_oci.so' include_tasks: mcrypt-7.2.yml
notify: when: php_version|default('5.5') == '7.2' and php_needs_mcrypt
- "Apache | Restart Apache"
- name: Import msodbc
- include: oci.yml import_tasks: msodbc.yml
when: repository is defined and php_needs_oci8 and oci_available.stdout != '/usr/lib/php5/20090626/pdo_oci.so' when: php_needs_msodbc
- name: "PHP | Ensure ImageMagick config directory" - block:
file:
dest=/etc/ImageMagick - name: Apache FPM Socket Configuration
state=directory template:
owner=root src: etc-apache2-conf-available-php-fpm
group=root dest: /etc/apache2/{{ apache_conf_dir }}/php{{ php_version_main }}-fpm.conf
mode=0755 owner: root
group: root
- name: "PHP | ImageMagick Policy File" mode: 0644
notify:
- Restart Apache
- name: Enable Apache PHP FPM Configuration
command: a2enconf php{{ php_version_main }}-fpm
args:
creates: /etc/apache2/conf-enabled/php{{ php_version_main }}-fpm{{ apache_conf_ext }}
notify:
- Restart Apache
when: php_fpm_socket
- name: FPM Default Pool Configuration
template: template:
src=etc-imagemagick-policy.xml src: php_pool.conf
dest=/etc/ImageMagick/policy.xml dest: /etc/{{ php_base_dir }}/fpm/pool.d/default.conf
owner=root owner: root
group=root group: root
mode=0644 mode: 0644
when: (php_version_main|default(7) == 7) and php_fpm and apache_server_default
notify:
- Restart PHP-FPM
- block:
- name: Set facts for PHP 7
set_fact:
phpLogRotatePrefix: '{{php_version|default("7.0")}}'
phpLibPrefix: ''
when: php_version_main|default(7) == 7
- name: Set facts for PHP 5
set_fact:
phpLogRotatePrefix: '5'
phpLibPrefix: '5'
when: php_version_main|default(7) != 7
- name: Install logrotate script
template:
src: etc-logrotate-php
dest: /etc/logrotate.d/php{{ phpLogRotatePrefix }}-fpm
owner: root
group: root
mode: 0644
notify:
- Initial Logrotate
- name: Adjust apache config for default site
lineinfile:
dest: /etc/apache2/sites-available/{{ apache_conf_default_prefix }}default{{ apache_conf_ext }}
regexp: '{{ item.regexp }}'
line: '{{ item.line }}'
backrefs: yes
with_items:
- regexp: 'ProxyPassMatch'
line: ' ProxyPassMatch ^/(.*\.php(/.*)?)$ fcgi://127.0.0.1:{{ php_fpm_port|default(9999) }}/var/www{{apache_server_default_root}}/$1'
- regexp: '<Proxy fcgi'
line: ' <Proxy fcgi://127.0.0.1:{{ php_fpm_port|default(9999) }}>'
when: apache_server_default
notify:
- Restart PHP-FPM
- Restart Apache
when: php_fpm
tags:
- logrotate
- name: Explicitly set PHP version for CLI
alternatives:
name: php
path: /usr/bin/php{{ php_version }}
...@@ -3,142 +3,161 @@ ...@@ -3,142 +3,161 @@
--- ---
# file: roles/php/tasks/php53.yml # file: roles/php/tasks/php53.yml
- name: "Ensure PHP53 config directory" - name: Ensure PHP53 config directory
file: file:
dest='{{ item }}' dest: '{{ item }}'
state='directory' state: directory
with_items: with_items:
- '/etc/{{ php_base_dir }}/fpm/pool.d/' - /etc/{{ php_base_dir }}/fpm/pool.d/
- name: "Check PHP 5.3 Requirement" - name: Check PHP 5.3 Requirement
shell: php --version shell: php --version
register: php_version_available register: php_version_available
changed_when: false changed_when: no
- block: - block:
- name: "Package Preferences" - name: Package Preferences
template: template:
src='preferences/{{ item }}' src: preferences/{{ item }}
dest='/etc/apt/preferences.d/{{ item }}-pin' dest: /etc/apt/preferences.d/{{ item }}-pin
owner='root' owner: root
group='root' group: root
mode='644' mode: 0644
with_items: with_items:
- 'openssl' - openssl
- 'libssl' - libssl
- name: "Install Packages" - name: Install Packages
apt: apt:
pkg={{ item }} pkg: '{{ packages }}'
state=installed state: present
with_items: vars:
- 'build-essential' packages:
- 'libfcgi-dev' - autoconf2.13
- 'libfcgi0ldbl' - automake1.4
- 'libjpeg62-dbg' - build-essential
- 'libmcrypt-dev' - libc-client2007e
- 'libssl-dev' - libc-client2007e-dev
- 'libc-client2007e' - libfcgi-dev
- 'libc-client2007e-dev' - libfcgi0ldbl
- 'libxml2-dev' - libfreetype6-dev
- 'libcurl4-openssl-dev' - libgif-dev
- 'libpng-dev' - libgif4
- 'libjpeg-progs' - libjpeg-progs
- 'autoconf2.13' - libjpeg62-dbg
- 'automake1.4' - libjpeg8
- libjpeg8-dev
- name: "Link Client Lib" - libmcrypt-dev
file: - libmysqlclient-dev
src='/usr/lib/x86_64-linux-gnu/libc-client.a' - libpcre++-dev
dest='/usr/lib/libc-client.a' - libpcre3-dev
state='link' - libpng-dev
force=yes - libssl-dev
- libx11-dev
- name: "Make sure an empty directory /tmp/php53 exists" - libxau-dev
file: - libxcb1-dev
path='/tmp/php53' - libxdmcp-dev
state='{{ item }}' - libxml2-dev
with_items: - libxml2-dev
- absent - libxpm-dev
- directory - x11proto-core-dev
- x11proto-input-dev
- name: "Download PHP 5.3" - x11proto-kb-dev
get_url: - xtrans-dev
url='http://in1.php.net/distributions/php-5.3.29.tar.bz2'
dest='/tmp/php-5.3.29.tar.bz2' - name: Link Client Lib
file:
- name: "Unpack PHP 5.3" src: /usr/lib/libc-client.a
unarchive: dest: /usr/lib/x86_64-linux-gnu/libc-client.a
src='/tmp/php-5.3.29.tar.bz2' state: link
dest='/tmp/php53'
copy=no - name: Make sure an empty directory /tmp/php53 exists
file:
- name: "Compile PHP 5.3" path: /tmp/php53
shell: "{{ item }} chdir=/tmp/php53/php-5.3.29" state: '{{ item }}'
with_items: with_items:
- ./configure --with-libdir=/lib/x86_64-linux-gnu --enable-fpm --enable-mbstring --enable-sockets --with-zlib --enable-zip --with-imap-ssl --with-imap --with-curl --with-mcrypt --with-gd --with-mysql --with-pdo-mysql --with-mysqli --with-gettext --with-jpeg-dir=/usr --with-png-dir=/usr --with-kerberos --with-openssl --disable-cgi - absent
- make - directory
- make install
- name: Download PHP 5.3
- name: "Create PHP53 Start Script" get_url:
template: url: 'http://in1.php.net/distributions/php-5.3.29.tar.bz2'
src='etc-init-d-php53-fpm' dest: /tmp/php-5.3.29.tar.bz2
dest='/etc/init.d/php-fpm'
owner='root' - name: Unpack PHP 5.3
group='root' unarchive:
mode='755' src: /tmp/php-5.3.29.tar.bz2
dest: /tmp/php53
- name: "Add PHP-FPM to Boot-List" copy: no
command: update-rc.d php-fpm defaults
- name: Compile PHP 5.3
when: '"PHP 5.3.29" not in php_version_available.stdout' shell: '{{ item }}'
args:
- name: "Copy PHP53 Libraries" chdir: /tmp/php53/php-5.3.29
with_items:
- ./configure --with-libdir=/lib/x86_64-linux-gnu --enable-fpm --enable-mbstring --enable-sockets --with-zlib --enable-zip --with-imap-ssl --with-imap --with-curl --with-mcrypt --with-gd --with-mysql --with-pdo-mysql --with-mysqli --with-gettext --with-jpeg-dir=/usr --with-png-dir=/usr --with-kerberos --with-openssl --disable-cgi
- make
- make install
- name: Create PHP53 Start Script
template:
src: etc-init-d-php53-fpm
dest: /etc/init.d/php-fpm
owner: root
group: root
mode: 0755
- name: Add PHP-FPM to Boot-List
command: update-rc.d php-fpm defaults
when: php_version_available and 'PHP 5.3.29' not in php_version_available.stdout
- name: Copy PHP53 Libraries
copy: copy:
src='php53/libs/{{ item.file }}' src: php53/libs/{{ item.file }}
dest='{{ php53.libdir }}/{{ item.file }}' dest: '{{ php53.libdir }}/{{ item.file }}'
owner='root' owner: root
group='root' group: root
mode='644' mode: 0644
with_items: '{{ php53.libraries }}' with_items: '{{ php53.libraries }}'
- name: "Ensure PHP53 Library Links" - name: Ensure PHP53 Library Links
file: file:
src='{{ php53.libdir }}/{{ item.file }}' src: '{{ php53.libdir }}/{{ item.file }}'
dest='{{ php53.libdir }}/{{ item.link }}' dest: '{{ php53.libdir }}/{{ item.link }}'
state='link' state: link
owner='root' owner: root
group='root' group: root
mode='644' mode: 0644
with_items: '{{ php53.libraries }}' with_items: '{{ php53.libraries }}'
- name: "Ensure extra Library Links" - name: Ensure extra Library Links
file: file:
src='{{ item.src }}' src: '{{ item.src }}'
dest='{{ php53.libdir }}/{{ item.link }}' dest: '{{ php53.libdir }}/{{ item.link }}'
state='link' state: link
owner='root' owner: root
group='root' group: root
mode='644' mode: 0644
with_items: '{{ php53.liblinks }}' with_items: '{{ php53.liblinks }}'
- name: "Copy PHP53 Modules" - name: Copy PHP53 Modules
copy: copy:
src='php53/{{ item }}.so' src: php53/{{ item }}.so
dest='{{ php53.extdir }}/{{ item }}.so' dest: '{{ php53.extdir }}/{{ item }}.so'
owner='root' owner: root
group='root' group: root
mode='644' mode: 0644
with_items: '{{ php53.modules }}' with_items: '{{ php53.modules }}'
- name: "Create PHP53 INI Files" - name: Create PHP53 INI Files
template: template:
src='etc-php5-apache2-php.ini' src: etc-php5-apache2-php.ini
dest='/etc/{{ php_base_dir }}/{{ item }}/php.ini' dest: /etc/{{ php_base_dir }}/{{ item }}/php.ini
owner='root' owner: root
group='root' group: root
mode='644' mode: 0644
with_items: with_items:
- 'cgi53' - cgi53
- 'cli53' - cli53
- 'fpm' - fpm
---
# file: roles/php/tasks/variables.yml
- block:
- name: Set default facts
set_fact:
phpFpmService: php5-fpm
- name: Set facts for PHP 5
set_fact:
phpFpmService: php-fpm
when: php_version_main|default(7) == 5
- name: Set facts for PHP 7
set_fact:
phpFpmService: php{{php_version|default("7.0")}}-fpm
when: php_version_main|default(7) == 7
tags:
- always
<IfModule mod_fastcgi.c>
AddHandler php{{ php_version_main }}-fcgi .php
Action php{{ php_version_main }}-fcgi /php{{ php_version_main }}-fcgi
Alias /php{{ php_version_main }}-fcgi /usr/lib/cgi-bin/php{{ php_version_main }}-fcgi
FastCgiExternalServer /usr/lib/cgi-bin/php{{ php_version_main }}-fcgi -socket /var/run/php{{ php_version_main }}-fpm.sock -pass-header Authorization
<Directory /usr/lib/cgi-bin>
Include /etc/apache2/{{ apache_conf_dir }}/global-deny.conf
</Directory>
</IfModule>