Deployment Guide
Deploy your DALT.PHP learning project
DALT.PHP is a learning framework, not designed for production. This guide covers deploying learning projects or prototypes. For production apps, use Laravel or Symfony.
Quick Deployment Options
Option 1: Shared Hosting (Easiest)
Good for simple learning projects you want to share.
Configure Web Root
Point your domain to the public/ directory.
In cPanel: Set Document Root to /home/username/public_html/public
Set Environment
Create .env file:
APP_ENV=production
APP_DEBUG=false
DB_DRIVER=sqlite
DB_DATABASE=database/app.sqliteSet Permissions
chmod -R 755 storage
chmod -R 755 databaseOption 2: VPS (More Control)
Use a VPS for full control over the environment.
Setup Server
# Update system
sudo apt update && sudo apt upgrade -y
# Install PHP 8.2+
sudo apt install php8.2 php8.2-cli php8.2-fpm php8.2-sqlite3 -y
# Install Nginx
sudo apt install nginx -yClone Project
cd /var/www
sudo git clone https://github.com/yourusername/your-project.git
cd your-project
composer install --no-devConfigure Nginx
Create /etc/nginx/sites-available/your-project:
server {
listen 80;
server_name yourdomain.com;
root /var/www/your-project/public;
index index.php;
location / {
try_files $uri $uri/ /index.php?$query_string;
}
location ~ \.php$ {
fastcgi_pass unix:/var/run/php/php8.2-fpm.sock;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi_params;
}
}Enable site:
sudo ln -s /etc/nginx/sites-available/your-project /etc/nginx/sites-enabled/
sudo nginx -t
sudo systemctl restart nginxSetup Environment
cp .env.example .env
nano .envSet production values:
APP_ENV=production
APP_DEBUG=falseRun Migrations & Set Permissions
php artisan migrate
sudo chown -R www-data:www-data /var/www/your-project
sudo chmod -R 755 /var/www/your-project
sudo chmod -R 775 /var/www/your-project/storageOption 3: Platform as a Service
Zero-config deployments for quick prototypes.
Providers: Railway, Render, Heroku
Example with Railway:
- Connect GitHub repository
- Railway auto-detects PHP
- Add environment variables
- Deploy automatically on push
Essential Configuration
Disable Debug Mode
In .env:
APP_ENV=production
APP_DEBUG=falseUse PostgreSQL (Optional)
For better performance than SQLite:
DB_DRIVER=pgsql
DB_HOST=localhost
DB_NAME=your_db
DB_USER=your_user
DB_PASS=your_passwordEnable HTTPS
Use Let's Encrypt for free SSL:
sudo apt install certbot python3-certbot-nginx
sudo certbot --nginx -d yourdomain.comSecurity Basics
Hide Sensitive Files
Ensure .env is not web-accessible (Nginx):
location ~ /\.env {
deny all;
}Set Secure Headers
add_header X-Frame-Options "SAMEORIGIN";
add_header X-Content-Type-Options "nosniff";Troubleshooting
500 Internal Server Error
Check logs:
tail -f /var/log/nginx/error.log
tail -f storage/logs/app.logCommon causes:
- Wrong file permissions
- Missing
.envfile - PHP errors
Database Connection Failed
Verify:
- Database credentials in
.env - Database server is running
- File permissions on SQLite database
Routes Not Working
Ensure:
- Nginx config has
try_filesdirective public/is the document root- PHP-FPM is running
Remember: DALT.PHP is for learning. For production apps, migrate to Laravel or another production-ready framework.