Current File : /home/inlingua/public_html/decay_sym/root/var/softaculous/apps/apache2/3/install.php
<?php

/*
function __apache2_requirements(){
	
}

function __apache2_postinstall(){
	
}
*/

function __apache2_preinstall(){
	
	global $W, $iapps, $error, $globals, $sdata;
	
	$distro = $globals['WU_DISTRO'];
	$ver = explode('.', $globals['os_version']);
	$os_ver = $ver[0];
	
	if($distro != 'ubuntu'){
		if($distro == 'almalinux' || ($distro == 'centos' && $os_ver == 8) || $distro == 'rocky'){
			vexec('dnf config-manager --set-enabled powertools');
		}else{
			vexec('yum --enablerepo=powertools');
		}
	}
	
	yum('lynx', 'install');
	
	// Check for default web server
	$default = $globals['WU_DEFAULT_SERVER'];
	
	if(empty($default)){
		return;
	}
	
	yum('lsof', 'install');
	
	putenv('PATH=/usr/kerberos/sbin:/usr/kerberos/bin:/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin:/root/bin');
			
	// Kill service running on port 80
	if(!empty($sdata['set-defaults'])){
		kill_by_port(80);
	}
	
}

function __apache2_after_save_install(){
	
	global $infos, $W, $iapps, $globals;
	
	copy(APACHE2_WAPP.'/apachectl', APACHE2_BIN.'/apachectl');
	
	// Make the CONF Folder
	@mkdir(APACHE2_ETC.'conf.d', 0755);
	
	// Move the CONF Files
	copy(__DIR__.'/httpd.conf', APACHE2_ETC.'httpd.conf');
	
	copy(__DIR__.'/modules.cnf', APACHE2_CONFD.'/modules.cnf');
	
	// Move pagespeed CONF
	unlink(APACHE2_ETC.'pagespeed.conf');
	copy(__DIR__.'/pagespeed.conf', APACHE2_ETC.'pagespeed.conf');

	// Rename mod_pagespeed_ap24.so to mod_pagespeed.so
	@unlink(APACHE2_APP.'modules/mod_pagespeed.so');
	rename(APACHE2_APP.'modules/mod_pagespeed_ap24.so', APACHE2_APP.'modules/mod_pagespeed.so');
	
	// Add the logrotate
	if (file_exists('/etc/logrotate.d/apache2')){
		unlink('/etc/logrotate.d/apache2');
	}
	copy(APACHE2_WAPP.'/apache2_logrotate', '/etc/logrotate.d/apache2');
		
	// Default Webuzo Page
	copy(APACHE2_WAPP.'/noindex.html', APACHE2_APP.'www/error/noindex.html');
	copy(APACHE2_WAPP.'/noindex.html', APACHE2_APP.'www/htdocs/index.html');
	copy(APACHE2_WAPP.'/404.html', APACHE2_APP.'www/error/404.html');
	copy(APACHE2_WAPP.'/500.html', APACHE2_APP.'www/error/500.html');
	copy(APACHE2_WAPP.'/50x.html', APACHE2_APP.'www/error/50x.html');
	mkdir(APACHE2_APP.'www/suspended/');
	copy(APACHE2_WAPP.'/suspended.html', APACHE2_APP.'www/suspended/index.html');
	
	// ADD User as during compile time we use this !
	vexec('useradd -r apache -s /sbin/nologin  >> /dev/null 2>&1');
	
	// Check for distro
	$distro = $globals['WU_DISTRO'];
	
	$ver = explode('.', $globals['os_version']);
	$os_ver = $ver[0];
	
	if($distro == 'ubuntu'){
		vexec('groupadd -r nobody');
	}
	
	// Save the error templates
	$users = get_server_users(0);	
	apache2_template_updated('root');
	
	foreach($users as $U){
		if(!empty($U['reseller'])){
			apache2_template_updated($U['user']);
		}
	}
	
	// If http2 enabled then disable it to set default MPM and enable fast-cgi
	$apache_settings = load_app_conf('apache2', 'conf');
	if(empty($apache_settings)){
		$globals['NO_HTTP2'] = true;	
		$globals['NO_FASTCGI'] = false;	
	}
	
	// Rebuild the vhost file
	apache2_vh_rebuild();
	
	// Reload Web server
	apache2_reload();
}

function __apache2_configure(){
	
	global $iapps, $infos, $softpanel, $W, $globals;
		
	// Installing lynx for checking https status
	yum('lynx');
	
	// Create the configuration file
	apache2_conf_rebuild();
	
}