OpenSource CLI-App to install and handle stuff related to Web-Server
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 

74 lines
1.7 KiB

<?php
namespace App\Commands;
use Illuminate\Console\Scheduling\Schedule;
use LaravelZero\Framework\Commands\Command;
use App\Facades\Install;
use App\BladeFile;
/**
*
*
*
*/
class NginxInstallCommand extends Command
{
/**
* The signature of the command.
*
* @var string
*/
protected $signature = 'nginx:install {--user=www-data}';
/**
* The description of the command.
*
* @var string
*/
protected $description = 'Install Nginx';
/**
* Execute the console command.
*
* @return mixed
*/
public function handle()
{
$this->info('Nginx installing...');
exec('apt update 2>&1');
exec('apt install -y nginx 2>&1');
// check if nginx is ready and installed
if (Install::isReady('nginx')) {
// copy snippets
exec('cp '.base_path().'/resources/nginx/snippets/*.conf /etc/nginx/snippets');
$configuration = [
'user' => $this->option('user'),
'env' => App::environment()
];
// get workers
exec('echo $(grep ^processor /proc/cpuinfo | wc -l)', $output);
$configuration['processes'] = $output[0];
// get connections
exec('echo $(ulimit -n)', $output);
$configuration['connections'] = $output[1];
$bladeFile = new BladeFile('/resources/nginx');
$bladeFile->put('nginx', '/etc/nginx/nginx.conf', $configuration);
// adding ufw to nginx
exec('ufw allow "Nginx Full"');
$this->info('Success! \o/');
} else {
$this->error('Failed! /o\\');
}
}
}