diff --git a/app/Commands/PhpFpmInstallCommand.php b/app/Commands/PhpFpmInstallCommand.php index 731c40d..19443fc 100644 --- a/app/Commands/PhpFpmInstallCommand.php +++ b/app/Commands/PhpFpmInstallCommand.php @@ -46,6 +46,8 @@ class PhpFpmInstallCommand extends Command { $this->info('Php-fpm installing...'); + $output = []; + exec('apt update 2>&1', $output); exec('apt install -y php-fpm '.self::PACKAGES.' 2>&1', $output); @@ -64,24 +66,24 @@ class PhpFpmInstallCommand extends Command $user = $this->option('user'); if ($user) { - $output = []; - $this->info('Php-fpm change user...'); - exec('sed -i "s/user = www-data/user = '.$user.'/g" '.$file, $output); - exec('sed -i "s/group = www-data/group = '.$user.'/g" '.$file, $output); + system('sed -i "s/user = www-data/user = '.$user.'/g" '.$file); + system('sed -i "s/group = www-data/group = '.$user.'/g" '.$file); - exec('sed -i "s/listen.owner = www-data/listen.owner = '.$user.'/g" '.$file, $output); - exec('sed -i "s/listen.group = www-data/listen.group = '.$user.'/g" '.$file, $output); - - $this->line(implode("\n", $output)); + system('sed -i "s/listen.owner = www-data/listen.owner = '.$user.'/g" '.$file); + system('sed -i "s/listen.group = www-data/listen.group = '.$user.'/g" '.$file); } - $output = []; - $this->info('Php-fpm change mode...'); - exec('sed -i "s/;listen.mode = 0660/listen.mode = 0660/g" '.$file, $output); + system('sed -i "s/;listen.mode = 0660/listen.mode = 0660/g" '.$file); + + // getting version and restart service + $output = []; + exec("systemctl --full --type service --all | awk '{print $1}' | egrep php.+?fpm.service", $output); - $this->line(implode("\n", $output)); + foreach ($output as $line) { + system('service '.str_replace('.service', '', $line).' restart'); + } } } diff --git a/app/Helpers/InstallHelper.php b/app/Helpers/InstallHelper.php index af4fa27..d8f4d2e 100644 --- a/app/Helpers/InstallHelper.php +++ b/app/Helpers/InstallHelper.php @@ -30,7 +30,7 @@ class InstallHelper { $result = false; - exec('echo $(dpkg -s nginx 2>&1 | grep "'.self::PACKAGE_STATUS.'")', $output); + exec('echo $(dpkg -s '.$name.' 2>&1 | grep "'.self::PACKAGE_STATUS.'")', $output); if (isset($output[0]) && $output[0] === self::PACKAGE_STATUS) { $result = true; @@ -59,7 +59,7 @@ class InstallHelper } /** - * + * * * @return string */