forked from UnionOfRAD/lithium
-
Notifications
You must be signed in to change notification settings - Fork 0
/
ci_depends.php
114 lines (102 loc) · 2.69 KB
/
ci_depends.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
#!/usr/bin/env php
<?php
set_time_limit(0);
$installer = new PhpExtensions();
if (isset($argv[1]) && 'APC' === strtoupper($argv[1])) {
$installer->install('apc');
} else {
$installer->install('xcache');
}
$installer->install('memcached');
$installer->install('mongo');
class PhpExtensions {
protected $extensions;
protected $phpVersion;
protected $iniPath;
public function __construct() {
$this->phpVersion = phpversion();
$this->iniPath = php_ini_loaded_file();
$this->extensions = array(
'memcached' => array(
'url' => 'http://pecl.php.net/get/memcached-2.0.1.tgz',
'require' => array(),
'configure' => array(),
'ini' => array(
'extension=memcached.so'
)
),
'apc' => array(
'url' => 'http://pecl.php.net/get/APC-3.1.10.tgz',
'require' => array(),
'configure' => array(),
'ini' => array(
'extension=apc.so',
'apc.enabled=1',
'apc.enable_cli=1'
)
),
'xcache' => array(
'url' => 'http://xcache.lighttpd.net/pub/Releases/1.3.2/xcache-1.3.2.tar.gz',
'require' => array(
'php' => array('<', '5.4')
),
'configure' => array('--enable-xcache'),
'ini' => array(
'extension=xcache.so',
'xcache.cacher=false',
'xcache.admin.enable_auth=0',
'xcache.var_size=1M'
)
),
'mongo' => array(
'url' => 'http://pecl.php.net/get/mongo-1.2.7.tgz',
'require' => array(),
'configure' => array(),
'ini' => array(
'extension=mongo.so'
)
)
);
}
public function install($name) {
if (array_key_exists($name, $this->extensions)) {
$extension = $this->extensions[$name];
echo $name;
if (isset($extension['require']['php'])) {
$version = $extension['require']['php'];
if (!version_compare($this->phpVersion, $version[1], $version[0])) {
printf(
" => not installed, requires a PHP version %s %s (%s installed)\n",
$version[0],
$version[1],
$this->phpVersion
);
return;
}
}
$this->system(sprintf("wget %s > /dev/null 2>&1", $extension['url']));
$file = basename($extension['url']);
$this->system(sprintf("tar -xzf %s > /dev/null 2>&1", $file));
$folder = basename($file, ".tgz");
$folder = basename($folder, ".tar.gz");
$this->system(sprintf(
'sh -c "cd %s && phpize && ./configure %s && make && sudo make install" > /dev/null 2>&1',
$folder,
implode(' ', $extension['configure'])
));
foreach ($extension['ini'] as $ini) {
$this->system(sprintf("echo %s >> %s", $ini, $this->iniPath));
}
printf("=> installed (%s)\n", $folder);
}
}
private function system($cmd) {
$ret = 0;
system($cmd, $ret);
if (0 !== $ret) {
printf("=> Command '%s' failed !", $cmd);
exit($ret);
}
}
}
?>