Deploy Symfony Applications on UnderHost VPS
Deploy enterprise Symfony web applications on UnderHost VPS. Configure PHP-FPM, Nginx, database, environment variables, and production optimization.
On this page
Symfony is an enterprise-grade PHP framework known for flexibility, reusability, and powerful components. Unlike Laravel (batteries-included) or Flask (minimal), Symfony gives you fine-grained control—you pick exactly which components you need. This makes Symfony ideal for complex, large-scale applications and teams prioritizing long-term maintainability.
Symfony vs Laravel vs Django
| Aspect | Symfony | Laravel | Django |
|---|---|---|---|
| Language | PHP | PHP | Python |
| Philosophy | Enterprise, modular | Developer-friendly | Batteries-included |
| Learning Curve | Steep | Gentle | Moderate |
| Flexibility | Very high | High | Moderate |
| Best For | Large teams, complex apps | Fast startup, SMB | Rapid prototyping, Python |
| Community Size | Large, enterprise | Very large, growing | Massive |
Requirements
- UnderHost Cloud VPS or Dedicated Server
- PHP 7.4 or 8.0+ with extensions: OpenSSL, ctype, curl, JSON, iconv, xml
- Composer for dependency management
- MySQL/MariaDB or PostgreSQL for database
- Nginx or Apache web server
- SSH access and comfort with command line
Project Setup & Composer
Create a new Symfony project (or clone existing):
# Create new project
composer create-project symfony/skeleton my-app
# Or clone from Git
cd /home/username/public_html
git clone https://github.com/yourname/my-symfony-app.git
cd my-symfony-app
composer install
Verify installation:
php bin/console --version
You should see output like: Symfony 6.x.x
Environment Configuration
Create .env file for your environment (VPS/production):
cp .env .env.production
nano .env.production
Key environment variables:
APP_ENV=prod
APP_DEBUG=0
APP_SECRET=your-super-secret-key-change-this
DATABASE_URL="mysql://user:password@localhost:3306/dbname"
MAILER_DSN="smtp://localhost"
Load production environment on VPS:
export APP_ENV=prod
export DATABASE_URL="mysql://user:password@localhost/dbname"
Database Setup
Create database and user (cPanel):
- cPanel → MySQL Databases
- Create database:
username_symfony - Create user and grant permissions
Update DATABASE_URL in .env with credentials, then run s:
php bin/console doctrine:database:create
php bin/console doctrine:s:migrate
Web Server Configuration
Nginx Configuration (recommended for Symfony):
server {
listen 80;
server_name yourdomain.com;
root /home/username/public_html/my-app/public;
location / {
try_files $uri /index.php$is_args$args;
}
location ~ ^/index\.php(/|$) {
fastcgi_pass unix:/var/run/php-fpm.sock;
fastcgi_split_path_info ^(.+\.php)(/.*)$;
include fastcgi_params;
fastcgi_param SCRIPT_FILENAME $realpath_root$fastcgi_script_name;
fastcgi_param DOCUMENT_ROOT $realpath_root;
}
location ~ \.php$ {
return 404;
}
}
Apache Configuration (.htaccess in public/):
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(.*)$ index.php [QSA,L]
</IfModule>
Symfony Bundles (Extensions)
Symfony's power comes from reusable bundles. Install popular ones:
# ORM (Doctrine)
composer require doctrine
# User authentication
composer require symfony/security-bundle
# Form handling
composer require symfony/form
# Validation
composer require symfony/validator
# API platform (for REST APIs)
composer require api-platform/api-pack
Production Deployment
1. Clear cache (important for updates):
php bin/console cache:clear --env=prod
php bin/console cache:warmup --env=prod
2. Set proper permissions:
chmod -R 755 var/
chmod -R 755 public/
3. Compile assets (if using Webpack Encore):
npm install
npm run build
4. Enable HTTP caching headers:
# config/packages/framework.yaml
framework:
http_cache:
enabled: true
5. Setup logging for debugging issues:
# config/packages/monolog.yaml
monolog:
handlers:
main:
type: stream
path: "%kernel.logs_dir%/%kernel.environment%.log"
level: debug
Troubleshooting
| Problem | Solution |
|---|---|
| 500 Internal Server Error | Check logs: tail var/log/prod.log |
| Database connection failed | Verify DATABASE_URL in .env, user exists |
| Permission denied on var/ | Run: chmod -R 755 var/ public/ |
| Assets not loading | Clear cache: php bin/console cache:clear --env=prod |
| Slow performance | Enable HTTP caching, optimize queries with Doctrine |
Your .env contains secrets (database passwords, API keys). Add to .gitignore and provide .env.example instead for team members to copy.
Related: Laravel deployment | Django deployment | Composer package manager
Need a developer-friendly server?
Use an UnderHost Cloud VPS for SSH, Git, Node.js, Python, Laravel, Docker, cron, and custom development workflows.





















