Vanguard Installation Guide
This guide provides step-by-step instructions for installing Vanguard, a web application built on the Laravel framework. Follow the steps below to set up the project.
Prerequisites
- PHP 8.1 or higher
- Composer
- Node.js and npm
- PostgreSQL database
- Redis
- Open ports for SSH connections on destination servers
Step-by-Step Installation
Clone the Repository
bashgit clone https://github.com/vanguardbackup/vanguard vanguard cd vanguard
Set Up Environment File
bashcp .env.example .env
Edit the
.env
file to configure your environment:- Set database credentials (
DB_*
variables) - Add your email to
ADMIN_EMAIL_ADDRESSES
(comma-separated for multiple) - Set
SSH_PASSPHRASE
for your SSH key passphrase
- Set database credentials (
Install PHP Dependencies
bashcomposer install
Generate Application Key
bashphp artisan key:generate
Run Database Migrations
bashphp artisan migrate
Generate SSH Key
bashphp artisan vanguard:generate-ssh-key
Install and Compile Frontend Dependencies
bashnpm install npm run build
Configure GitHub Login (Optional) If you want to enable GitHub login:
- Create a new GitHub OAuth App at https://github.com/settings/developers
- Set the Authorization callback URL to
http://your-app-url/auth/github/callback
- Update your
.env
file with the GitHub app credentials:GITHUB_CLIENT_ID=your_github_client_id GITHUB_CLIENT_SECRET=your_github_client_secret
Set Up Reverb for Web Sockets
bashphp artisan reverb:start
Please update your
.env
accordingly, set your domain etc and the ports that Reverb will use. Please see the Reverb website for more details.Start Horizon
bashphp artisan horizon
By default, Vanguard will use Horizon to process background jobs such as backup tasks. It is important that Horizon is started for the jobs to be queued.
Your Vanguard application should now be accessible at http://localhost:8000
(or the URL provided by the serve
command).
Post-Installation Steps
Create Your Account
- Navigate to the Vanguard application in your web browser.
- Register a new account using the registration form or log in with GitHub if configured.
- After registration, add your email address to the
ADMIN_EMAIL_ADDRESSES
list in the.env
file to grant admin privileges.
Configure SSH Connections
- Ensure that the relevant ports are open on the destination servers for SSH connections.
- Verify that the SSH credentials and configurations in your Vanguard settings are correct.
- Test the SSH connections to ensure Vanguard can successfully connect to remote servers.
Production Deployment
For production environments, consider the following:
TIP
For easier management of Laravel applications in production, we highly recommend using a server management provider such as Ploi or Laravel Forge. These platforms automate many of the deployment steps, handle server provisioning, and provide easy-to-use interfaces for managing your Laravel applications. They can significantly simplify your deployment process and ongoing maintenance.
Web Server Configuration
- Configure Nginx or Apache to serve your application.
- Ensure proper permissions on storage and bootstrap/cache directories.
Background Job Processing
- Start Horizon for production:bash
php artisan horizon
- Set up a process monitor like Supervisor to keep Horizon running.
- Start Horizon for production:
Scheduled Tasks Add this Cron entry to your server:
* * * * * cd /path-to-your-project && php artisan schedule:run >> /dev/null 2>&1
Environment Optimization
bashphp artisan config:cache php artisan route:cache php artisan view:cache
SSL Configuration Ensure you have a valid SSL certificate installed and configured.
Firewall Configuration
- Configure your firewall to allow incoming connections on the necessary ports for SSH.
- Ensure that Vanguard can make outgoing SSH connections to your destination servers.
Troubleshooting
- If you encounter any issues with web sockets, ensure Reverb is properly configured and running.
- For database-related problems, verify your database credentials in the
.env
file. - If Horizon isn't processing jobs, check its configuration and ensure it's running.
- If SSH connections fail, verify that the necessary ports are open and that the SSH credentials are correct.
Updating Vanguard
To update Vanguard to the latest version:
- Pull the latest changes:bash
git pull origin main
- Update dependencies:bash
composer update npm update
- Run migrations:bash
php artisan migrate
- Rebuild assets:bash
npm run build
Remember to check the changelog for any breaking changes or additional update steps.
WARNING
Always backup your database and project files before performing updates.
For more detailed information, consult the official documentation for Laravel, Reverb, Horizon, and Pulse.