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 (80)
Showing with 1149 additions and 739 deletions
php_install_redis: true
php_hold_version: false
---
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_packages:
- php-apc
- php-imagick
- php-pear
- php-soap
- php-uploadprogress
- php5
- php5-cgi
- php5-cli
......@@ -17,84 +27,94 @@ php_packages:
- php5-mysql
- php5-xdebug
- php5-xmlrpc
- imagemagick
php_base_dir: 'php5'
php_conf_dir: 'conf.d'
php_base_dir: php5
php_conf_dir: conf.d
php_allow_call_time_pass_reference: 'on'
php_browscap: false
php_date_timezone: 'Europe/Berlin'
php_browscap: no
php_date_timezone: Europe/Berlin
php_display_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_filter_default: 'unsafe_raw'
php_filter_default: unsafe_raw
php_html_errors: 'Off'
php_log_errors: 'On'
php_magic_quotes_gpc: 'On'
php_max_execution_time: '30'
php_max_file_uploads: '20'
php_max_input_vars: '1000'
php_memory_limit: '32M'
php_needs_oci8: false
php_post_max_size: '32M'
php_max_execution_time: 30
php_max_file_uploads: 20
php_max_input_time: 60
php_max_input_vars: 1000
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_long_arrays: 'On'
php_sendmail_path: '/usr/sbin/sendmail -t -i'
php_session_cache_expire: '180'
php_session_cookie_lifetime: '0'
php_session_gc_divisor: '1000'
php_session_gc_maxlifetime: '1440'
php_sendmail_path: /usr/sbin/sendmail -t -i
php_session_cache_expire: 180
php_session_cookie_lifetime: 0
php_session_gc_divisor: 1000
php_session_gc_maxlifetime: 1440
php_short_open_tag: 'Off'
php_upload_max_filesize: '2M'
php_zend_assertions: '-1'
php_upload_max_filesize: 2M
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_rfc1867: '1'
apc_shm_size: '256M'
apc_shm_segments: '1'
apc_num_files_hint: '0'
apc_ttl: '7200'
apc_user_ttl: '7200'
apc_gc_ttl: '3600'
apc_rfc1867: 1
apc_shm_size: 32M
apc_shm_segments: 1
apc_num_files_hint: 0
apc_ttl: 7200
apc_user_ttl: 7200
apc_gc_ttl: 3600
# opcache.ini
opcache_memory_consumption: '128'
opcache_max_accelerated_files: '7963'
opcache_revalidate_freq: '30'
opcache_interned_strings_buffer: '16'
opcache_memory_consumption: 128
opcache_max_accelerated_files: 7963
opcache_revalidate_freq: 30
opcache_interned_strings_buffer: 16
# php 5.3
php53:
libraries:
- file: 'libgd.so.2.0.0'
link: 'libgd.so.2'
- file: 'liblcms.so.1.0.19'
link: 'liblcms.so.1'
- file: 'libMagickCore.so.4.0.1'
link: 'libMagickCore.so.4'
- file: 'libMagickWand.so.4.0.1'
link: 'libMagickWand.so.4'
- file: 'libt1.so.5.1.2'
link: 'libt1.so.5'
- file: libgd.so.2.0.0
link: libgd.so.2
- file: liblcms.so.1.0.19
link: liblcms.so.1
- file: libMagickCore.so.4.0.1
link: libMagickCore.so.4
- file: libMagickWand.so.4.0.1
link: libMagickWand.so.4
- file: libt1.so.5.1.2
link: libt1.so.5
liblinks:
- src: '/lib/x86_64-linux-gnu/libpng12.so.0'
link: 'libpng12.so.0'
- src: /lib/x86_64-linux-gnu/libpng12.so.0
link: libpng12.so.0
modules:
- 'apc'
- 'curl'
- 'gd'
- 'imagick'
- 'imap'
#- 'json'
- 'mcrypt'
#- 'memcached'
- 'mysql'
- 'mysqli'
- 'pdo_mysql'
#- 'readline'
- 'redis'
- 'xmlrpc'
extdir: '/usr/local/lib/php/extensions/no-debug-non-zts-20090626'
libdir: '/usr/lib/x86_64-linux-gnu'
- apc
- curl
- gd
- imagick
- imap
# - json
- mcrypt
# - memcached
- mysql
- mysqli
- pdo_mysql
# - readline
- redis
- xmlrpc
extdir: /usr/local/lib/php/extensions/no-debug-non-zts-20090626
libdir: /usr/lib/x86_64-linux-gnu
......@@ -22,7 +22,7 @@
*/
$VERSION='$Id: apc.php 307048 2011-01-03 23:53:17Z kalle $';
$VERSION='$Id$';
////////// READ OPTIONAL CONFIGURATION FILE ////////////
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 ///////////////////////////////////////////////////////////
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
// 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!
// If set to 1:
// You need to change ADMIN_PASSWORD to make
......@@ -41,7 +41,7 @@ defaults('USE_AUTHENTICATION',1); // Use (internal) authentication - best choi
defaults('ADMIN_USERNAME','apc'); // Admin Username
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
//defaults('DATE_FORMAT', "d.m.Y H:i:s"); // German
......@@ -61,7 +61,7 @@ function defaults($d,$v) {
// 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();
$host = php_uname('n');
if($host) { $host = '('.$host.')'; }
......@@ -71,10 +71,8 @@ if (isset($_SERVER['SERVER_ADDR'])) {
// operation constants
define('OB_HOST_STATS',1);
define('OB_SYS_CACHE',2);
define('OB_USER_CACHE',3);
define('OB_SYS_CACHE_DIR',4);
define('OB_VERSION_CHECK',9);
define('OB_USER_CACHE',2);
define('OB_VERSION_CHECK',3);
// check validity of input variables
$vardom=array(
......@@ -91,12 +89,9 @@ $vardom=array(
'SORT1' => '/^[AHSMCDTZ]$/', // first sort key
'SORT2' => '/^[DA]$/', // second sort key
'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
$scope_list=array(
'A' => 'cache_list',
......@@ -169,34 +164,30 @@ if (!USE_AUTHENTICATION) {
</body></html>
EOB;
exit;
} else {
$AUTHENTICATED=1;
}
}
}
// select cache mode
if ($AUTHENTICATED && $MYREQUEST['OB'] == OB_USER_CACHE) {
$cache_mode='user';
}
// clear cache
if ($AUTHENTICATED && isset($MYREQUEST['CC']) && $MYREQUEST['CC']) {
apc_clear_cache($cache_mode);
apcu_clear_cache();
}
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.";
exit;
}
$cache_user = apc_cache_info('user', 1);
$mem=apc_sma_info();
if(!$cache['num_hits']) { $cache['num_hits']=1; $time++; } // Avoid division by 0 errors on a cache clear
$cache = apcu_cache_info();
$mem=apcu_sma_info();
// don't cache this page
//
......@@ -241,7 +232,7 @@ if (isset($MYREQUEST['IMG']))
$r=$diameter/2;
$w=deg2rad((360+$start+($end-$start)/2)%360);
if (function_exists("imagefilledarc")) {
// exists only if GD 2.0.1 is avaliable
imagefilledarc($im, $centerX+1, $centerY+1, $diameter, $diameter, $start, $end, $color1, IMG_ARC_PIE);
......@@ -258,13 +249,13 @@ if (isset($MYREQUEST['IMG']))
if ($text) {
if ($placeindex>0) {
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 {
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) {
$r=$diameter/2;
......@@ -272,13 +263,13 @@ if (isset($MYREQUEST['IMG']))
if ($placeindex>0) {
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 {
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='') {
global $col_black;
$x1=$x+$w-1;
......@@ -290,15 +281,15 @@ if (isset($MYREQUEST['IMG']))
imagerectangle($im, $x, $y1, $x1, $y, $color1);
if ($text) {
if ($placeindex>0) {
if ($placeindex<16)
{
$px=5;
$py=$placeindex*12+6;
imagefilledrectangle($im, $px+90, $py+3, $px+90-4, $py-3, $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 {
if ($placeindex<31) {
$px=$x+40*2;
......@@ -309,7 +300,7 @@ if (isset($MYREQUEST['IMG']))
}
imagefilledrectangle($im, $px, $py+3, $px-4, $py-3, $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 {
imagestring($im,4,$x+5,$y1-16,$text,$color1);
......@@ -331,7 +322,7 @@ if (isset($MYREQUEST['IMG']))
imagecolortransparent($image,$col_white);
switch ($MYREQUEST['IMG']) {
case 1:
$s=$mem['num_seg']*$mem['seg_size'];
$a=$mem['avail_mem'];
......@@ -342,7 +333,7 @@ if (isset($MYREQUEST['IMG']))
// would expect because we try to visualize any memory fragmentation as well.
$angle_from = 0;
$string_placement=array();
for($i=0; $i<$mem['num_seg']; $i++) {
for($i=0; $i<$mem['num_seg']; $i++) {
$ptr = 0;
$free = $mem['block_lists'][$i];
uasort($free, 'block_sort');
......@@ -369,7 +360,7 @@ if (isset($MYREQUEST['IMG']))
$angle_from = $angle_to;
$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;
if(($angle_to+$fuzz)>1) $angle_to = 1;
fill_arc($image,$x,$y,$size,$angle_from*360,$angle_to*360,$col_black,$col_red);
......@@ -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])));
}
break;
case 2:
case 2:
$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;
case 3:
$s=$mem['num_seg']*$mem['seg_size'];
$a=$mem['avail_mem'];
......@@ -400,7 +391,7 @@ if (isset($MYREQUEST['IMG']))
// 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.
for($i=0; $i<$mem['num_seg']; $i++) {
for($i=0; $i<$mem['num_seg']; $i++) {
$ptr = 0;
$free = $mem['block_lists'][$i];
uasort($free, 'block_sort');
......@@ -423,7 +414,7 @@ if (isset($MYREQUEST['IMG']))
$y+=$h;
$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;
if ($h > 0) {
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']))
}
}
break;
case 4:
$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));
case 4:
$s=$cache['num_hits']+$cache['num_misses'];
$a=$cache['num_hits'];
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;
}
header("Content-type: image/png");
imagepng($image);
exit;
......@@ -458,15 +450,15 @@ function bsize($s) {
// sortable table header in "scripts for this host" view
function sortheader($key,$name,$extra='') {
global $MYREQUEST, $MY_SELF_WO_SORT;
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>";
}
// create menu entry
// create menu entry
function menu_entry($ob,$title) {
global $MYREQUEST,$MY_SELF;
if ($MYREQUEST['OB']!=$ob) {
......@@ -474,7 +466,7 @@ function menu_entry($ob,$title) {
} else if (empty($MYREQUEST['SH'])) {
return "<li><span class=active>$title</span></li>";
} 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)
?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head><title>APC INFO <?php echo $host ?></title>
<head><title>APCu INFO <?php echo $host ?></title>
<style><!--
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; }
......@@ -626,8 +618,8 @@ ol.menu a:hover {
background:rgb(193,193,244);
text-decoration:none;
}
div.info {
background:rgb(204,204,204);
border:solid rgb(204,204,204) 1px;
......@@ -700,7 +692,7 @@ div.authneeded {
padding:2em;
text-align:center;
}
input {
background:rgb(153,153,204);
border:solid rgb(102,102,153) 2px;
......@@ -715,35 +707,29 @@ input {
<body>
<div class="head">
<h1 class="apc">
<div class="logo"><span class="logo"><a href="http://pecl.php.net/package/APC">APC</a></span></div>
<div class="nameinfo">Opcode Cache</div>
<div class="logo"><span class="logo"><a href="http://pecl.php.net/package/APCu">APCu</a></span></div>
<div class="nameinfo">User Cache</div>
</h1>
<div class="login">
<?php put_login_link(); ?>
</div>
<hr class="apc">
</div>
<?php
<?php
// Display main Menu
echo <<<EOB
<ol class=menu>
<li><a href="$MY_SELF&OB={$MYREQUEST['OB']}&SH={$MYREQUEST['SH']}">Refresh Data</a></li>
EOB;
echo
menu_entry(1,'View Host Stats'),
menu_entry(2,'System Cache Entries');
if ($AUTHENTICATED) {
echo menu_entry(4,'Per-Directory Entries');
}
echo
menu_entry(3,'User Cache Entries'),
menu_entry(9,'Version Check');
menu_entry(OB_HOST_STATS,'View Host Stats'),
menu_entry(OB_USER_CACHE,'User Cache Entries'),
menu_entry(OB_VERSION_CHECK,'Version Check');
if ($AUTHENTICATED) {
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;
}
echo <<<EOB
......@@ -756,14 +742,9 @@ echo <<<EOB
<div class=content>
EOB;
// MAIN SWITCH STATEMENT
// MAIN SWITCH STATEMENT
switch ($MYREQUEST['OB']) {
// -----------------------------------------------
// Host Stats
// -----------------------------------------------
......@@ -772,77 +753,58 @@ case OB_HOST_STATS:
$mem_avail= $mem['avail_mem'];
$mem_used = $mem_size-$mem_avail;
$seg_size = bsize($mem['seg_size']);
$req_rate = sprintf("%.2f",($cache['num_hits']+$cache['num_misses'])/($time-$cache['start_time']));
$hit_rate = sprintf("%.2f",($cache['num_hits'])/($time-$cache['start_time']));
$miss_rate = sprintf("%.2f",($cache['num_misses'])/($time-$cache['start_time']));
$insert_rate = sprintf("%.2f",($cache['num_inserts'])/($time-$cache['start_time']));
$req_rate_user = sprintf("%.2f",($cache_user['num_hits']+$cache_user['num_misses'])/($time-$cache_user['start_time']));
$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');
$req_rate_user = sprintf("%.2f", $cache['num_hits'] ? (($cache['num_hits']+$cache['num_misses'])/($time-$cache['start_time'])) : 0);
$hit_rate_user = sprintf("%.2f", $cache['num_hits'] ? (($cache['num_hits'])/($time-$cache['start_time'])) : 0);
$miss_rate_user = sprintf("%.2f", $cache['num_misses'] ? (($cache['num_misses'])/($time-$cache['start_time'])) : 0);
$insert_rate_user = sprintf("%.2f", $cache['num_inserts'] ? (($cache['num_inserts'])/($time-$cache['start_time'])) : 0);
$apcversion = phpversion('apcu');
$phpversion = phpversion();
$number_files = $cache['num_entries'];
$size_files = bsize($cache['mem_size']);
$number_vars = $cache_user['num_entries'];
$size_vars = bsize($cache_user['mem_size']);
$number_vars = $cache['num_entries'];
$size_vars = bsize($cache['mem_size']);
$i=0;
echo <<< EOB
<div class="info div1"><h2>General Cache Information</h2>
<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>
EOB;
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']))
echo "<tr class=tr-1><td class=td-0>Server Software</td><td>{$_SERVER['SERVER_SOFTWARE']}</td></tr>\n";
echo <<<EOB
<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)
<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)
</td></tr>
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-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
</tbody></table>
</div>
<div class="info div1"><h2>File Cache Information</h2>
<table cellspacing=0><tbody>
<tr class=tr-0><td class=td-0>Cached Files</td><td>$number_files ($size_files)</td></tr>
<tr class=tr-1><td class=td-0>Hits</td><td>{$cache['num_hits']}</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>Request Rate (hits, misses)</td><td>$req_rate cache requests/second</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>Miss Rate</td><td>$miss_rate 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>Cache full count</td><td>{$cache['expunges']}</td></tr>
</tbody></table>
</div>
<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 class="info div1"><h2>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['num_hits']}</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>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['expunges']}</td></tr>
</tbody>
</table>
</div>
<div class="info div2"><h2>Runtime Settings</h2><table cellspacing=0><tbody>
EOB;
$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";
$j = 1 - $j;
}
......@@ -860,7 +822,7 @@ EOB;
<table cellspacing=0><tbody>
EOB;
$size='width='.(GRAPH_SIZE+50).' height='.(GRAPH_SIZE+10);
echo <<<EOB
echo <<<EOB
<tr>
<td class=td-0>$mem_note</td>
<td class=td-1>Hits &amp; Misses</td>
......@@ -868,18 +830,18 @@ EOB;
EOB;
echo
graphics_avail() ?
graphics_avail() ?
'<tr>'.
"<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"
: "",
'<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-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>',
'<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-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";
echo <<< EOB
</tr>
</tbody></table>
......@@ -906,7 +868,7 @@ EOB;
}
$freeseg += count($mem['block_lists'][$i]);
}
if ($freeseg > 1) {
$frag = sprintf("%.2f%% (%s out of %s in %d fragments)", ($fragsize/$freetotal)*100,bsize($fragsize),bsize($freetotal),$freeseg);
} else {
......@@ -936,7 +898,7 @@ EOB;
</tbody></table>
</div>
EOB;
break;
......@@ -954,71 +916,13 @@ case OB_USER_CACHE:
$fieldheading='User Entry Label';
$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;
echo <<<EOB
<div class=sorting><form>Scope:
<input type=hidden name=OB value={$MYREQUEST['OB']}>
<select name=SCOPE>
EOB;
echo
echo
"<option value=A",$MYREQUEST['SCOPE']=='A' ? " selected":"",">Active</option>",
"<option value=D",$MYREQUEST['SCOPE']=='D' ? " selected":"",">Deleted</option>",
"</select>",
......@@ -1032,7 +936,7 @@ EOB;
"<option value=D",$MYREQUEST['SORT1']=='D' ? " selected":"",">Deleted at</option>";
if($fieldname=='info') echo
"<option value=D",$MYREQUEST['SORT1']=='T' ? " selected":"",">Timeout</option>";
echo
echo
'</select>',
'<select name=SORT2>',
'<option value=D',$MYREQUEST['SORT2']=='D' ? ' selected':'','>DESC</option>',
......@@ -1081,16 +985,17 @@ EOB;
// builds list with alpha numeric sortable keys
//
$list = array();
foreach($cache[$scope_list[$MYREQUEST['SCOPE']]] as $i => $entry) {
switch($MYREQUEST['SORT1']) {
case 'A': $k=sprintf('%015d-',$entry['access_time']); break;
case 'H': $k=sprintf('%015d-',$entry['num_hits']); break;
case 'Z': $k=sprintf('%015d-',$entry['mem_size']); break;
case 'M': $k=sprintf('%015d-',$entry['mtime']); break;
case 'C': $k=sprintf('%015d-',$entry['creation_time']); break;
case 'T': $k=sprintf('%015d-',$entry['ttl']); break;
case 'D': $k=sprintf('%015d-',$entry['deletion_time']); break;
case 'S': $k=''; break;
case 'A': $k=sprintf('%015d-',$entry['access_time']); break;
case 'H': $k=sprintf('%015d-',$entry['num_hits']); break;
case 'Z': $k=sprintf('%015d-',$entry['mem_size']); break;
case 'M': $k=sprintf('%015d-',$entry['mtime']); break;
case 'C': $k=sprintf('%015d-',$entry['creation_time']); break;
case 'T': $k=sprintf('%015d-',$entry['ttl']); break;
case 'D': $k=sprintf('%015d-',$entry['deletion_time']); break;
case 'S': $k=$entry["info"]; break;
}
if (!$AUTHENTICATED) {
// hide all path entries if not logged in
......@@ -1101,22 +1006,22 @@ EOB;
}
if ($list) {
// sort list
//
switch ($MYREQUEST['SORT2']) {
case "A": krsort($list); break;
case "D": ksort($list); break;
}
// output list
$i=0;
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');
echo
'<tr class=tr-',$i%2,'>',
"<td class=td-0><a href=\"$MY_SELF&OB=",$MYREQUEST['OB'],"&SH=",md5($entry[$fieldkey]),"\">",$field_value,'</a></td>',
'<tr id="key-'. $sh .'" class=tr-',$i%2,'>',
"<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 right">',$entry['mem_size'],'</td>',
'<td class="td-n center">',date(DATE_FORMAT,$entry['access_time']),'</td>',
......@@ -1141,141 +1046,19 @@ EOB;
echo '<td class="td-last center"> &nbsp; </td>';
}
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++;
if ($i == $MYREQUEST['COUNT'])
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 {
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
</tbody></table>
......@@ -1295,7 +1078,7 @@ EOB;
// -----------------------------------------------
case OB_VERSION_CHECK:
echo <<<EOB
<div class="info"><h2>APC Version Information</h2>
<div class="info"><h2>APCu Version Information</h2>
<table cellspacing=0><tbody>
<tr>
<th></th>
......@@ -1303,24 +1086,24 @@ case OB_VERSION_CHECK:
EOB;
if (defined('PROXY')) {
$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 {
$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) {
echo '<tr class="td-last center"><td>Unable to fetch version information.</td></tr>';
} 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>';
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;
} else {
echo '<div class="failed">You are running an older version of APC ('.$apcversion.'),
newer version '.$match[1].' is available at <a href="http://pecl.php.net/package/APC/'.$match[1].'">
http://pecl.php.net/package/APC/'.$match[1].'</a>
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/APCu/'.$match[1].'">
http://pecl.php.net/package/APCu/'.$match[1].'</a>
</div>';
$i = -1;
}
......@@ -1328,18 +1111,19 @@ EOB;
echo '<tr class="tr-0"><td><h3>Change Log:</h3><br/>';
preg_match_all('!<(title|description)>([^<]+)</\\1>!', $rss, $match);
next($match[2]); next($match[2]);
$changelog = $match[2];
while (list(,$v) = each($match[2])) {
list(,$ver) = explode(' ', $v, 2);
for ($j = 2; $j + 1 < count($changelog); $j += 2) {
$v = $changelog[$j];
if ($i < 0 && version_compare($apcversion, $ver, '>=')) {
break;
} else if (!$i--) {
break;
}
echo "<b><a href=\"http://pecl.php.net/package/APC/$ver\">".htmlspecialchars($v, ENT_QUOTES, 'UTF-8')."</a></b><br><blockquote>";
echo nl2br(htmlspecialchars(current($match[2]), ENT_QUOTES, 'UTF-8'))."</blockquote>";
next($match[2]);
list($unused, $ver) = $v;
$changes = $changelog[$j + 1];
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>';
}
......
---
# file: roles/php/handlers/main.yml
- name: "Restart PHP-FPM"
- name: Restart PHP-FPM
service:
name: '{{ phpFpmService|default("php7.0-fpm") }}'
state: 'restarted'
name: '{{ phpFpmService }}'
state: restarted
- name: Initial Logrotate
shell: logrotate -f /etc/logrotate.d/php{{ phpLogRotatePrefix }}-fpm
......@@ -2,3 +2,4 @@
dependencies:
- { role: apache }
- { role: imagemagick }
......@@ -5,17 +5,36 @@
---
# file: roles/php/tasks/main.yml
- name: "PHP Role"
set_fact: role_php_started=true
tags: always
- name: PHP Role
set_fact:
role_php_started: yes
tags:
- always
- block:
- include: php.yml
when: role_php_completed is not defined
- name: Include variables
include_tasks: variables.yml
tags:
- always
- name: 'PHP | Remember that this role had been run'
set_fact: role_php_completed=true
tags: always
- name: Import php
import_tasks: php.yml
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='644'
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
- name: "PHP | Apt Repository"
- name: Apt Repository
apt_repository:
repo='{{ item }}'
state='present'
mode='644'
repo: '{{ item }}'
state: present
mode: 0644
with_items: '{{ php_repositories }}'
- name: "PHP | Install required packages."
- name: Install required packages.
apt:
pkg={{ item }}
state=installed
force=yes
with_items: '{{ php_packages }}'
pkg: '{{ php_packages }}'
state: present
force: yes
notify:
- "Apache | Restart Apache"
- Restart Apache
- name: "PHP | Hold em all"
shell: dpkg --get-selections | grep ^php | sed s/install/hold/g | sudo dpkg --set-selections
- name: Hold em all
shell: dpkg --get-selections | grep ^sed s/install/hold/g | sudo dpkg --set-selections
when: php_hold_version
- name: "PHP | Install PECL packages"
shell: 'pecl install --soft imagick-3.3.0'
when: php_version|default('5.5') != '7'
ignore_errors: true
- name: Install PECL packages
shell: pecl install --soft imagick-3.3.0
when: php_version_main|default(7) != 7
ignore_errors: yes
- name: "PHP | Install PECL packages"
shell: 'pecl install --soft oauth'
when: php_version|default('5.5') == '7'
ignore_errors: true
# 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: "PHP | Ensure Apache config directory"
- name: Ensure Apache config directory
file:
dest=/etc/{{ php_base_dir }}/apache2
state=directory
owner=root
group=root
mode='755'
dest: /etc/{{ php_base_dir }}/apache2
state: directory
owner: root
group: root
mode: 0755
- name: "PHP | Configuration file, php.ini"
- name: Configuration file, php.ini
template:
src=etc-php5-apache2-php.ini
dest=/etc/{{ php_base_dir }}/apache2/php.ini
owner=root
group=root
mode='644'
src: etc-php5-apache2-php.ini
dest: /etc/{{ php_base_dir }}/apache2/php.ini
owner: root
group: root
mode: 0644
notify:
- "Apache | Restart Apache"
- Restart Apache
- include: php53.yml
- name: Import php53
import_tasks: php53.yml
when: php_version|default('5.5') == '5.3'
- name: "PHP | Configuration file, fcgid.conf"
- name: Configuration file, fcgid.conf
template:
src=fcgid.conf
dest=/etc/apache2/mods-available/fcgid.conf
owner=root
group=root
mode='644'
src: fcgid.conf
dest: /etc/apache2/mods-available/fcgid.conf
owner: root
group: root
mode: 0644
notify:
- "Apache | Restart Apache"
- Restart Apache
- name: "PHP | Cache configuration file, opcache.ini"
- name: Configuration files
template:
src=etc-php5-conf-d-opcache.ini
dest=/etc/{{ php_base_dir }}/{{ php_conf_dir }}/opcache.ini
owner=root
group=root
mode='644'
src: etc-php5-conf-d-{{ item }}.ini
dest: /etc/{{ php_base_dir }}/{{ php_conf_dir }}/{{ item }}.ini
owner: root
group: root
mode: 0644
with_items:
- apcu
- opcache
notify:
- "Apache | Restart Apache"
- Restart Apache
- name: "PHP | Create extra directory for browscap"
- name: Create extra directory for browscap
file:
dest=/etc/{{ php_base_dir }}/apache2/extra
state=directory
owner=root
group=root
dest: /etc/{{ php_base_dir }}/apache2/extra
state: directory
owner: root
group: root
when: php_browscap
- name: "PHP | browscap.ini"
- name: browscap.ini
copy:
src=browscap.ini
dest=/etc/{{ php_base_dir }}/apache2/extra/browscap.ini
owner=root
group=root
src: browscap.ini
dest: /etc/{{ php_base_dir }}/apache2/extra/browscap.ini
owner: root
group: root
when: php_browscap
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:
dest=/var/www/apc
state=directory
owner=www-data
group=www-data
dest: /var/www/apc
state: directory
owner: www-data
group: www-data
- name: "PHP | Copy APC status php script"
- name: Copy APC status php script
copy:
src=apc.php
dest=/var/www/apc
owner=www-data
group=www-data
- name: "PHP | Check OCI Requirement"
shell: ls /usr/lib/php5/20090626/pdo_oci.so
register: oci_available
when: php_needs_oci8
ignore_errors: yes
changed_when: oci_available.stdout != '/usr/lib/php5/20090626/pdo_oci.so'
notify:
- "Apache | Restart Apache"
src: apc.php
dest: /var/www/apc
owner: www-data
group: www-data
- include: oci.yml
when: repository is defined and php_needs_oci8 and oci_available.stdout != '/usr/lib/php5/20090626/pdo_oci.so'
- name: Include oci version
include_tasks: oci-{{ php_version|default('5.5') }}.yml
when: repository is defined and php_needs_oci8
- name: "PHP | Ensure ImageMagick config directory"
file:
dest=/etc/ImageMagick
state=directory
owner=root
group=root
mode='755'
- name: Include mcrypt
include_tasks: mcrypt-7.2.yml
when: php_version|default('5.5') == '7.2' and php_needs_mcrypt
- name: Import msodbc
import_tasks: msodbc.yml
when: php_needs_msodbc
- name: "PHP | ImageMagick Policy File"
- block:
- name: Apache FPM Socket Configuration
template:
src: etc-apache2-conf-available-php-fpm
dest: /etc/apache2/{{ apache_conf_dir }}/php{{ php_version_main }}-fpm.conf
owner: root
group: root
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:
src=etc-imagemagick-policy.xml
dest=/etc/ImageMagick/policy.xml
owner=root
group=root
mode='644'
src: php_pool.conf
dest: /etc/{{ php_base_dir }}/fpm/pool.d/default.conf
owner: root
group: root
mode: 0644
when: (php_version_main|default(7) == 7) and php_fpm and apache_server_default
notify:
- Restart PHP-FPM
- block:
- set_fact:
phpLogRotatePrefix='7.0'
phpLibPrefix=''
when: php_version|default('5.5') == '7'
- set_fact:
phpLogRotatePrefix='5'
phpLibPrefix='5'
when: php_version|default('5.5') != '7'
- name: "Install logrotate script"
template:
src=etc-logrotate-php
dest=/etc/logrotate.d/php{{ phpLogRotatePrefix }}-fpm
owner=root
group=root
mode='644'
tags: 'logrotate'
- 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,159 +3,161 @@
---
# file: roles/php/tasks/php53.yml
- name: "Ensure PHP53 config directory"
- name: Ensure PHP53 config directory
file:
dest='{{ item }}'
state='directory'
dest: '{{ item }}'
state: directory
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
register: php_version_available
changed_when: false
changed_when: no
- block:
- name: "Package Preferences"
template:
src='preferences/{{ item }}'
dest='/etc/apt/preferences.d/{{ item }}-pin'
owner='root'
group='root'
mode='644'
with_items:
- 'openssl'
- 'libssl'
- name: "Install Packages"
apt:
pkg={{ item }}
state=installed
with_items:
- 'autoconf2.13'
- 'automake1.4'
- 'build-essential'
- 'libc-client2007e'
- 'libc-client2007e-dev'
- 'libcurl4-openssl-dev'
- 'libfcgi-dev'
- 'libfcgi0ldbl'
- 'libfreetype6-dev'
- 'libgif-dev'
- 'libgif4'
- 'libjpeg-progs'
- 'libjpeg62-dbg'
- 'libjpeg8'
- 'libjpeg8-dev'
- 'libmcrypt-dev'
- 'libmysqlclient-dev'
- 'libpcre++-dev'
- 'libpcre3-dev'
- 'libpng-dev'
- 'libssl-dev'
- 'libx11-dev'
- 'libxau-dev'
- 'libxcb1-dev'
- 'libxdmcp-dev'
- 'libxml2-dev'
- 'libxml2-dev'
- 'libxpm-dev'
- 'x11proto-core-dev'
- 'x11proto-input-dev'
- 'x11proto-kb-dev'
- 'xtrans-dev'
- name: "Link Client Lib"
file:
src='/usr/lib/libc-client.a'
dest='/usr/lib/x86_64-linux-gnu/libc-client.a'
state='link'
- name: "Make sure an empty directory /tmp/php53 exists"
file:
path='/tmp/php53'
state='{{ item }}'
with_items:
- absent
- directory
- name: "Download PHP 5.3"
get_url:
url='http://in1.php.net/distributions/php-5.3.29.tar.bz2'
dest='/tmp/php-5.3.29.tar.bz2'
- name: "Unpack PHP 5.3"
unarchive:
src='/tmp/php-5.3.29.tar.bz2'
dest='/tmp/php53'
copy=no
- name: "Compile PHP 5.3"
shell: "{{ item }} 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='755'
- name: "Add PHP-FPM to Boot-List"
command: update-rc.d php-fpm defaults
when: '"PHP 5.3.29" not in php_version_available.stdout'
- name: "Copy PHP53 Libraries"
- name: Package Preferences
template:
src: preferences/{{ item }}
dest: /etc/apt/preferences.d/{{ item }}-pin
owner: root
group: root
mode: 0644
with_items:
- openssl
- libssl
- name: Install Packages
apt:
pkg: '{{ packages }}'
state: present
vars:
packages:
- autoconf2.13
- automake1.4
- build-essential
- libc-client2007e
- libc-client2007e-dev
- libfcgi-dev
- libfcgi0ldbl
- libfreetype6-dev
- libgif-dev
- libgif4
- libjpeg-progs
- libjpeg62-dbg
- libjpeg8
- libjpeg8-dev
- libmcrypt-dev
- libmysqlclient-dev
- libpcre++-dev
- libpcre3-dev
- libpng-dev
- libssl-dev
- libx11-dev
- libxau-dev
- libxcb1-dev
- libxdmcp-dev
- libxml2-dev
- libxml2-dev
- libxpm-dev
- x11proto-core-dev
- x11proto-input-dev
- x11proto-kb-dev
- xtrans-dev
- name: Link Client Lib
file:
src: /usr/lib/libc-client.a
dest: /usr/lib/x86_64-linux-gnu/libc-client.a
state: link
- name: Make sure an empty directory /tmp/php53 exists
file:
path: /tmp/php53
state: '{{ item }}'
with_items:
- absent
- directory
- name: Download PHP 5.3
get_url:
url: 'http://in1.php.net/distributions/php-5.3.29.tar.bz2'
dest: /tmp/php-5.3.29.tar.bz2
- name: Unpack PHP 5.3
unarchive:
src: /tmp/php-5.3.29.tar.bz2
dest: /tmp/php53
copy: no
- name: Compile PHP 5.3
shell: '{{ item }}'
args:
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:
src='php53/libs/{{ item.file }}'
dest='{{ php53.libdir }}/{{ item.file }}'
owner='root'
group='root'
mode='644'
src: php53/libs/{{ item.file }}
dest: '{{ php53.libdir }}/{{ item.file }}'
owner: root
group: root
mode: 0644
with_items: '{{ php53.libraries }}'
- name: "Ensure PHP53 Library Links"
- name: Ensure PHP53 Library Links
file:
src='{{ php53.libdir }}/{{ item.file }}'
dest='{{ php53.libdir }}/{{ item.link }}'
state='link'
owner='root'
group='root'
mode='644'
src: '{{ php53.libdir }}/{{ item.file }}'
dest: '{{ php53.libdir }}/{{ item.link }}'
state: link
owner: root
group: root
mode: 0644
with_items: '{{ php53.libraries }}'
- name: "Ensure extra Library Links"
- name: Ensure extra Library Links
file:
src='{{ item.src }}'
dest='{{ php53.libdir }}/{{ item.link }}'
state='link'
owner='root'
group='root'
mode='644'
src: '{{ item.src }}'
dest: '{{ php53.libdir }}/{{ item.link }}'
state: link
owner: root
group: root
mode: 0644
with_items: '{{ php53.liblinks }}'
- name: "Copy PHP53 Modules"
- name: Copy PHP53 Modules
copy:
src='php53/{{ item }}.so'
dest='{{ php53.extdir }}/{{ item }}.so'
owner='root'
group='root'
mode='644'
src: php53/{{ item }}.so
dest: '{{ php53.extdir }}/{{ item }}.so'
owner: root
group: root
mode: 0644
with_items: '{{ php53.modules }}'
- name: "Create PHP53 INI Files"
- name: Create PHP53 INI Files
template:
src='etc-php5-apache2-php.ini'
dest='/etc/{{ php_base_dir }}/{{ item }}/php.ini'
owner='root'
group='root'
mode='644'
src: etc-php5-apache2-php.ini
dest: /etc/{{ php_base_dir }}/{{ item }}/php.ini
owner: root
group: root
mode: 0644
with_items:
- 'cgi53'
- 'cli53'
- 'fpm'
- cgi53
- cli53
- 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>