本文整理汇总了PHP中unix::APACHE_LOCATE_PHP_FPM方法的典型用法代码示例。如果您正苦于以下问题:PHP unix::APACHE_LOCATE_PHP_FPM方法的具体用法?PHP unix::APACHE_LOCATE_PHP_FPM怎么用?PHP unix::APACHE_LOCATE_PHP_FPM使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类unix
的用法示例。
在下文中一共展示了unix::APACHE_LOCATE_PHP_FPM方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: php_fpm
function php_fpm($aspid = false)
{
$unix = new unix();
if (is_file("/etc/lsb-release")) {
if ($GLOBALS["VERBOSE"]) {
"CheckSourcesList: Ubuntu system, aborting\n";
}
}
if (!is_file("/etc/debian_version")) {
return;
}
$phpfpm = $unix->APACHE_LOCATE_PHP_FPM();
if (is_file($phpfpm)) {
nginx();
return;
}
if ($aspid) {
$pidfile = "/etc/artica-postfix/pids/" . basename(__FILE__) . "." . __FUNCTION__ . ".pid";
$pidTime = "/etc/artica-postfix/pids/" . basename(__FILE__) . "." . __FUNCTION__ . ".time";
$kill = $unix->find_program("kill");
$timexec = $unix->file_time_min($pidTime);
if ($timexec < 240) {
return;
}
@unlink($pidTime);
@file_put_contents($pidTime, time());
$pid = $unix->get_pid_from_file($pidfile);
if ($unix->process_exists($pid, basename(__FILE__))) {
$time = $unix->PROCCESS_TIME_MIN($pid);
if ($time < 30) {
return;
}
unix_system_kill_force($pid);
}
@file_put_contents($pidfile, getmypid());
}
$ver = trim(@file_get_contents("/etc/debian_version"));
preg_match("#^([0-9]+)\\.#", $ver, $re);
if (preg_match("#squeeze\\/sid#", $ver)) {
$Major = 6;
}
$Major = $re[1];
if ($Major != 6) {
echo "CheckSourcesList: Debian version <> {$Major} aborting...\n";
return;
}
Check_dotdeb();
$unix = new unix();
$aptget = $unix->find_program("apt-get");
echo "CheckSourcesList: Installing php5-fpm\n";
$cmd = "DEBIAN_FRONTEND=noninteractive {$aptget} -o Dpkg::Options::=\"--force-confnew\" --force-yes -y install php5-fpm libapache2-mod-fastcgi 2>&1";
echo "CheckSourcesList: {$cmd}\n";
shell_exec($cmd);
$phpfpm = $unix->APACHE_LOCATE_PHP_FPM();
if (is_file($phpfpm)) {
$php = $unix->LOCATE_PHP5_BIN();
shell_exec("{$php} /usr/share/artica-postfix/exec.initslapd.php --phppfm");
APTToSyslog("Restarting PHP-FPM");
shell_exec("/etc/init.d/php5-fpm restart");
shell_exec("/etc/init.d/artica-postfix restart apache");
shell_exec("/etc/init.d/artica-status reload");
shell_exec("/etc/init.d/artica-framework restart");
shell_exec("/etc/init.d/monit restart");
shell_exec("{$php} /usr/share/artica-postfix/exec.freeweb.php --build");
}
}
示例2: BuildArticaInNginx
function BuildArticaInNginx()
{
$sock = new sockets();
$unix = new unix();
$BuildFrameWorkInNginx = false;
$EnableArticaFrontEndToNGninx = intval($sock->GET_INFO("EnableArticaFrontEndToNGninx"));
if ($GLOBALS["OUTPUT"]) {
echo "Starting......: " . date("H:i:s") . " [INIT]: Nginx, EnableArticaFrontEndToNGninx = {$EnableArticaFrontEndToNGninx}\n";
}
if ($EnableArticaFrontEndToNGninx == 0) {
return;
}
$SargOutputDir = $sock->GET_INFO("SargOutputDir");
if ($SargOutputDir == null) {
$SargOutputDir = "/var/www/html/squid-reports";
}
if (!is_dir($SargOutputDir)) {
@mkdir($SargOutputDir, 0755, true);
}
if (!is_file("{$SargOutputDir}/logo.gif")) {
@copy("/usr/share/artica-postfix/css/images/logo.gif", "{$SargOutputDir}/logo.gif");
}
if (!is_file("{$SargOutputDir}/pattern.png")) {
@copy("/usr/share/artica-postfix/css/images/pattern.png", "{$SargOutputDir}/pattern.png");
}
$phpfpm = $unix->APACHE_LOCATE_PHP_FPM();
$EnablePHPFPM = $sock->GET_INFO("EnablePHPFPM");
$EnableArticaApachePHPFPM = $sock->GET_INFO("EnableArticaApachePHPFPM");
if (!is_numeric($EnableArticaApachePHPFPM)) {
$EnableArticaApachePHPFPM = 0;
}
if ($EnableArticaApachePHPFPM == 0) {
$EnablePHPFPM = 0;
}
$EnableSargGenerator = $sock->GET_INFO("EnableSargGenerator");
if (!is_numeric($EnableSargGenerator)) {
$EnableSargGenerator = 1;
}
if (!is_numeric($EnablePHPFPM)) {
$EnablePHPFPM = 0;
}
if (!is_file($phpfpm)) {
$EnablePHPFPM = 0;
}
if ($EnablePHPFPM == 1) {
ToSyslog("Restarting PHP5-FPM");
shell_exec("/etc/init.d/php5-fpm reload >/dev/null 2>&1");
}
$host = new nginx("0.0.0.0:9000");
$host->set_ssl();
$host->set_proxy_disabled();
$host->set_DocumentRoot("/usr/share/artica-postfix");
$host->set_index_file("admin.index.php");
$host->build_proxy();
$lighttpdbin = $unix->find_program("lighttpd");
if (!is_file($lighttpdbin)) {
$BuildFrameWorkInNginx = true;
}
if (is_file("/etc/artica-postfix/WORDPRESS_APPLIANCE")) {
$BuildFrameWorkInNginx = true;
}
if ($EnableSargGenerator == 1) {
if ($GLOBALS["OUTPUT"]) {
echo "Starting......: " . date("H:i:s") . " [INIT]: Nginx, SARG is enabled...\n";
}
$host->SargDir();
$host->build_proxy();
}
if ($BuildFrameWorkInNginx) {
if (is_file("/etc/php5/fpm/pool.d/framework.conf")) {
if ($GLOBALS["OUTPUT"]) {
echo "Starting......: " . date("H:i:s") . " [INIT]: Nginx, building framework...\n";
}
$host = new nginx(47980);
$host->set_proxy_disabled();
$host->set_DocumentRoot("/usr/share/artica-postfix/framework");
$host->set_framework();
$host->set_listen_ip("127.0.0.1");
$host->set_servers_aliases(array("127.0.0.1"));
$host->build_proxy();
}
}
}
示例3: apache_config
function apache_config()
{
$sock = new sockets();
$unix = new unix();
$EnablePHPFPM = 0;
$APACHE_SRC_ACCOUNT = $unix->APACHE_SRC_ACCOUNT();
$APACHE_SRC_GROUP = $unix->APACHE_SRC_GROUP();
if (preg_match("#APACHE_RUN_GROUP#", $APACHE_SRC_GROUP)) {
$APACHE_SRC_GROUP = "www-data";
}
$LogFilePath = "/var/log/artica-wifidog/access.log";
$directories[] = "/var/run/apache2";
$directories[] = "/var/run/artica-apache";
$directories[] = "/var/log/artica-wifidog";
$directories[] = "/home/artica/hotspot/sessions";
$directories[] = "/home/artica/hotspot/caches";
while (list($index, $maindir) = each($directories)) {
@mkdir($maindir, 0755, true);
@chown($maindir, $APACHE_SRC_ACCOUNT);
@chgrp($maindir, $APACHE_SRC_GROUP);
}
$ErrorLog = dirname($LogFilePath) . "/error.log";
if (!is_file($LogFilePath)) {
@touch($LogFilePath);
}
@chown($LogFilePath, $APACHE_SRC_ACCOUNT);
@chgrp($LogFilePath, $APACHE_SRC_GROUP);
if (!is_file($ErrorLog)) {
@touch($ErrorLog);
}
@chown($ErrorLog, $APACHE_SRC_ACCOUNT);
@chgrp($ErrorLog, $APACHE_SRC_GROUP);
$APACHE_MODULES_PATH = $unix->APACHE_MODULES_PATH();
$HotSpotMaxClients = intval(@file_get_contents("/etc/artica-postfix/settings/Daemons/HotSpotMaxClients"));
$HotSpotStartServers = intval(@file_get_contents("/etc/artica-postfix/settings/Daemons/HotSpotStartServers"));
$HotSpotForceDDOSDisable = intval(@file_get_contents("/etc/artica-postfix/settings/Daemons/HotSpotForceDDOSDisable"));
if ($HotSpotMaxClients == 0) {
$HotSpotMaxClients = 20;
}
if ($HotSpotStartServers == 0) {
$HotSpotStartServers = 5;
}
$EnableArticaHotSpot = $sock->GET_INFO("EnableArticaHotSpot");
$SquidHotSpotPort = $sock->GET_INFO("SquidHotSpotPort");
$ArticaHotSpotPort = $sock->GET_INFO("ArticaHotSpotPort");
$ArticaSSLHotSpotPort = $sock->GET_INFO("ArticaSSLHotSpotPort");
$ArticaSplashHotSpotPort = $sock->GET_INFO("ArticaSplashHotSpotPort");
$ArticaSplashHotSpotPortSSL = $sock->GET_INFO("ArticaSplashHotSpotPortSSL");
if (!is_numeric($ArticaHotSpotPort)) {
$ArticaHotSpotPort = 0;
}
if (!is_numeric($ArticaSplashHotSpotPort)) {
$ArticaSplashHotSpotPort = 16080;
}
if (!is_numeric($ArticaSplashHotSpotPortSSL)) {
$ArticaSplashHotSpotPortSSL = 16443;
}
$ArticaHotSpotInterface = $sock->GET_INFO("ArticaHotSpotInterface");
$HospotHTTPServerName = trim($sock->GET_INFO("HospotHTTPServerName"));
$HotSpotErrorRedirect = $sock->GET_INFO("HotSpotErrorRedirect");
if ($HotSpotErrorRedirect == null) {
$HotSpotErrorRedirect = "http://www.msftncsi.com";
}
$Params = unserialize($sock->GET_INFO("HotSpotEvasive"));
$ApacheEvasiveInstalled = intval($sock->GET_INFO("ApacheEvasiveInstalled"));
if (!is_numeric($Params["DOSEnable"])) {
$Params["DOSEnable"] = 1;
}
if (!is_numeric($Params["DOSHashTableSize"])) {
$Params["DOSHashTableSize"] = 1024;
}
if (!is_numeric($Params["DOSPageCount"])) {
$Params["DOSPageCount"] = 3;
}
if (!is_numeric($Params["DOSSiteCount"])) {
$Params["DOSSiteCount"] = 20;
}
if (!is_numeric($Params["DOSPageInterval"])) {
$Params["DOSPageInterval"] = 1;
}
if (!is_numeric($Params["DOSSiteInterval"])) {
$Params["DOSSiteInterval"] = 10;
}
if (!is_numeric($Params["DOSBlockingPeriod"])) {
$Params["DOSBlockingPeriod"] = 5;
}
$unix = new unix();
$NETWORK_ALL_INTERFACES = $unix->NETWORK_ALL_INTERFACES();
$ipaddr = $NETWORK_ALL_INTERFACES[$ArticaHotSpotInterface]["IPADDR"];
if ($GLOBALS["OUTPUT"]) {
echo "Starting......: " . date("H:i:s") . " [INIT]: {$GLOBALS["SERVICE_NAME"]} HotSpot run as {$ArticaHotSpotInterface} ( {$ipaddr} )\n";
}
if ($ipaddr == "0.0.0.0") {
$ipaddr = "*";
}
if ($ipaddr == null) {
$ipaddr = "*";
}
$GLOBALS["HOSTPOT_WEB_INTERFACE"] = $ipaddr;
$phpfpm = $unix->APACHE_LOCATE_PHP_FPM();
//.........这里部分代码省略.........
示例4: apache_config
function apache_config()
{
$sock = new sockets();
$unix = new unix();
$EnablePHPFPM = 0;
$ipaddr = null;
@mkdir("/var/run/apache2", 0755, true);
@mkdir("/var/run/sarg-apache", 0755, true);
@mkdir("/var/log/apache2", 0755, true);
@mkdir(dirname($GLOBALS["APACHE_PID_PATH"]), 0755, true);
$APACHE_SRC_ACCOUNT = $unix->APACHE_SRC_ACCOUNT();
$APACHE_SRC_GROUP = $unix->APACHE_SRC_GROUP();
$APACHE_MODULES_PATH = $unix->APACHE_MODULES_PATH();
$SargOutputDir = $sock->GET_INFO("SargOutputDir");
if ($SargOutputDir == null) {
$SargOutputDir = "/var/www/html/squid-reports";
}
$SargWebPort = intval($sock->GET_INFO("SargWebPort"));
if ($SargWebPort == 0) {
$SargWebPort = rand(55600, 59000);
$sock->SET_INFO("SargWebPort", $SargWebPort);
}
if (is_link($SargOutputDir)) {
$SargOutputDir = @readlink($SargOutputDir);
}
@mkdir($SargOutputDir, 0755, true);
if (!is_file("{$SargOutputDir}/index.html")) {
$php = $unix->LOCATE_PHP5_BIN();
shell_exec("{$php} /usr/share/artica-postfix/exec.sarg.php --exec --force >/dev/null 2>&1 &");
}
if ($ipaddr == null) {
$ipaddr = "*";
}
$phpfpm = $unix->APACHE_LOCATE_PHP_FPM();
$php = $unix->LOCATE_PHP5_BIN();
$EnableArticaApachePHPFPM = $sock->GET_INFO("EnableArticaApachePHPFPM");
if (!is_numeric($EnableArticaApachePHPFPM)) {
$EnableArticaApachePHPFPM = 0;
}
if (!is_file($phpfpm)) {
$EnableArticaApachePHPFPM = 0;
}
$logfile = "/var/log/apache2/apache-sarg-access.log";
$ErrorLog = "/var/log/apache2/apache-sarg-error.log";
$unix->chown_func($APACHE_SRC_ACCOUNT, $APACHE_SRC_GROUP, "/var/run/sarg-apache");
$apache_LOCATE_MIME_TYPES = $unix->apache_LOCATE_MIME_TYPES();
if ($EnableArticaApachePHPFPM == 1) {
if (!is_file("{$APACHE_MODULES_PATH}/mod_fastcgi.so")) {
if ($GLOBALS["OUTPUT"]) {
echo "Starting......: " . date("H:i:s") . " [INIT]: {$GLOBALS["SERVICE_NAME"]} mod_fastcgi.so is required to use PHP5-FPM\n";
}
$EnableArticaApachePHPFPM = 0;
}
}
if ($APACHE_SRC_ACCOUNT == null) {
$APACHE_SRC_ACCOUNT = "www-data";
$APACHE_SRC_GROUP = "www-data";
$unix->CreateUnixUser($APACHE_SRC_ACCOUNT, $APACHE_SRC_GROUP, "Apache username");
}
@unlink($ErrorLog);
@unlink($logfile);
if (!is_file("{$logfile}")) {
@touch("{$logfile}");
}
if (!is_file("{$ErrorLog}")) {
@touch("{$ErrorLog}");
}
$unix->chown_func($APACHE_SRC_ACCOUNT, $APACHE_SRC_GROUP, $ErrorLog);
$unix->chown_func($APACHE_SRC_ACCOUNT, $APACHE_SRC_GROUP, $logfile);
$unix->chown_func($APACHE_SRC_ACCOUNT, $APACHE_SRC_GROUP, "/var/run/sarg-apache");
$unix->chown_func($APACHE_SRC_ACCOUNT, $APACHE_SRC_GROUP, "/var/log/apache2");
$unix->chown_func($APACHE_SRC_ACCOUNT, $APACHE_SRC_GROUP, dirname($GLOBALS["APACHE_PID_PATH"]));
if ($GLOBALS["OUTPUT"]) {
echo "Starting......: " . date("H:i:s") . " [INIT]: {$GLOBALS["SERVICE_NAME"]} Run as {$APACHE_SRC_ACCOUNT}:{$APACHE_SRC_GROUP}\n";
}
if ($GLOBALS["OUTPUT"]) {
echo "Starting......: " . date("H:i:s") . " [INIT]: {$GLOBALS["SERVICE_NAME"]} HTTP Port: {$ArticaSplashHotSpotPort} SSL Port: {$ArticaSplashHotSpotPortSSL}\n";
}
if ($GLOBALS["OUTPUT"]) {
echo "Starting......: " . date("H:i:s") . " [INIT]: {$GLOBALS["SERVICE_NAME"]} PHP-FPM: {$EnablePHPFPM}\n";
}
$f[] = "LockFile /var/run/apache2/sarg-artica-accept.lock";
$f[] = "PidFile {$GLOBALS["APACHE_PID_PATH"]}";
$f[] = "AcceptMutex flock";
$f[] = "DocumentRoot {$SargOutputDir}";
$f[] = "DirectoryIndex index.html";
$f[] = "ErrorDocument 400 /index.html";
$f[] = "ErrorDocument 401 /index.html";
$f[] = "ErrorDocument 403 /index.html";
$f[] = "ErrorDocument 404 /index.html";
$f[] = "ErrorDocument 500 /index.html";
$f[] = "NameVirtualHost {$ipaddr}:{$SargWebPort}";
$f[] = "Listen {$ipaddr}:{$SargWebPort}";
$f[] = "<VirtualHost {$ipaddr}:{$SargWebPort}>";
$f[] = "\tServerName {$ipaddr}";
$f[] = "\tDocumentRoot {$SargOutputDir}";
$f[] = "</VirtualHost>";
$f[] = "<IfModule mpm_prefork_module>";
$f[] = "</IfModule>";
$f[] = "<IfModule mpm_worker_module>";
//.........这里部分代码省略.........
示例5: phppfm
function phppfm()
{
if (is_file("/etc/artica-postfix/FROM_ISO")) {
if (!is_file("/etc/artica-postfix/artica-iso-setup-launched")) {
die;
}
}
$unix = new unix();
if (is_file("/etc/artica-postfix/FROM_ISO")) {
$daemon_path = "/usr/sbin/php5-fpm";
$php = $GLOBALS["PHP5_BIN_PATH"];
} else {
$php = $unix->LOCATE_PHP5_BIN();
$daemon_path = $unix->APACHE_LOCATE_PHP_FPM();
}
$INITD_PATH = "/etc/init.d/php5-fpm";
$php5script = "exec.php-fpm.php";
$daemonbinLog = "PHP5 FastCGI Process Manager Daemon";
$f[] = "#!/bin/sh";
$f[] = "### BEGIN INIT INFO";
$f[] = "# Provides: php5-fpm";
$f[] = "# Required-Start: \$local_fs \$syslog";
$f[] = "# Required-Stop: \$local_fs \$syslog";
$f[] = "# Should-Start:";
$f[] = "# Should-Stop:";
$f[] = "# Default-Start: 2 3 4 5";
$f[] = "# Default-Stop: 0 1 6";
$f[] = "# Short-Description: {$daemonbinLog}";
$f[] = "# chkconfig: - 80 75";
$f[] = "# description: {$daemonbinLog}";
$f[] = "### END INIT INFO";
$f[] = "DAEMON={$daemon_path}";
$f[] = "[ -x \"\$DAEMON\" ] || exit 0";
$f[] = "case \"\$1\" in";
$f[] = " start)";
$f[] = " {$php} /usr/share/artica-postfix/{$php5script} --start --script \$2 \$3";
$f[] = " ;;";
$f[] = "";
$f[] = " stop)";
$f[] = " {$php} /usr/share/artica-postfix/{$php5script} --stop --script \$2 \$3";
$f[] = " ;;";
$f[] = "";
$f[] = " restart)";
$f[] = " {$php} /usr/share/artica-postfix/{$php5script} --restart --script \$2 \$3";
$f[] = " ;;";
$f[] = "";
$f[] = " *)";
$f[] = " echo \"Usage: \$0 {start|stop|restart} (+ '--verbose' for more infos)\"";
$f[] = " exit 1";
$f[] = " ;;";
$f[] = "esac";
$f[] = "exit 0\n";
echo "{$daemonbinLog}: [INFO] Writing {$INITD_PATH} with new config\n";
@unlink($INITD_PATH);
@file_put_contents($INITD_PATH, @implode("\n", $f));
@chmod($INITD_PATH, 0755);
if (is_file('/usr/sbin/update-rc.d')) {
shell_exec("/usr/sbin/update-rc.d -f " . basename($INITD_PATH) . " defaults >/dev/null 2>&1");
}
if (is_file('/sbin/chkconfig')) {
shell_exec("/sbin/chkconfig --add " . basename($INITD_PATH) . " >/dev/null 2>&1");
shell_exec("/sbin/chkconfig --level 345 " . basename($INITD_PATH) . " on >/dev/null 2>&1");
}
}
示例6: buildConfig
//.........这里部分代码省略.........
if ($line == null) {
continue;
}
if (preg_match("#Starting.*?lighttpd(.+)#", $line, $re)) {
$line = $re[1];
}
$line = str_replace(": ", "", $line);
if ($GLOBALS["OUTPUT"]) {
echo "Starting......: " . date("H:i:s") . " [ARTI]: {$GLOBALS["SERVICE_NAME"]} {$line}\n";
}
}
PHP_MYADMIN();
$PHP_FCGI_CHILDREN = 3;
$max_procs = 3;
if ($LighttpdArticaMaxProcs > 0) {
$max_procs = $LighttpdArticaMaxProcs;
}
if ($LighttpdArticaMaxChildren > 0) {
$PHP_FCGI_CHILDREN = $LighttpdArticaMaxChildren;
}
if (!$unix->ISMemoryHiger1G()) {
$PHP_FCGI_CHILDREN = 2;
$max_procs = 1;
}
$MEMORY = $unix->MEM_TOTAL_INSTALLEE();
if ($MEMORY < 624288) {
$LighttpdRunAsminimal = 1;
}
if ($LighttpdRunAsminimal == 1) {
$max_procs = 1;
$PHP_FCGI_CHILDREN = 2;
$PHP_FCGI_MAX_REQUESTS = 500;
}
$phpfpm = $unix->APACHE_LOCATE_PHP_FPM();
$EnablePHPFPM = $sock->GET_INFO("EnablePHPFPM");
if (!is_numeric($EnablePHPFPM)) {
$EnablePHPFPM = 0;
}
if (!is_file($phpfpm)) {
$EnablePHPFPM = 0;
}
if ($EnablePHPFPM == 0) {
$EnableArticaApachePHPFPM = 0;
}
if ($EnableArticaApachePHPFPM == 0) {
$EnablePHPFPM = 0;
}
if ($GLOBALS["OUTPUT"]) {
echo "Starting......: " . date("H:i:s") . " [INIT]: {$GLOBALS["SERVICE_NAME"]} EnableArticaApachePHPFPM = {$EnableArticaApachePHPFPM}\n";
}
if ($EnablePHPFPM == 1) {
if ($GLOBALS["OUTPUT"]) {
echo "Starting......: " . date("H:i:s") . " [INIT]: {$GLOBALS["SERVICE_NAME"]} Using PHP-FPM........: Yes\n";
}
} else {
if ($GLOBALS["OUTPUT"]) {
echo "Starting......: " . date("H:i:s") . " [INIT]: {$GLOBALS["SERVICE_NAME"]} Using PHP-FPM........: No\n";
}
}
$ArticaHttpsPort = 9000;
$NoLDAPInLighttpdd = 0;
$ArticaHttpUseSSL = 1;
$ArticaHttpsPort = $sock->GET_INFO("ArticaHttpsPort");
$ArticaHttpUseSSL = $sock->GET_INFO("ArticaHttpUseSSL");
if (!is_numeric($ArticaHttpUseSSL)) {
$ArticaHttpUseSSL = 1;
示例7: apache_config
function apache_config()
{
$sock = new sockets();
$unix = new unix();
$EnablePHPFPM = 0;
@mkdir("/var/run/squid", 0755, true);
@mkdir("/var/run/squid", 0755, true);
$APACHE_SRC_ACCOUNT = "squid";
$APACHE_SRC_GROUP = "squid";
$APACHE_MODULES_PATH = $unix->APACHE_MODULES_PATH();
if (!isset($GLOBALS["HyperCacheStoragePath"])) {
$sock = new sockets();
$GLOBALS["HyperCacheStoragePath"] = $sock->GET_INFO("HyperCacheStoragePath");
if ($GLOBALS["HyperCacheStoragePath"] == null) {
$GLOBALS["HyperCacheStoragePath"] = "/home/artica/proxy-cache";
}
}
$SquidEnforceRules = intval($sock->GET_INFO("SquidEnforceRules"));
$HyperCacheHTTPListenPort = $sock->GET_INFO("HyperCacheHTTPListenPort");
$HyperCacheHTTPListenPortSSL = $sock->GET_INFO("HyperCacheHTTPListenPortSSL");
$HyperCacheHTTPListenPortSSLEnabled = intval($sock->GET_INFO("HyperCacheHTTPListenPortSSLEnabled"));
if (!is_numeric($HyperCacheHTTPListenPort)) {
$HyperCacheHTTPListenPort = 8700;
}
if (!is_numeric($HyperCacheHTTPListenPortSSL)) {
$HyperCacheHTTPListenPortSSL = 8900;
}
$HyperCacheListenAddr = $sock->GET_INFO("HyperCacheListenAddr");
$unix = new unix();
$NETWORK_ALL_INTERFACES = $unix->NETWORK_ALL_INTERFACES();
unset($NETWORK_ALL_INTERFACES["lo"]);
if ($HyperCacheListenAddr == null) {
$HyperCacheListenAddr = $unix->NETWORK_DEFAULT_LISTEN_ADDR();
$sock->SET_INFO("HyperCacheListenAddr", $HyperCacheListenAddr);
}
if ($unix->NETWORK_IS_LISTEN_ADDR_EXISTS($HyperCacheListenAddr)) {
if ($GLOBALS["OUTPUT"]) {
echo "Starting......: " . date("H:i:s") . " [INIT]: {$GLOBALS["SERVICE_NAME"]} {$HyperCacheListenAddr} doesn't exists...\n";
}
$HyperCacheListenAddr = $unix->NETWORK_DEFAULT_LISTEN_ADDR();
$sock->SET_INFO("HyperCacheListenAddr", $HyperCacheListenAddr);
}
$ipaddr = $HyperCacheListenAddr;
$phpfpm = $unix->APACHE_LOCATE_PHP_FPM();
$php = $unix->LOCATE_PHP5_BIN();
$EnableArticaApachePHPFPM = $sock->GET_INFO("EnableArticaApachePHPFPM");
if (!is_numeric($EnableArticaApachePHPFPM)) {
$EnableArticaApachePHPFPM = 0;
}
if (!is_file($phpfpm)) {
$EnableArticaApachePHPFPM = 0;
}
$unix->chown_func($APACHE_SRC_ACCOUNT, $APACHE_SRC_GROUP, "/var/run/squid");
$apache_LOCATE_MIME_TYPES = $unix->apache_LOCATE_MIME_TYPES();
if ($EnableArticaApachePHPFPM == 1) {
if (!is_file("{$APACHE_MODULES_PATH}/mod_fastcgi.so")) {
if ($GLOBALS["OUTPUT"]) {
echo "Starting......: " . date("H:i:s") . " [INIT]: {$GLOBALS["SERVICE_NAME"]} mod_fastcgi.so is required to use PHP5-FPM\n";
}
$EnableArticaApachePHPFPM = 0;
}
}
if ($GLOBALS["OUTPUT"]) {
echo "Starting......: " . date("H:i:s") . " [INIT]: {$GLOBALS["SERVICE_NAME"]} Listen address: {$ipaddr}\n";
}
if ($GLOBALS["OUTPUT"]) {
echo "Starting......: " . date("H:i:s") . " [INIT]: {$GLOBALS["SERVICE_NAME"]} Run as {$APACHE_SRC_ACCOUNT}:{$APACHE_SRC_GROUP}\n";
}
if ($GLOBALS["OUTPUT"]) {
echo "Starting......: " . date("H:i:s") . " [INIT]: {$GLOBALS["SERVICE_NAME"]} HTTP Port: {$HyperCacheHTTPListenPort} SSL Port: {$HyperCacheHTTPListenPortSSL}\n";
}
if ($GLOBALS["OUTPUT"]) {
echo "Starting......: " . date("H:i:s") . " [INIT]: {$GLOBALS["SERVICE_NAME"]} PHP-FPM: {$EnablePHPFPM}\n";
}
$q = new mysql_squid_builder();
$nice = EXEC_NICE();
$sql = "SELECT * FROM artica_caches_mirror WHERE enabled=1 AND `ToDelete`=0";
$results = $q->QUERY_SQL($sql);
$HyperCache = new HyperCache();
while ($ligne = mysql_fetch_assoc($results)) {
$t = time();
$sitename = $ligne["sitename"];
$sitename_path = $HyperCache->HyperCacheUriToHostname($sitename);
$workingdir = $GLOBALS["HyperCacheStoragePath"] . "/mirror/{$sitename_path}";
if (!is_dir($workingdir)) {
@mkdir($workingdir, 0755, true);
}
@chown("{$GLOBALS["HyperCacheStoragePath"]}/mirror", "squid");
@chgrp("{$GLOBALS["HyperCacheStoragePath"]}/mirror", "squid");
@chown("{$GLOBALS["HyperCacheStoragePath"]}/mirror/{$sitename_path}", "squid");
@chgrp("{$GLOBALS["HyperCacheStoragePath"]}/mirror/{$sitename_path}", "squid");
if ($GLOBALS["OUTPUT"]) {
echo "Starting......: " . date("H:i:s") . " [INIT]: {$GLOBALS["SERVICE_NAME"]} build folder for mirrored {$sitename_path}\n";
}
$mirrors[] = "";
$mirrors_aliases[] = "alias /{$sitename_path} {$workingdir}";
if ($GLOBALS["OUTPUT"]) {
echo "Starting......: " . date("H:i:s") . " [INIT]: alias /{$sitename_path} {$workingdir}\n";
}
$mirrors[] = "";
//.........这里部分代码省略.........
示例8: php5_fpm
function php5_fpm()
{
$unix = new unix();
$daemon_path = $unix->APACHE_LOCATE_PHP_FPM();
if (!is_file($daemon_path)) {
return;
}
$f[] = "# PHP-FPM configuration";
$f[] = "<IfModule mod_fastcgi.c>";
$f[] = " Alias /php5.fastcgi /var/lib/apache2/fastcgi/php5.fastcgi";
$f[] = " AddHandler php-script .php";
$f[] = " FastCGIExternalServer /var/lib/apache2/fastcgi/php5.fastcgi -socket /var/run/php-fpm-apache2.sock -idle-timeout 610";
$f[] = " Action php-script /php5.fastcgi virtual";
$f[] = "";
$f[] = " # Forbid access to the fastcgi handler.";
$f[] = " <Directory /var/lib/apache2/fastcgi>";
$f[] = " <Files php5.fastcgi>";
$f[] = " Order deny,allow";
$f[] = " Allow from all";
$f[] = " </Files>";
$f[] = " </Directory>";
$f[] = "";
$f[] = " # FPM status page.";
$f[] = " <Location /php-fpm-status>";
$f[] = " SetHandler php-script";
$f[] = " Order deny,allow";
$f[] = " Deny from all";
$f[] = " Allow from 127.0.0.1 ::1";
$f[] = " </Location>";
$f[] = "";
$f[] = " # FPM ping page.";
$f[] = " <Location /php-fpm-ping>";
$f[] = " SetHandler php-script";
$f[] = " Order deny,allow";
$f[] = " Deny from all";
$f[] = " Allow from 127.0.0.1 ::1";
$f[] = " </Location>";
$f[] = "</IfModule>";
@file_put_contents("/etc/apache2/mods-available/php5-fpm.conf", @implode("\n", $f));
}
示例9: apache_config
function apache_config()
{
$sock = new sockets();
$unix = new unix();
$EnablePHPFPM = 0;
@mkdir("/var/run/apache2", 0755, true);
@mkdir("/var/run/artica-roundcube", 0755, true);
@mkdir("/var/run/roundcube-apache", 0755, true);
@mkdir("/var/log/apache2", 0755, true);
$APACHE_SRC_ACCOUNT = $unix->APACHE_SRC_ACCOUNT();
$APACHE_SRC_GROUP = $unix->APACHE_SRC_GROUP();
$APACHE_MODULES_PATH = $unix->APACHE_MODULES_PATH();
$pydio_installed = false;
if (is_file(" /etc/php5/cli/conf.d/ming.ini")) {
@unlink(" /etc/php5/cli/conf.d/ming.ini");
}
@unlink("/var/log/apache2/roundcube-error.log");
@touch("/var/log/apache2/roundcube-error.log");
@chmod("/var/log/apache2/roundcube-error.log", 0755);
$unix->chown_func($APACHE_SRC_ACCOUNT, $APACHE_SRC_GROUP, "/var/log/apache2/*");
$unix->chown_func($APACHE_SRC_ACCOUNT, $APACHE_SRC_GROUP, "/usr/share/artica-postfix/ressources/logs/*");
$RoundCubeHTTPPort = 8888;
$RoundCubeHTTPSPort = 449;
$NoLDAPInLighttpdd = 0;
$RoundCubeHTTPSPort = intval($sock->GET_INFO("RoundCubeHTTPSPort"));
$RoundCubeHTTPPort = intval($sock->GET_INFO("RoundCubeHTTPPort"));
$RoundCubeUseSSL = intval($sock->GET_INFO("RoundCubeUseSSL"));
$RoundCubeUploadMaxFilesize = intval($sock->GET_INFO("RoundCubeUploadMaxFilesize"));
if ($RoundCubeUploadMaxFilesize == 0) {
$RoundCubeUploadMaxFilesize = 128;
}
if ($RoundCubeHTTPSPort == 0) {
$RoundCubeHTTPSPort = 449;
}
if ($RoundCubeHTTPPort == 0) {
$RoundCubeHTTPPort = 8888;
}
$RoundCubeListenIP = $sock->GET_INFO("RoundCubeListenIP");
$phpfpm = $unix->APACHE_LOCATE_PHP_FPM();
$php = $unix->LOCATE_PHP5_BIN();
$EnableArticaApachePHPFPM = $sock->GET_INFO("EnableArticaApachePHPFPM");
if (!is_numeric($EnableArticaApachePHPFPM)) {
$EnableArticaApachePHPFPM = 0;
}
if (!is_file($phpfpm)) {
$EnableArticaApachePHPFPM = 0;
}
$EnablePHPFPM = intval($sock->GET_INFO("EnablePHPFPM"));
if (!is_numeric($EnablePHPFPM)) {
$EnablePHPFPM = 0;
}
if ($EnablePHPFPM == 0) {
$EnableArticaApachePHPFPM = 0;
}
$unix->chown_func($APACHE_SRC_ACCOUNT, $APACHE_SRC_GROUP, "/var/run/artica-roundcube");
$apache_LOCATE_MIME_TYPES = $unix->apache_LOCATE_MIME_TYPES();
if ($EnableArticaApachePHPFPM == 1) {
if (!is_file("{$APACHE_MODULES_PATH}/mod_fastcgi.so")) {
if ($GLOBALS["OUTPUT"]) {
echo "Starting......: " . date("H:i:s") . " [INIT]: {$GLOBALS["SERVICE_NAME"]} mod_fastcgi.so is required to use PHP5-FPM\n";
}
$EnableArticaApachePHPFPM = 0;
}
}
if ($APACHE_SRC_ACCOUNT == null) {
$APACHE_SRC_ACCOUNT = "www-data";
$APACHE_SRC_GROUP = "www-data";
$unix->CreateUnixUser($APACHE_SRC_ACCOUNT, $APACHE_SRC_GROUP, "Apache username");
}
if ($GLOBALS["OUTPUT"]) {
echo "Starting......: " . date("H:i:s") . " [INIT]: {$GLOBALS["SERVICE_NAME"]} Run as {$APACHE_SRC_ACCOUNT}:{$APACHE_SRC_GROUP}\n";
}
if ($GLOBALS["OUTPUT"]) {
echo "Starting......: " . date("H:i:s") . " [INIT]: {$GLOBALS["SERVICE_NAME"]} PHP-FPM: {$EnablePHPFPM}\n";
}
if ($GLOBALS["OUTPUT"]) {
echo "Starting......: " . date("H:i:s") . " [INIT]: {$GLOBALS["SERVICE_NAME"]} PHP-FPM Enabled: {$EnableArticaApachePHPFPM}\n";
}
$open_basedir[] = "/usr/share/artica-postfix";
$open_basedir[] = "/etc/artica-postfix";
$open_basedir[] = "/etc/artica-postfix/settings";
$open_basedir[] = "/var/log";
$open_basedir[] = "/var/run/mysqld";
$open_basedir[] = "/usr/share/php";
$open_basedir[] = "/usr/share/php5";
$open_basedir[] = "/var/lib/php5";
$open_basedir[] = "/var/lighttpd/upload";
$open_basedir[] = "/usr/share/artica-postfix/ressources";
$open_basedir[] = "/usr/share/artica-postfix/framework";
$open_basedir[] = "/etc/ssl/certs/mysql-client-download";
$open_basedir[] = "/var/run";
$open_basedir[] = "/bin";
$open_basedir[] = "/tmp";
$open_basedir[] = "/usr/sbin";
$open_basedir[] = "/home";
$f[] = "<Directory \"/usr/share/roundcube\">";
$f[] = "\tOptions Indexes FollowSymLinks";
$f[] = "\tphp_value open_basedir \"/usr/share/roundcube\"";
$f[] = "\tphp_admin_value upload_tmp_dir \"/usr/share/roundcube/uploads\"";
$f[] = "\tphp_flag register_globals off";
//.........这里部分代码省略.........
示例10: buildConfig
function buildConfig()
{
$unix = new unix();
$sock = new sockets();
$phpcgi = $unix->LIGHTTPD_PHP5_CGI_BIN_PATH();
@mkdir("/usr/share/artica-postfix/framework", 0755, true);
@mkdir("/usr/share/artica-postfix/ressources/sock", 0755, true);
@mkdir("/usr/share/artica-postfix/ressources/web", 0755, true);
@mkdir("/var/run/artica-framework", 0755, true);
$LighttpdRunAsminimal = $sock->GET_INFO("LighttpdRunAsminimal");
$LighttpdArticaMaxProcs = $sock->GET_INFO("LighttpdArticaMaxProcs");
$LighttpdArticaMaxChildren = $sock->GET_INFO("LighttpdArticaMaxChildren");
$PHP_FCGI_MAX_REQUESTS = $sock->GET_INFO("PHP_FCGI_MAX_REQUESTS");
$EnablePHPFPMFrameWork = $sock->GET_INFO("EnablePHPFPMFrameWork");
if (!is_numeric($EnablePHPFPMFrameWork)) {
$EnablePHPFPMFrameWork = 0;
}
if (!is_numeric($LighttpdRunAsminimal)) {
$LighttpdRunAsminimal = 0;
}
if (!is_numeric($LighttpdArticaMaxProcs)) {
$LighttpdArticaMaxProcs = 0;
}
if (!is_numeric($LighttpdArticaMaxChildren)) {
$LighttpdArticaMaxChildren = 0;
}
if (!is_numeric($PHP_FCGI_MAX_REQUESTS)) {
$PHP_FCGI_MAX_REQUESTS = 200;
}
$PHP_FCGI_CHILDREN = 1;
$max_procs = 5;
if ($LighttpdArticaMaxProcs > 0) {
$max_procs = $LighttpdArticaMaxProcs;
}
if ($LighttpdArticaMaxChildren > 0) {
$PHP_FCGI_CHILDREN = $LighttpdArticaMaxChildren;
}
if (!$unix->ISMemoryHiger1G()) {
$PHP_FCGI_CHILDREN = 2;
$max_procs = 2;
$PHP_FCGI_MAX_REQUESTS = 200;
}
$MEMORY = $unix->MEM_TOTAL_INSTALLEE();
if ($MEMORY < 624288) {
$LighttpdRunAsminimal = 1;
}
if ($LighttpdRunAsminimal == 1) {
$max_procs = 2;
$PHP_FCGI_CHILDREN = 1;
$PHP_FCGI_MAX_REQUESTS = 500;
}
if ($GLOBALS["OUTPUT"]) {
echo "Starting......: " . date("H:i:s") . " [INIT]: MAX Procs............: {$max_procs}\n";
}
if ($GLOBALS["OUTPUT"]) {
echo "Starting......: " . date("H:i:s") . " [INIT]: Php5 processes.......: {$PHP_FCGI_CHILDREN}\n";
}
if ($GLOBALS["OUTPUT"]) {
echo "Starting......: " . date("H:i:s") . " [INIT]: Max cnx/processes....: {$PHP_FCGI_MAX_REQUESTS}\n";
}
$phpfpm = $unix->APACHE_LOCATE_PHP_FPM();
$EnablePHPFPM = $sock->GET_INFO("EnablePHPFPM");
if (!is_numeric($EnablePHPFPM)) {
$EnablePHPFPM = 0;
}
if (!is_file($phpfpm)) {
$EnablePHPFPM = 0;
}
$PHP_FPM_Params = PHP_FPM_Params();
if (!isset($ParseParams["allow-to-run-as-root"])) {
$EnablePHPFPMFrameWork = 0;
}
if ($EnablePHPFPMFrameWork == 0) {
$EnablePHPFPM = 0;
}
if ($GLOBALS["OUTPUT"]) {
echo "Starting......: " . date("H:i:s") . " [INIT]: php-fpm..............: {$phpfpm}\n";
}
if ($GLOBALS["OUTPUT"]) {
echo "Starting......: " . date("H:i:s") . " [INIT]: EnablePHPFPMFrameWork: {$EnablePHPFPMFrameWork}\n";
}
if ($GLOBALS["OUTPUT"]) {
echo "Starting......: " . date("H:i:s") . " [INIT]: EnablePHPFPM.........: {$EnablePHPFPM}\n";
}
if ($EnablePHPFPM == 1) {
if ($GLOBALS["OUTPUT"]) {
echo "Starting......: " . date("H:i:s") . " [INIT]: Using PHP-FPM........: Yes\n";
}
} else {
if ($GLOBALS["OUTPUT"]) {
echo "Starting......: " . date("H:i:s") . " [INIT]: Using PHP-FPM........: No\n";
}
}
$phpcgi_path = $unix->LIGHTTPD_PHP5_CGI_BIN_PATH();
if ($GLOBALS["OUTPUT"]) {
echo "Starting......: " . date("H:i:s") . " [INIT]: php-cgi path.........: {$phpcgi_path}\n";
}
$f[] = "#artica-postfix saved by artica lighttpd.conf";
$f[] = "";
$f[] = "server.modules = (";
//.........这里部分代码省略.........
示例11: buildConfig
function buildConfig($aspid = false)
{
$unix = new unix();
if ($aspid) {
$pidfile = "/etc/artica-postfix/pids/" . basename(__FILE__) . "." . __FUNCTION__ . ".pid";
$pid = $unix->get_pid_from_file($pidfile);
if ($unix->process_exists($pid, basename(__FILE__))) {
$time = $unix->PROCCESS_TIME_MIN($pid);
if ($GLOBALS["OUTPUT"]) {
echo "Starting......: " . date("H:i:s") . " [INIT]: PHP-FPM: Already Artica task running PID {$pid} since {$time}mn\n";
}
return;
}
@file_put_contents($pidfile, getmypid());
}
$sock = new sockets();
$phpfpm = $unix->APACHE_LOCATE_PHP_FPM();
if (!is_file($phpfpm)) {
return;
}
$APACHE_USER = $unix->APACHE_SRC_ACCOUNT();
$APACHE_GROUP = $unix->APACHE_SRC_GROUP();
$VERSION = GetVersion();
$AsRoot = false;
$tr = explode(".", $VERSION);
$MAJOR = $tr[0];
$MINOR = $tr[1];
$REV = $tr[2];
$process_priority = false;
$syslog_facility = true;
$process_max = true;
if ($MAJOR > 4) {
if ($MINOR > 2) {
if ($REV > 20) {
$process_priority = true;
}
}
}
if ($GLOBALS["OUTPUT"]) {
echo "Starting......: " . date("H:i:s") . " [INIT]: PHP-FPM: Parse Parameters\n";
}
$ParseParams = ParseParams();
$AsRoot = true;
if (isset($ParseParams["allow-to-run-as-root"])) {
if ($GLOBALS["OUTPUT"]) {
echo "Starting......: " . date("H:i:s") . " [INIT]: PHP-FPM: Allow run as root TRUE\n";
}
$AsRoot = true;
} else {
if ($GLOBALS["OUTPUT"]) {
echo "Starting......: " . date("H:i:s") . " [INIT]: PHP-FPM: Allow run as root is disabled\n";
}
}
$PHPFPMNoSyslog = trim(@file_get_contents("/etc/artica-postfix/settings/Daemons/PHPFPMNoSyslog"));
$PHPFPMNoProcessMax = trim(@file_get_contents("/etc/artica-postfix/settings/Daemons/PHPFPMNoProcessMax"));
if (!is_numeric($PHPFPMNoSyslog)) {
$PHPFPMNoSyslog = 0;
}
if (!is_numeric($PHPFPMNoProcessMax)) {
$PHPFPMNoProcessMax = 0;
}
if ($GLOBALS["OUTPUT"]) {
echo "Starting......: " . date("H:i:s") . " [INIT]: PHP-FPM: PHPFPMNoSyslog:{$PHPFPMNoSyslog}\n";
}
if ($PHPFPMNoSyslog == 1) {
if ($GLOBALS["OUTPUT"]) {
echo "Starting......: " . date("H:i:s") . " [INIT]: PHP-FPM: Disabling process.priority token\n";
}
$syslog_facility = false;
}
if ($PHPFPMNoProcessMax == 1) {
$process_max = false;
}
$ProcessNice = $unix->GET_PERFS('ProcessNice');
if (!is_numeric($ProcessNice)) {
$ProcessNice = 19;
}
if ($ProcessNice > 19) {
$ProcessNice = 19;
}
if ($ProcessNice < 1) {
$ProcessNice = 19;
}
$EnableArticaApachePHPFPM = intval($sock->GET_INFO("EnableArticaApachePHPFPM"));
$EnablePHPFPMFreeWeb = intval($sock->GET_INFO("EnablePHPFPMFreeWeb"));
$EnablePHPFPMFrameWork = $sock->GET_INFO("EnablePHPFPMFrameWork");
$EnableFreeWeb = $sock->GET_INFO("EnableFreeWeb");
if (!is_numeric($EnablePHPFPMFrameWork)) {
$EnablePHPFPMFrameWork = 0;
}
if (!is_numeric($EnableArticaApachePHPFPM)) {
$EnableArticaApachePHPFPM = 0;
}
if (!is_numeric($EnablePHPFPMFreeWeb)) {
$EnablePHPFPMFreeWeb = 0;
}
if (!is_numeric($EnableFreeWeb)) {
$EnableFreeWeb = 0;
}
if ($EnableFreeWeb == 0) {
//.........这里部分代码省略.........