This guide outlines the steps to deploy an Angular frontend and a Laravel backend application on a Digital Ocean droplet. By following these instructions, you'll be able to set up and configure your server to host both the frontend and backend components of your application.
- A Digital Ocean account
- Basic understanding of Angular and Laravel development
- Familiarity with Linux server administration and command line interface
-
Create a Digital Ocean Droplet
- Log in to your Digital Ocean account and create a new droplet.
- Choose the desired operating system (e.g., Ubuntu) and configuration for your droplet.
-
SSH Into Your Droplet
- Once your droplet is created, SSH into it using the provided IP address and your SSH key.
-
Install Required Software
- Update the package list:
sudo apt update
- Install Nginx web server:
sudo apt install nginx
- Install PHP and required extensions for Laravel:
sudo apt install php php-cli php-fpm php-mysql php-json php-mbstring php-xml php-zip unzip
- Update the package list:
-
Configure Nginx
- Configure Nginx to serve your Angular frontend and Laravel backend applications. You'll need to create server blocks for each application.
-
Install Composer (for Laravel)
- Install Composer, a PHP dependency manager, by following the instructions on the Composer website.
-
Deploy Laravel Backend
- Clone your Laravel project repository onto the server.
- Install dependencies using Composer:
composer install
- Set up environment variables and configure your
.env
file. - Run database migrations and seeders if necessary:
php artisan migrate --seed
- Configure Nginx to serve your Laravel application.
-
Deploy Angular Frontend
- Build your Angular project locally:
ng build --prod
- Transfer the built files to your server using SCP or another file transfer method.
- Configure Nginx to serve your Angular application.
- Build your Angular project locally:
-
Secure Your Server
- Configure firewall rules to allow only necessary incoming traffic.
- Enable HTTPS by obtaining an SSL certificate and configuring Nginx to use it.
-
Test Your Deployment
- Access your server's IP address in a web browser to verify that both the Angular frontend and Laravel backend are functioning correctly.
-
Monitor and Maintain
- Set up monitoring and logging to keep track of server performance and errors.
- Regularly update your server's software to ensure security and stability.