omniglies / laravel-server-manager
A Laravel package for server management with SSH connectivity, git deployment, monitoring, and log viewing
Requires
- php: ^8.2
- illuminate/support: ^10.0|^11.0|^12.0
- phpseclib/phpseclib: ^3.0
Requires (Dev)
- illuminate/testing: ^10.0|^11.0|^12.0
- mockery/mockery: ^1.6
- orchestra/testbench: ^8.0|^9.0|^10.0
- phpunit/phpunit: ^10.0|^11.0
This package is auto-updated.
Last update: 2025-06-23 03:29:43 UTC
README
A comprehensive Laravel package for server management with SSH connectivity, git deployment, monitoring, and log viewing capabilities.
Features
- SSH Connection Management: Connect to remote servers using password or private key authentication
- Git Deployment: Deploy applications from git repositories with customizable build scripts
- Server Monitoring: Real-time monitoring of CPU, memory, disk usage, processes, and services
- Log Management: View, search, download, and manage server log files
- Web Interface: Clean, responsive web interface built with Tailwind CSS and Alpine.js
Installation
- Install the package via Composer:
composer require omniglies/laravel-server-manager
- Publish the configuration file:
php artisan vendor:publish --tag=config --provider="ServerManager\LaravelServerManager\ServerManagerServiceProvider"
- Publish and run migrations (optional, for storing server configurations):
php artisan vendor:publish --tag=migrations --provider="ServerManager\LaravelServerManager\ServerManagerServiceProvider"
php artisan migrate
- Publish views (optional, for customization):
php artisan vendor:publish --tag=views --provider="ServerManager\LaravelServerManager\ServerManagerServiceProvider"
Configuration
The package publishes a configuration file to config/server-manager.php
. You can customize:
- SSH connection settings
- Deployment configurations
- Monitoring thresholds
- Log management settings
- Security restrictions
- UI preferences
Usage
Web Interface
Visit /server-manager
in your Laravel application to access the web interface.
SSH Connection
use ServerManager\LaravelServerManager\Services\SshService; $sshService = app(SshService::class); $config = [ 'host' => 'your-server.com', 'username' => 'user', 'password' => 'password', // or use 'private_key' 'port' => 22 ]; $connected = $sshService->connect($config); if ($connected) { $result = $sshService->execute('ls -la'); echo $result['output']; }
Deployment
use ServerManager\LaravelServerManager\Services\DeploymentService; $deploymentService = app(DeploymentService::class); $config = [ 'repository' => 'https://github.com/user/repo.git', 'deploy_path' => '/var/www/html', 'branch' => 'main', 'build_commands' => ['npm install', 'npm run build'], 'post_deploy_commands' => ['php artisan migrate', 'php artisan cache:clear'] ]; $result = $deploymentService->deploy($config);
Monitoring
use ServerManager\LaravelServerManager\Services\MonitoringService; $monitoringService = app(MonitoringService::class); $status = $monitoringService->getServerStatus(); $processes = $monitoringService->getProcesses(10); $services = $monitoringService->getServiceStatus(['nginx', 'mysql']);
Log Management
use ServerManager\LaravelServerManager\Services\LogService; $logService = app(LogService::class); $logs = $logService->readLog('/var/log/nginx/error.log', 100); $searchResults = $logService->searchLog('/var/log/syslog', 'error', 50); $logFiles = $logService->getLogFiles('/var/log');
API Routes
The package provides several API endpoints:
Server Management
GET /server-manager/servers/status
- Get server statusPOST /server-manager/servers/connect
- Connect to serverPOST /server-manager/servers/disconnect
- Disconnect from serverGET /server-manager/servers/processes
- Get running processesGET /server-manager/servers/services
- Get service status
Deployment
POST /server-manager/deployments/deploy
- Deploy applicationPOST /server-manager/deployments/rollback
- Rollback deploymentGET /server-manager/deployments/status
- Get deployment status
Log Management
GET /server-manager/logs/files
- List log filesGET /server-manager/logs/read
- Read log fileGET /server-manager/logs/search
- Search in log fileGET /server-manager/logs/tail
- Tail log fileGET /server-manager/logs/download
- Download log filePOST /server-manager/logs/clear
- Clear log filePOST /server-manager/logs/rotate
- Rotate log file
Security
The package includes several security features:
- Command filtering (allowed/blocked commands)
- Connection limits
- Credential encryption options
- SSH key authentication support
- CSRF protection on all forms
Make sure to:
- Use strong SSH credentials
- Limit SSH access to specific IP addresses
- Regularly rotate SSH keys
- Monitor server access logs
Requirements
- PHP 8.2+
- Laravel 10.0+, 11.0+, or 12.0+
- phpseclib/phpseclib ^3.0
Contributing
Contributions are welcome! Please feel free to submit a Pull Request.
License
This package is open-sourced software licensed under the MIT license.
Support
For support, please create an issue in the GitHub repository or contact the maintainers.