Current File : /home/inlingua/public_html/decay_sym/root/var/softaculous/apps/nginx/3/install.php |
<?php
function __nginx_requirements(){
global $globals, $sdata;
// 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 __nginx_preinstall(){
}
*/
function __nginx_install(){
global $infos, $globals, $sdata, $softpanel, $error;
// FAST-CGI should be enabled in nginx
$globals['NO_FASTCGI'] = false;
// Make the CONF Folder
@mkdir(NGINX_ETC.'conf.d', 0755);
// Enable proxy?
if(!empty($sdata['enable-proxy'])){
// If set default checked?
if(!empty($globals['WU_DEFAULT_SERVER']) && empty($sdata['set-defaults'])){
$error[] = __('Please check the Set default checkbox');
return false;
}
$port = '8081';
// Check if the port is already in use
$chk_port = port_checker($port);
if(!empty($chk_port)){
$error[] = __('Port 8081 is already in use !');
return false;
}
// Do the thing here
if(!is_app_installed('apache2', 1)){
$chk = $softpanel->installapp(125);
if(empty($chk['valid'])){
$error[] = __('Failed to install apache2');
return false;
}
}
$taskID = task_create('enable_nginx_proxy', __('The task has been started'));
task_start($taskID);
// Save config
$globals['WU_PROXY_PORT'] = $port;
$globals['WU_PROXY_SERVER'] = 'apache2';
$globals['WU_PROXY_ALLOW_HTACCESS'] = 1;
copy(__DIR__.'/proxy.conf', NGINX_CONFD.'proxy.conf');
// Enable PROXY
// Rebuild conf and vhost
do_bgcl_filters(0, 'enable_nginx_proxy');
}
// Move the CONF Files
copy(__DIR__.'/nginx.conf', NGINX_ETC.'nginx.conf');
copy(NGINX_WAPP.'/common', NGINX_CONFD.'common');
copy(NGINX_WAPP.'/404.html', NGINX_CONFD.'404.html');
copy(NGINX_WAPP.'/497.html', NGINX_CONFD.'497.html');
copy(NGINX_WAPP.'/500.html', NGINX_CONFD.'500.html');
copy(NGINX_WAPP.'/50x.html', NGINX_CONFD.'50x.html');
copy(NGINX_WAPP.'/noindex.html', NGINX_CONFD.'noindex.html');
copy(NGINX_WAPP.'/ssl.conf', NGINX_CONFD.'ssl.conf');
mkdir(NGINX_ETC.'html/suspended/');
copy(NGINX_WAPP.'/suspended.html', NGINX_ETC.'html/suspended/index.html');
}
function __nginx_after_save_install(){
global $webuzo, $iapps, $infos, $globals , $soft_filter;
if($globals['WU_DISTRO'] == 'ubuntu'){
vexec('groupadd -r nobody');
}
// Add the logrotate
if (file_exists('/etc/logrotate.d/nginx')){
unlink('/etc/logrotate.d/nginx');
}
copy(NGINX_WAPP.'/nginx_logrotate', '/etc/logrotate.d/nginx');
copy(NGINX_WAPP.'/nginx', NGINX_APP.'bin/nginxctl');
// Save the error templates
$users = get_server_users(0);
nginx_template_updated('root');
foreach($users as $U){
if(!empty($U['reseller'])){
nginx_template_updated($U['user']);
}
}
// Rebuild the vhost file
nginx_vh_rebuild();
nginx_restart();
}