Skip to content

hamed-elfayome/Server-setup-automation

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

1 Commit
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

πŸš€ Server Setup & Hosting Automation

A comprehensive guide and automation toolkit for setting up secure, production-ready VPS servers with automated deployment capabilities for Laravel, Vue.js, and Next.js applications.

πŸ“‹ Table of Contents

✨ Features

  • πŸ”’ Secure Server Setup: SSH key authentication, firewall configuration, and security hardening
  • 🌐 Multi-Stack Support: Laravel (PHP), Vue.js (SPA), and Next.js (SSR) applications
  • πŸ”§ Automated Configuration: One-command project creation with database setup
  • πŸ“¦ SSL/TLS: Automatic Let's Encrypt certificate generation and renewal
  • πŸ”„ CI/CD Ready: GitHub Actions workflows for automated deployment
  • πŸ’Ύ Backup System: Automated backups with restore capabilities
  • πŸ“Š Monitoring: Built-in performance monitoring tools
  • πŸ” Database Management: MySQL with phpMyAdmin integration
  • πŸ“ FTP Support: Secure FTP server configuration

πŸš€ Quick Start

  1. Clone this repository:

    git clone https://github.com/yourusername/server-setup-automation.git
    cd server-setup-automation
  2. Run the initial server setup:

    chmod +x scripts/initial-setup.sh
    ./scripts/initial-setup.sh
  3. Create your first project:

    sudo bash scripts/create-project.sh example.com laravel

πŸ“‹ Prerequisites

  • Ubuntu 20.04+ VPS server
  • Root access to the server
  • Domain name pointing to your server's IP
  • SSH client on your local machine

πŸ›  Installation

Manual Installation

Follow the step-by-step guide in docs/INSTALLATION.md for detailed installation instructions.

Automated Installation

Use the provided scripts for automated setup:

# Initial server setup
./scripts/initial-setup.sh

# Install automation tools
./scripts/install-automation.sh

πŸ“– Usage

Creating New Projects

# Laravel project
sudo bash scripts/create-project.sh yourdomain.com laravel

# Vue.js project
sudo bash scripts/create-project.sh yourdomain.com vue

# Next.js project
sudo bash scripts/create-project.sh yourdomain.com next

Managing Projects

# List all projects
./scripts/list-projects.sh

# Backup a project
./scripts/backup-project.sh yourdomain.com

# Restore from backup
./scripts/restore-backup.sh

🎯 Project Types

Laravel Projects

  • PHP 8.2 with FPM
  • MySQL database with automatic user creation
  • phpMyAdmin with HTTP authentication
  • Composer dependency management
  • Laravel-specific optimizations

Vue.js Projects

  • Static file serving with Nginx
  • Asset optimization and caching
  • SEO-friendly configuration
  • Build process automation

Next.js Projects

  • PM2 process management
  • Automatic port assignment
  • Static asset optimization
  • Server-side rendering support

πŸ”„ GitHub Actions Integration

This repository includes ready-to-use GitHub Actions workflows for automated deployment:

Required Secrets

Configure these secrets in your GitHub repository:

  • SSH_PRIVATE_KEY: Your server's SSH private key
  • SERVER_HOST: Your server's IP address or domain
  • SERVER_PORT: SSH port (default: 22)
  • SERVER_USER: SSH username (default: admin)
  • SUDO_PASSWORD: Sudo password for the server user

πŸ”’ Security Features

  • SSH Key Authentication: Password-less login with ED25519 keys
  • Firewall Configuration: UFW with minimal required ports
  • SSL/TLS Encryption: Automatic Let's Encrypt certificates
  • Database Security: Secure MySQL configuration
  • File Permissions: Proper ownership and permission settings
  • HTTP Authentication: phpMyAdmin access protection

πŸ’Ύ Backup & Recovery

Automated Backups

Backups run automatically every Friday at 2:00 AM and include:

  • Web files (/var/www)
  • Nginx configuration (/etc/nginx)
  • MySQL databases (/var/lib/mysql)

Manual Backup

./scripts/backup-project.sh yourdomain.com

Restore from Backup

./scripts/restore-backup.sh

πŸ“Š Monitoring

Built-in monitoring tools:

  • htop: System resource monitoring
  • vnstat: Network usage tracking
  • PM2: Process monitoring (for Next.js projects)

🀝 Contributing

  1. Fork the repository
  2. Create a feature branch (git checkout -b feature/amazing-feature)
  3. Commit your changes (git commit -m 'Add some amazing feature')
  4. Push to the branch (git push origin feature/amazing-feature)
  5. Open a Pull Request

See CONTRIBUTING.md for detailed guidelines.

πŸ“„ License

This project is licensed under the MIT License - see the LICENSE file for details.

πŸ†˜ Support

πŸ™ Acknowledgments

  • Let's Encrypt for free SSL certificates
  • Nginx for the web server
  • PM2 for process management
  • GitHub Actions for CI/CD

Made with ❀️ for developers who value automation and security

About

A comprehensive guide and automation toolkit for setting up secure, production-ready VPS servers with automated deployment capabilities for Laravel, Vue.js, and Next.js applications.

Topics

Resources

License

Contributing

Security policy

Stars

Watchers

Forks

Contributors

Languages