Skip to main content

Prerequisites

Before starting, ensure you have the following:
  • A fresh Ubuntu 24.04 server with root or sudo access.
  • A registered domain name with an A record pointing to your server’s public IP address.
  • An SSH client (e.g., Terminal, PuTTY) and an SFTP client (e.g., FileZilla).
  • A secure password for the database user.
  • Your application’s source code and database SQL file.
  • Back up your server before proceeding.
  • Obtain your server’s IP address from your hosting provider (e.g., AWS, DigitalOcean).

Table of Contents

  1. Connect to the Server
  2. Install and Configure Dependencies
  3. Upload Source Code
  4. Configure Application
  5. Enable HTTPS
  6. Set Up Firewall
  7. Troubleshooting

Step 1: Connect to the Server

Connect to your server via SSH to begin the setup process.
  1. Obtain your server’s IP address from your hosting provider.
  2. Open a terminal and connect: ssh root@<your-server-ip>
  3. If using a key-based connection: ssh -i yourkey.pem root@<your-server-ip>
    Verify SSH Service
    • If you can’t connect, ensure port 22 is open: sudo ufw allow 22.
    • Contact your hosting provider if SSH issues persist.

Step 2: Install and Configure Dependencies

Install the necessary software packages for your Aleuto application, including Nginx, PHP 8.4, PostgreSQL, Node.js, Redis, Memcached, Supervisor, and Certbot.
Update Package List
Upgrade Packages
Install Basic Packages
Verify Installation
Create Swap Space
Verify Swap
  • Swap space prevents memory issues on low-RAM servers.
  • Adjust the size based on your server’s needs.
Install Nginx
Remove Default Site
Verify Nginx
Add PHP Repository
Update Package Lists
Install Generic PHP Packages
Install PHP 8.4
Configure PHP for Secure Connections
Restart PHP-FPM
Verify PHP
  • Optionally, tune PHP-FPM settings in /etc/php/8.4/fpm/pool.d/www.conf (e.g., pm.max_children) based on server resources.
Download Composer
Move Composer
Verify Composer
Add Node.js Repository
Update Package Lists
Install Node.js and Tools
Verify Node.js and NPM
Install Redis
Enable and Start Redis
Verify Redis
  • Expected output: PONG
Install PostgreSQL
Configure PostgreSQL Users
Configure Remote Access
Create Database
Restart PostgreSQL
Verify PostgreSQL
  • Replace secure_password_here with a strong, unique password.
  • For better security, restrict remote access to specific IPs (e.g., host all all <your-ip>/32 scram-sha-256).
Install Memcached
Enable and Start Memcached
Verify Memcached
Install Supervisor
Enable and Start Supervisor
Verify Supervisor
Create Horizon Configuration
Horizon Configuration
Create Reverb Configuration
Reverb Configuration
Update Supervisor
Verify Supervisor Processes
  • Ensure Laravel Horizon and Reverb are installed in your project: composer require laravel/horizon laravel/reverb.
  • Check logs (/var/www/aleuto/storage/logs/horizon.log, /var/www/aleuto/storage/logs/reverb.log) if processes fail to start.
Install Certbot
Verify Certbot
Upgrade Check
Clean Up

Step 3: Upload Source Code

Upload your Aleuto application’s source code and database to the server.

Upload Source Code

  1. Download FileZilla Client.
  2. Download your application’s source code.
  3. Upload the source code to /var/www/aleuto.
Set Permissions
  • Verify the directory structure matches your application’s requirements.

Import Database

Import SQL File
Verify Database Import
  • Ensure database credentials are set in the .env file before importing.
  • If the import fails, check the SQL file for errors or verify PostgreSQL is running: sudo systemctl status postgresql.

Step 4: Configure Application

Configure Nginx and Laravel to serve your application.

Configure Nginx

Create Nginx Configuration
Nginx Configuration
Enable Site
Test Nginx Configuration
Restart Nginx
  • Replace your-domain.com with your actual domain.
  • Check /var/log/nginx/error.log if Nginx fails to start.

Configure Laravel

Navigate to Project Directory
Copy .env.example
Edit .env File
Example .env Configuration
Install Composer Dependencies
Install NPM Dependencies
Build Frontend Assets
Generate Application Key
Set Permissions
Add User to www-data Group
Create Storage Link
Set Up Laravel Scheduler
Add Cron Job
Verify Laravel
  • Test your application by visiting https://your-domain.com in a browser.
  • Ensure all .env values match your database and server setup.
  • Verify Horizon and Reverb: sudo supervisorctl status.

Step 5: Enable HTTPS

Secure your application with an SSL certificate using Certbot.

Enable HTTPS

Configure DNS
Obtain SSL Certificate
Test SSL Renewal
Restart Nginx
Verify SSL
  • Ensure DNS is fully propagated before running Certbot.
  • Certbot automatically configures Nginx for HTTPS.

Step 6: Set Up Firewall

Configure the firewall to allow necessary traffic.
Allow SSH, HTTP, HTTPS, and Reverb
Enable Firewall
Verify Firewall Status
  • Port 6001 is the default for Laravel Reverb; adjust if using a different port in your Reverb configuration.
  • Disable root SSH access for better security: edit /etc/ssh/sshd_config and set PermitRootLogin no, then restart SSH: sudo systemctl restart sshd.

Step 7: Troubleshooting

Common issues and solutions:
  • Nginx Fails to Start:
  • Check syntax: sudo nginx -t
  • View logs: cat /var/log/nginx/error.log
  • Database Connection Errors:
  • Verify .env credentials match the PostgreSQL user and database.
  • Test connection: psql -U aleuto_user -d aleuto_db -h 127.0.0.1
  • Permission Issues:
  • Ensure www-data owns files: sudo chown -R www-data:www-data /var/www/aleuto
  • Check permissions: ls -l /var/www/aleuto
  • Application Not Loading:
  • Verify Laravel logs: cat /var/www/aleuto/storage/logs/laravel.log
  • Ensure PHP-FPM is running: sudo systemctl status php8.4-fpm
  • Horizon or Reverb Not Running:
  • Check Supervisor status: sudo supervisorctl status
  • View logs: cat /var/www/aleuto/storage/logs/horizon.log or cat /var/www/aleuto/storage/logs/reverb.log
  • Ensure packages are installed: composer require laravel/horizon laravel/reverb
  • For persistent issues, check service logs (e.g., /var/log/php8.4-fpm.log, /var/log/postgresql/postgresql-17-main.log).
  • Contact your hosting provider or consult your application’s documentation for specific requirements.

Summary

You’ve successfully set up an Ubuntu 24.04 server with Nginx, PHP 8.4, PostgreSQL 17, Node.js, Redis, Memcached, Supervisor, and a Aleuto application with Horizon and Reverb, secured with an SSL certificate. Your application should now be accessible at https://your-domain.com.