Skip to content

Instantly share code, notes, and snippets.

@mklasen
Last active April 25, 2023 13:53
Show Gist options
  • Save mklasen/39a9068172bdb31a0d223a79d9c66005 to your computer and use it in GitHub Desktop.
Save mklasen/39a9068172bdb31a0d223a79d9c66005 to your computer and use it in GitHub Desktop.
Cloudways restart PHP-FPM via terminal
  1. Create a folder on your server.
  2. Copy the composer.json file
  3. Run composer install
  4. Create a file called restart-php-fpm.php
  5. Set the correct email, key, server ID and php-fpm version.
  6. Run php restart-php-fpm.php
{
"name": "mklasen/cw-restart-php-fpm",
"require": {
"cloudwaysapi/phpsdk": "^1.0"
},
"authors": [
{
"name": "Marinus Klasen",
"email": "[email protected]"
}
]
}
<?php
require "vendor/autoload.php";
use Cloudways\Server\Service\Service;
$service = new Service();
$service->SetEmail("_email_");
$service->SetKey("_api_key_");
$servers = $service->getServers();
foreach ($servers as $server) {
if (is_array($server) && !empty($server)) {
$object = reset($server);
print($object->id . ': ' . $object->label . "\n");
}
}
<?php
require "vendor/autoload.php";
use Cloudways\Server\Service\Service;
$service = new Service();
$service->SetEmail("_email_");
$service->SetKey("_api_key_");
$service->manageServices('_server_id_', 'php7.3-fpm', 'restart');
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment