Install on Cloud Server (LEMP Stack)
LEMP (Linux, Nginx, MySQL, PHP) is a high-performance web server stack. This guide covers deploying bPass on cloud servers with Nginx, which offers better performance and resource efficiency compared to Apache.
Prerequisites
- A fresh Ubuntu 20.04+ or Debian 11+ server
- Root or sudo access to the server
- A domain name pointing to your server's IP address
- Basic knowledge of Linux command line
Step 1: Prepare Your Server Environment
Update Your System
Install Nginx Web Server
# Install Nginx
sudo apt install nginx -y
# Start and enable Nginx
sudo systemctl start nginx
sudo systemctl enable nginx
# Check Nginx status
sudo systemctl status nginx
Install MySQL Database Server
# Install MySQL
sudo apt install mysql-server -y
# Secure MySQL installation
sudo mysql_secure_installation
# Start and enable MySQL
sudo systemctl start mysql
sudo systemctl enable mysql
Install PHP 8.2+ with PHP-FPM
# Add PHP repository
sudo apt install software-properties-common -y
sudo add-apt-repository ppa:ondrej/php -y
sudo apt update
# Install PHP-FPM and required extensions
sudo apt install php8.2-fpm php8.2-mysql php8.2-xml php8.2-gd \
php8.2-mbstring php8.2-tokenizer php8.2-json php8.2-bcmath php8.2-curl \
php8.2-zip php8.2-intl php8.2-readline php8.2-imagick -y
# Start and enable PHP-FPM
sudo systemctl start php8.2-fpm
sudo systemctl enable php8.2-fpm
# Check PHP version
php -v
Install Additional Tools
# Install Composer
curl -sS https://getcomposer.org/installer | php
sudo mv composer.phar /usr/local/bin/composer
# Install unzip
sudo apt install unzip -y
# Install Git (optional, but useful)
sudo apt install git -y
Step 2: Configure Nginx Server Block
Create Directory for Your Application
# Create directory
sudo mkdir -p /var/www/bpass.yourdomain.com
# Set ownership
sudo chown -R $USER:www-data /var/www/bpass.yourdomain.com
Create Nginx Server Block Configuration
Add the following configuration (replace bpass.yourdomain.com with your actual domain):
server {
listen 80;
listen [::]:80;
server_name bpass.yourdomain.com www.bpass.yourdomain.com;
root /var/www/bpass.yourdomain.com/public;
add_header X-Frame-Options "SAMEORIGIN";
add_header X-Content-Type-Options "nosniff";
index index.php;
charset utf-8;
location / {
try_files $uri $uri/ /index.php?$query_string;
}
location = /favicon.ico { access_log off; log_not_found off; }
location = /robots.txt { access_log off; log_not_found off; }
error_page 404 /index.php;
location ~ \.php$ {
fastcgi_pass unix:/var/run/php/php8.2-fpm.sock;
fastcgi_param SCRIPT_FILENAME $realpath_root$fastcgi_script_name;
include fastcgi_params;
fastcgi_hide_header X-Powered-By;
}
location ~ /\.(?!well-known).* {
deny all;
}
# Security headers
add_header X-XSS-Protection "1; mode=block";
add_header Referrer-Policy "strict-origin-when-cross-origin";
# Gzip compression
gzip on;
gzip_vary on;
gzip_min_length 1024;
gzip_types text/plain text/css text/xml text/javascript application/javascript application/xml+rss application/json;
# Client upload limit (adjust as needed)
client_max_body_size 100M;
# Log files
access_log /var/log/nginx/bpass_access.log;
error_log /var/log/nginx/bpass_error.log;
}
Enable the Server Block
# Create symbolic link to enable site
sudo ln -s /etc/nginx/sites-available/bpass.yourdomain.com /etc/nginx/sites-enabled/
# Test Nginx configuration
sudo nginx -t
# Restart Nginx
sudo systemctl restart nginx
Step 3: Configure PHP-FPM
Optimize PHP-FPM Configuration
Update these settings for better performance:
; Process manager settings
pm = dynamic
pm.max_children = 50
pm.start_servers = 5
pm.min_spare_servers = 5
pm.max_spare_servers = 35
pm.max_requests = 1000
; Security settings
security.limit_extensions = .php
Configure PHP Settings
Update these important settings:
max_execution_time = 300
max_input_vars = 3000
memory_limit = 256M
post_max_size = 100M
upload_max_filesize = 100M
; Enable OPcache for better performance
opcache.enable=1
opcache.memory_consumption=128
opcache.max_accelerated_files=4000
opcache.revalidate_freq=2
Restart PHP-FPM:
Step 4: Set Up MySQL Database
Create Database and User
# Login to MySQL
sudo mysql -u root -p
# Create database and user
CREATE DATABASE bpass_db;
CREATE USER 'bpass_user'@'localhost' IDENTIFIED BY 'your_secure_password';
GRANT ALL PRIVILEGES ON bpass_db.* TO 'bpass_user'@'localhost';
FLUSH PRIVILEGES;
EXIT;
Step 5: Upload and Deploy bPass
Upload Application Files
Option A: Using SCP from your local machine
Option B: Using wget/curl (if you have a direct download link)
Extract and Set Up Application
# Navigate to web directory
cd /var/www/bpass.yourdomain.com
# Extract application
sudo unzip /tmp/application.zip -d /var/www/bpass.yourdomain.com/
sudo mv /var/www/bpass.yourdomain.com/application/* /var/www/bpass.yourdomain.com/
sudo rmdir /var/www/bpass.yourdomain.com/application
# Set proper ownership and permissions
sudo chown -R www-data:www-data /var/www/bpass.yourdomain.com
sudo find /var/www/bpass.yourdomain.com -type f -exec chmod 644 {} \;
sudo find /var/www/bpass.yourdomain.com -type d -exec chmod 755 {} \;
# Make storage and cache directories writable
sudo chmod -R 775 /var/www/bpass.yourdomain.com/storage
sudo chmod -R 775 /var/www/bpass.yourdomain.com/bootstrap/cache
Install Composer Dependencies (if needed)
Step 6: Configure Firewall
Step 7: Run the Web Installer
- Visit Your Domain: Open
http://bpass.yourdomain.comin your browser - Automatic Redirect: You'll be redirected to
/install - Follow Installation Steps:
Step 1 - License Agreement: - Accept the license terms - Set your timezone - Continue
Step 2 - System Requirements: - Verify all server requirements are met - Fix any issues if shown
Step 3 - File Permissions: - Ensure all directories have proper permissions - Fix permissions if needed:
sudo chmod -R 775 /var/www/bpass.yourdomain.com/storage
sudo chmod -R 775 /var/www/bpass.yourdomain.com/bootstrap/cache
Step 4 - Database Configuration:
- Database Host: localhost
- Database Name: bpass_db
- Database Username: bpass_user
- Database Password: Your database password
- Test connection and continue
Step 5 - Complete Setup: - Configure email, storage, and queue settings - Complete the installation
Step 8: Set Up SSL Certificate (Recommended)
Using Let's Encrypt (Free SSL)
# Install Certbot for Nginx
sudo apt install certbot python3-certbot-nginx -y
# Get SSL certificate
sudo certbot --nginx -d bpass.yourdomain.com -d www.bpass.yourdomain.com
# Test automatic renewal
sudo certbot renew --dry-run
The SSL certificate will automatically update your Nginx configuration.
Step 9: Configure Cron Jobs for Laravel
# Edit crontab
sudo crontab -e
# Add Laravel scheduler
* * * * * cd /var/www/bpass.yourdomain.com && php artisan schedule:run >> /dev/null 2>&1
Step 10: Set Up Queue Worker (Optional)
For better performance, set up a queue worker with Supervisor:
# Install Supervisor
sudo apt install supervisor -y
# Create supervisor configuration
sudo nano /etc/supervisor/conf.d/bpass-worker.conf
Add the following:
[program:bpass-worker]
process_name=%(program_name)s_%(process_num)02d
command=php /var/www/bpass.yourdomain.com/artisan queue:work --sleep=3 --tries=3
autostart=true
autorestart=true
user=www-data
numprocs=1
redirect_stderr=true
stdout_logfile=/var/www/bpass.yourdomain.com/storage/logs/worker.log
stopwaitsecs=3600
# Update supervisor
sudo supervisorctl reread
sudo supervisorctl update
sudo supervisorctl start bpass-worker:*
Performance Optimization
Enable Nginx Caching
Add inside the server block:
# Cache static files
location ~* \.(jpg|jpeg|png|gif|ico|css|js|woff|woff2|ttf|svg)$ {
expires 1y;
add_header Cache-Control "public, immutable";
access_log off;
}
Configure Nginx Rate Limiting
Add this before the server block:
# Rate limiting
limit_req_zone $binary_remote_addr zone=login:10m rate=5r/m;
# Then inside server block for login endpoints
location /login {
limit_req zone=login burst=5 nodelay;
try_files $uri $uri/ /index.php?$query_string;
}
Troubleshooting
Common Issues
Test Nginx Configuration:
Check Nginx Error Logs:
Check PHP-FPM Status:
Check PHP-FPM Logs:
Fix Permissions Issues:
sudo chown -R www-data:www-data /var/www/bpass.yourdomain.com
sudo chmod -R 755 /var/www/bpass.yourdomain.com
sudo chmod -R 775 /var/www/bpass.yourdomain.com/storage
sudo chmod -R 775 /var/www/bpass.yourdomain.com/bootstrap/cache
Test MySQL Connection:
Performance Monitoring
Check Nginx Status:
Monitor PHP-FPM Pool:
Check Resource Usage:
Your bPass installation on LEMP stack is now complete and optimized for high performance!