mirror of
https://github.com/vitodeploy/vito.git
synced 2025-07-05 16:02:34 +00:00
use blade as conmmands template (#444)
* use blade as conmmands template * fix lint * fix ssl
This commit is contained in:
@ -3,7 +3,7 @@
|
||||
namespace App\SSH\Services\PHP;
|
||||
|
||||
use App\Exceptions\SSHCommandError;
|
||||
use App\SSH\HasScripts;
|
||||
use App\Exceptions\SSHError;
|
||||
use App\SSH\Services\AbstractService;
|
||||
use Closure;
|
||||
use Illuminate\Support\Str;
|
||||
@ -11,8 +11,6 @@
|
||||
|
||||
class PHP extends AbstractService
|
||||
{
|
||||
use HasScripts;
|
||||
|
||||
public function creationRules(array $input): array
|
||||
{
|
||||
return [
|
||||
@ -43,11 +41,14 @@ function (string $attribute, mixed $value, Closure $fail) {
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* @throws SSHError
|
||||
*/
|
||||
public function install(): void
|
||||
{
|
||||
$server = $this->service->server;
|
||||
$server->ssh()->exec(
|
||||
$this->getScript('install-php.sh', [
|
||||
view('ssh.services.php.install-php', [
|
||||
'version' => $this->service->version,
|
||||
'user' => $server->getSshUser(),
|
||||
]),
|
||||
@ -57,10 +58,13 @@ public function install(): void
|
||||
$this->service->server->os()->cleanup();
|
||||
}
|
||||
|
||||
/**
|
||||
* @throws SSHError
|
||||
*/
|
||||
public function uninstall(): void
|
||||
{
|
||||
$this->service->server->ssh()->exec(
|
||||
$this->getScript('uninstall-php.sh', [
|
||||
view('ssh.services.php.uninstall-php', [
|
||||
'version' => $this->service->version,
|
||||
]),
|
||||
'uninstall-php-'.$this->service->version
|
||||
@ -68,10 +72,13 @@ public function uninstall(): void
|
||||
$this->service->server->os()->cleanup();
|
||||
}
|
||||
|
||||
/**
|
||||
* @throws SSHError
|
||||
*/
|
||||
public function setDefaultCli(): void
|
||||
{
|
||||
$this->service->server->ssh()->exec(
|
||||
$this->getScript('change-default-php.sh', [
|
||||
view('ssh.services.php.change-default-php', [
|
||||
'version' => $this->service->version,
|
||||
]),
|
||||
'change-default-php'
|
||||
@ -79,12 +86,12 @@ public function setDefaultCli(): void
|
||||
}
|
||||
|
||||
/**
|
||||
* @throws SSHCommandError
|
||||
* @throws SSHError
|
||||
*/
|
||||
public function installExtension($name): void
|
||||
{
|
||||
$result = $this->service->server->ssh()->exec(
|
||||
$this->getScript('install-php-extension.sh', [
|
||||
view('ssh.services.php.install-php-extension', [
|
||||
'version' => $this->service->version,
|
||||
'name' => $name,
|
||||
]),
|
||||
@ -96,14 +103,20 @@ public function installExtension($name): void
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @throws SSHError
|
||||
*/
|
||||
public function installComposer(): void
|
||||
{
|
||||
$this->service->server->ssh()->exec(
|
||||
$this->getScript('install-composer.sh'),
|
||||
view('ssh.services.php.install-composer'),
|
||||
'install-composer'
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @throws SSHError
|
||||
*/
|
||||
public function getPHPIni(string $type): string
|
||||
{
|
||||
return $this->service->server->os()->readFile(
|
||||
@ -111,26 +124,30 @@ public function getPHPIni(string $type): string
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @throws SSHError
|
||||
*/
|
||||
public function createFpmPool(string $user, string $version, $site_id): void
|
||||
{
|
||||
$this->service->server->ssh()->exec(
|
||||
$this->getScript('create-fpm-pool.sh', [
|
||||
$this->service->server->ssh()->write(
|
||||
"/etc/php/{$version}/fpm/pool.d/{$user}.conf",
|
||||
view('ssh.services.php.fpm-pool', [
|
||||
'user' => $user,
|
||||
'version' => $version,
|
||||
'config' => $this->getScript('fpm-pool.conf', [
|
||||
'user' => $user,
|
||||
'version' => $version,
|
||||
]),
|
||||
]),
|
||||
"create-{$version}fpm-pool-{$user}",
|
||||
$site_id
|
||||
true
|
||||
);
|
||||
|
||||
$this->service->server->systemd()->restart($this->service->unit);
|
||||
}
|
||||
|
||||
/**
|
||||
* @throws SSHError
|
||||
*/
|
||||
public function removeFpmPool(string $user, string $version, $site_id): void
|
||||
{
|
||||
$this->service->server->ssh()->exec(
|
||||
$this->getScript('remove-fpm-pool.sh', [
|
||||
view('ssh.services.php.remove-fpm-pool', [
|
||||
'user' => $user,
|
||||
'version' => $version,
|
||||
]),
|
||||
|
@ -1,11 +0,0 @@
|
||||
if ! sudo rm /usr/bin/php; then
|
||||
echo 'VITO_SSH_ERROR' && exit 1
|
||||
fi
|
||||
|
||||
if ! sudo ln -s /usr/bin/php__version__ /usr/bin/php; then
|
||||
echo 'VITO_SSH_ERROR' && exit 1
|
||||
fi
|
||||
|
||||
echo "Default php is: "
|
||||
|
||||
php -v
|
@ -1,2 +0,0 @@
|
||||
echo '__config__' | sudo tee /etc/php/__version__/fpm/pool.d/__user__.conf
|
||||
sudo service php__version__-fpm restart
|
@ -1,22 +0,0 @@
|
||||
[__user__]
|
||||
user = __user__
|
||||
group = __user__
|
||||
|
||||
listen = /run/php/php__version__-fpm-__user__.sock
|
||||
listen.owner = vito
|
||||
listen.group = vito
|
||||
listen.mode = 0660
|
||||
|
||||
pm = dynamic
|
||||
pm.max_children = 5
|
||||
pm.start_servers = 2
|
||||
pm.min_spare_servers = 1
|
||||
pm.max_spare_servers = 3
|
||||
pm.max_requests = 500
|
||||
|
||||
php_admin_value[open_basedir] = /home/__user__/:/tmp/
|
||||
php_admin_value[upload_tmp_dir] = /home/__user__/tmp
|
||||
php_admin_value[session.save_path] = /home/__user__/tmp
|
||||
php_admin_value[display_errors] = off
|
||||
php_admin_value[log_errors] = on
|
||||
php_admin_value[error_log] = /home/__user__/.logs/php_errors.log
|
@ -1,9 +0,0 @@
|
||||
cd ~
|
||||
|
||||
curl -sS https://getcomposer.org/installer -o composer-setup.php
|
||||
|
||||
sudo php composer-setup.php --install-dir=/usr/local/bin --filename=composer
|
||||
|
||||
rm composer-setup.php
|
||||
|
||||
composer
|
@ -1,5 +0,0 @@
|
||||
sudo apt-get install -y php__version__-__name__
|
||||
|
||||
sudo service php__version__-fpm restart
|
||||
|
||||
php__version__ -m
|
@ -1,15 +0,0 @@
|
||||
sudo add-apt-repository ppa:ondrej/php -y
|
||||
|
||||
sudo DEBIAN_FRONTEND=noninteractive apt-get update
|
||||
|
||||
if ! sudo DEBIAN_FRONTEND=noninteractive apt-get install -y php__version__ php__version__-fpm php__version__-mbstring php__version__-mysql php__version__-gd php__version__-xml php__version__-curl php__version__-gettext php__version__-zip php__version__-bcmath php__version__-soap php__version__-redis php__version__-sqlite3 php__version__-tokenizer php__version__-pgsql php__version__-pdo; then
|
||||
echo 'VITO_SSH_ERROR' && exit 1
|
||||
fi
|
||||
|
||||
if ! sudo sed -i 's/www-data/__user__/g' /etc/php/__version__/fpm/pool.d/www.conf; then
|
||||
echo 'VITO_SSH_ERROR' && exit 1
|
||||
fi
|
||||
|
||||
sudo service php__version__-fpm enable
|
||||
|
||||
sudo service php__version__-fpm start
|
@ -1,2 +0,0 @@
|
||||
sudo rm -f /etc/php/__version__/fpm/pool.d/__user__.conf
|
||||
sudo service php__version__-fpm restart
|
@ -1,5 +0,0 @@
|
||||
sudo service php__version__-fpm stop
|
||||
|
||||
if ! sudo DEBIAN_FRONTEND=noninteractive apt-get remove -y php__version__ php__version__-fpm php__version__-mbstring php__version__-mysql php__version__-mcrypt php__version__-gd php__version__-xml php__version__-curl php__version__-gettext php__version__-zip php__version__-bcmath php__version__-soap php__version__-redis php__version__-sqlite3; then
|
||||
echo 'VITO_SSH_ERROR' && exit 1
|
||||
fi
|
@ -1,11 +0,0 @@
|
||||
if ! sudo sed -i 's,^__variable__ =.*$,__variable__ = __value__,' /etc/php/__version__/cli/php.ini; then
|
||||
echo 'VITO_SSH_ERROR' && exit 1
|
||||
fi
|
||||
|
||||
if ! sudo sed -i 's,^__variable__ =.*$,__variable__ = __value__,' /etc/php/__version__/fpm/php.ini; then
|
||||
echo 'VITO_SSH_ERROR' && exit 1
|
||||
fi
|
||||
|
||||
if ! sudo service php__version__-fpm restart; then
|
||||
echo 'VITO_SSH_ERROR' && exit 1
|
||||
fi
|
Reference in New Issue
Block a user