đī¸ CreatorContent.net
U
User
!
-
!
-
Manage Subscription
Manage Tokens
Storage
Media Library â
Documentation
User Dashboard
Podcasts
Podcasts
Episodes
Transcriptions
Contributors
Studio
Public Profile
Public Profiles
Blog
Event Lists
Surveys
Contact Forms
Subscribers
Notifications & Shoutouts
Development
React Test
Media Library
Help Center
Admin Dashboard
Logout
Back to Documentation
Deployment
Deployment
File: 20-deployment.md
Documentation Index
Loading documentation...
# Deployment Guide ## Overview This guide covers deploying CreatorContent.net to a production server, including prerequisites, setup steps, and maintenance procedures. ## Prerequisites ### Server Requirements - **Operating System**: Linux (Ubuntu 20.04+ recommended) - **PHP**: 8.2 or higher - **Web Server**: Nginx or Apache - **Database**: MySQL 8.0+ or PostgreSQL 12+ - **Composer**: Latest version - **Node.js**: 18+ (for asset compilation) - **FFmpeg**: Latest (for Studio system) ### Required PHP Extensions ```bash php -m | grep -E 'pdo|pdo_mysql|mbstring|openssl|tokenizer|xml|json|curl|gd|zip|fileinfo' ``` Install missing extensions: ```bash sudo apt-get install php8.2-mysql php8.2-mbstring php8.2-xml php8.2-curl php8.2-zip php8.2-gd ``` ### Other Required Tools ```bash # FFmpeg (for Studio) sudo apt-get install ffmpeg # Composer curl -sS https://getcomposer.org/installer | php sudo mv composer.phar /usr/local/bin/composer # Node.js and npm curl -fsSL https://deb.nodesource.com/setup_18.x | sudo -E bash - sudo apt-get install -y nodejs ``` ## Initial Setup ### 1. Clone Repository ```bash cd /var/www git clone <repository-url> creatorcontent.net cd creatorcontent.net ``` ### 2. Install Dependencies ```bash # PHP dependencies composer install --optimize-autoloader --no-dev # JavaScript dependencies npm install ``` ### 3. Environment Configuration ```bash # Copy example file cp .env.example .env # Generate application key php artisan key:generate # Edit .env file with production values nano .env ``` See `docs/19-configuration.md` for all required environment variables. ### 4. Database Setup ```bash # Run migrations php artisan migrate --force # (Optional) Seed database php artisan db:seed --force ``` ### 5. Storage Setup ```bash # Create storage link php artisan storage:link # Set permissions sudo chown -R www-data:www-data storage bootstrap/cache sudo chmod -R 775 storage bootstrap/cache ``` ### 6. Build Assets ```bash # Production build npm run build # Or watch for development npm run dev ``` ### 7. Optimize Application ```bash # Cache configuration php artisan config:cache # Cache routes php artisan route:cache # Cache views php artisan view:cache # Optimize autoloader (already done with --optimize-autoloader) ``` ## Web Server Configuration ### Nginx Configuration Create `/etc/nginx/sites-available/creatorcontent.net`: ```nginx server { listen 80; server_name creatorcontent.net www.creatorcontent.net; root /var/www/html/creatorcontent.net/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; } location ~ /\.(?!well-known).* { deny all; } # Handle custom domains server_name_in_redirect off; # Custom domain resolution (handled by middleware) location ~ ^/[^/]+/?$ { try_files $uri $uri/ /index.php?$query_string; } } ``` Enable site: ```bash sudo ln -s /etc/nginx/sites-available/creatorcontent.net /etc/nginx/sites-enabled/ sudo nginx -t sudo systemctl reload nginx ``` ### Apache Configuration If using Apache, configure virtual host in `/etc/apache2/sites-available/creatorcontent.net.conf`: ```apache <VirtualHost *:80> ServerName creatorcontent.net ServerAlias www.creatorcontent.net DocumentRoot /var/www/html/creatorcontent.net/public <Directory /var/www/html/creatorcontent.net/public> AllowOverride All Require all granted </Directory> ErrorLog ${APACHE_LOG_DIR}/creatorcontent_error.log CustomLog ${APACHE_LOG_DIR}/creatorcontent_access.log combined </VirtualHost> ``` Enable site: ```bash sudo a2ensite creatorcontent.net.conf sudo a2enmod rewrite sudo systemctl reload apache2 ``` ## SSL/HTTPS Setup ### Using Let's Encrypt (Certbot) ```bash # Install Certbot sudo apt-get install certbot python3-certbot-nginx # Obtain certificate sudo certbot --nginx -d creatorcontent.net -d www.creatorcontent.net # Auto-renewal (already set up by certbot) sudo certbot renew --dry-run ``` Update Nginx configuration to redirect HTTP to HTTPS: ```nginx server { listen 80; server_name creatorcontent.net www.creatorcontent.net; return 301 https://$server_name$request_uri; } server { listen 443 ssl http2; server_name creatorcontent.net www.creatorcontent.net; # ... rest of config } ``` ## Queue Workers ### Supervisor Configuration Create `/etc/supervisor/conf.d/creatorcontent-worker.conf`: ```ini [program:creatorcontent-worker] process_name=%(program_name)s_%(process_num)02d command=php /var/www/html/creatorcontent.net/artisan queue:work --sleep=3 --tries=3 --max-time=3600 autostart=true autorestart=true stopasgroup=true killasgroup=true user=www-data numprocs=2 redirect_stderr=true stdout_logfile=/var/www/html/creatorcontent.net/storage/logs/worker.log stopwaitsecs=3600 ``` Start supervisor: ```bash sudo supervisorctl reread sudo supervisorctl update sudo supervisorctl start creatorcontent-worker:* ``` ## Cron Jobs Add Laravel scheduler to crontab: ```bash sudo crontab -e -u www-data ``` Add: ```cron * * * * * cd /var/www/html/creatorcontent.net && php artisan schedule:run >> /dev/null 2>&1 ``` ## Custom Domain Setup ### DNS Configuration For custom domains to work: 1. **Server must accept requests for all domains** (wildcard DNS or server-level config) 2. **Domain resolution middleware** checks `custom_domains` table 3. **DNS validation** must pass before domain is active ### Nginx Wildcard Configuration ```nginx server { listen 80 default_server; listen [::]:80 default_server; server_name _; root /var/www/html/creatorcontent.net/public; # ... rest of config } ``` This allows the application to handle any domain via middleware. ## Maintenance Procedures ### Updating Application ```bash cd /var/www/html/creatorcontent.net # Pull latest changes git pull origin main # Install/update dependencies composer install --optimize-autoloader --no-dev npm install npm run build # Run migrations php artisan migrate --force # Clear and rebuild caches php artisan config:clear php artisan route:clear php artisan view:clear php artisan cache:clear php artisan config:cache php artisan route:cache php artisan view:cache # Restart queue workers sudo supervisorctl restart creatorcontent-worker:* ``` ### Backup Procedures #### Database Backup ```bash # Daily backup script mysqldump -u username -p database_name > /backups/db_$(date +%Y%m%d).sql # Or use Laravel backup package php artisan backup:run ``` #### File Backup ```bash # Backup storage directory tar -czf /backups/storage_$(date +%Y%m%d).tar.gz storage/ ``` ### Monitoring #### Application Logs ```bash # View Laravel logs tail -f storage/logs/laravel.log # View queue logs tail -f storage/logs/worker.log ``` #### System Monitoring - Monitor disk space - Monitor queue worker processes - Monitor database connections - Monitor API response times ## Performance Optimization ### Enable OPcache Edit `/etc/php/8.2/fpm/php.ini`: ```ini opcache.enable=1 opcache.memory_consumption=128 opcache.max_accelerated_files=10000 opcache.validate_timestamps=0 # Set to 1 in development ``` Restart PHP-FPM: ```bash sudo systemctl restart php8.2-fpm ``` ### Enable Redis for Cache/Queue 1. Install Redis: ```bash sudo apt-get install redis-server ``` 2. Configure in `.env`: ```env CACHE_STORE=redis QUEUE_CONNECTION=redis REDIS_HOST=127.0.0.1 REDIS_PORT=6379 ``` ### Database Optimization - Enable query caching - Add indexes for frequently queried columns - Use database connection pooling - Monitor slow query logs ## Security Hardening ### File Permissions ```bash # Set correct ownership sudo chown -R www-data:www-data /var/www/html/creatorcontent.net # Set directory permissions find /var/www/html/creatorcontent.net -type d -exec chmod 755 {} \; # Set file permissions find /var/www/html/creatorcontent.net -type f -exec chmod 644 {} \; # Protect .env file chmod 600 /var/www/html/creatorcontent.net/.env # Make storage writable chmod -R 775 /var/www/html/creatorcontent.net/storage chmod -R 775 /var/www/html/creatorcontent.net/bootstrap/cache ``` ### Firewall Configuration ```bash # Allow SSH sudo ufw allow 22/tcp # Allow HTTP/HTTPS sudo ufw allow 80/tcp sudo ufw allow 443/tcp # Enable firewall sudo ufw enable ``` ### Application Security - Set `APP_DEBUG=false` in production - Use strong `APP_KEY` - Enable HTTPS only cookies - Configure CORS properly - Regular security updates ## Troubleshooting ### Common Deployment Issues 1. **500 Internal Server Error** - Check `storage/logs/laravel.log` - Verify file permissions - Check `.env` configuration 2. **Permission Denied Errors** - Fix ownership: `sudo chown -R www-data:www-data storage bootstrap/cache` - Fix permissions: `chmod -R 775 storage bootstrap/cache` 3. **Queue Jobs Not Running** - Check supervisor status: `sudo supervisorctl status` - View logs: `tail -f storage/logs/worker.log` 4. **Asset Files Not Loading** - Run `npm run build` - Check `public/build` directory exists - Verify web server serves static files 5. **Database Connection Failed** - Verify `DB_*` variables in `.env` - Check database server is running - Verify firewall allows connections ## Deployment Checklist ### Pre-Deployment - [ ] Server meets requirements - [ ] Dependencies installed - [ ] Environment variables configured - [ ] Database created and migrated - [ ] Storage link created - [ ] Assets built - [ ] Application optimized ### Post-Deployment - [ ] Web server configured - [ ] SSL certificate installed - [ ] Queue workers running - [ ] Cron jobs configured - [ ] File permissions set - [ ] Backup procedures in place - [ ] Monitoring configured - [ ] Error logging working ## Related Documentation - **Configuration**: See `docs/19-configuration.md` for environment variables - **Overview**: See `docs/01-overview.md` for setup instructions - **Admin Panel**: See `docs/18-admin-panel.md` for admin features
0
đ Page Notes
+ Add New
Add New Note
Type
âšī¸ Info
đ Bug
⨠Feature Request
đĄ Improvement
â Missing Feature
đ¨ Design Changes
Title (optional)
Note Content
đ Add Note