PHP frameworks on DirectAdmin: configuration guide
PHP frameworks on DirectAdmin: configuration guide
Modern PHP frameworks like Laravel, Symfony, and CodeIgniter work excellently on DirectAdmin hosting, provided they are configured correctly. In this guide, you will learn how to optimally set up DirectAdmin for PHP framework development.Supported frameworks
Theory7 hosting with DirectAdmin supports all popular PHP frameworks:- Laravel: Most popular PHP framework
- Symfony: Enterprise-grade framework
- CodeIgniter: Lightweight framework
- Slim: Micro framework for APIs
- Lumen: Laravel micro framework
- Yii: High-performance framework
- CakePHP: Rapid development framework
Selecting PHP version
The correct PHP version is essential for frameworks.Version requirements
| Framework | Minimum PHP | Recommended |
|---|---|---|
| Laravel 11 | PHP 8.2 | PHP 8.3 |
| Symfony 7 | PHP 8.2 | PHP 8.3 |
| CodeIgniter 4 | PHP 8.1 | PHP 8.2+ |
| Slim 4 | PHP 7.4 | PHP 8.2+ |
Changing PHP version in DirectAdmin
- Log in to DirectAdmin
- Go to Domain Setup (under your domain)
- Click on PHP Version Manager or PHP Settings
- Select the desired PHP version
- Click on Save or Apply
PHP version per directory
You can use different PHP versions per subdirectory via .htaccess:# In .htaccess of the subdirectory
SetHandler application/x-httpd-php82
Configuring document root
Frameworks have a public directory that must be the document root.Why this is important
Frameworks separate:- public/: Web-accessible files (CSS, JS, index.php)
- Application code: Above the document root (secure)
Method 1: Symlink (recommended)
# Via SSH
cd ~/domains/jouwdomein.nl
# Backup existing public_html
mv public_html public_html_backup
# Symlink to framework public
ln -s myproject/public public_html
Method 2: DirectAdmin configuration
- Go to DirectAdmin
- Open Domain Setup
- Change Document Root to:
domains/jouwdomein.nl/myproject/public - Save the changes
Method 3: .htaccess redirect
If the above is not possible:# In root .htaccess
RewriteEngine On
RewriteCond %{REQUEST_URI} !^/myproject/public
RewriteRule ^(.*)$ /myproject/public/$1 [L]
Configuring SSH access
SSH is essential for Composer and artisan/console commands.Activating SSH
- Go to DirectAdmin
- Open Account Manager and then SSH Keys
- Click on Generate Key or upload your own key
- Activate SSH access
Making Composer available
Composer is available by default on Theory7 hosting:# Check version
composer --version
# Update if necessary
composer self-update
Setting file permissions
Correct permissions are crucial for frameworks.Default permissions
# Folders: 755
find /home/user/domains/domain.nl/myproject -type d -exec chmod 755 {} \;
# Files: 644
find /home/user/domains/domain.nl/myproject -type f -exec chmod 644 {} \;
Writable folders
Frameworks need write access for: Laravel:chmod -R 775 storage
chmod -R 775 bootstrap/cache
Symfony:
chmod -R 775 var
CodeIgniter:
chmod -R 775 writable
Database configuration
Connect your framework to MySQL/MariaDB.Creating a database
- Go to DirectAdmin
- Open Account Manager and then MySQL Management
- Click on Create new Database
- Fill in:
- Database name
- Username
- Password
- Click on Create
Connection string examples
Laravel (.env):DB_CONNECTION=mysql
DB_HOST=localhost
DB_DATABASE=user_dbname
DB_USERNAME=user_dbuser
DB_PASSWORD=wachtwoord
Symfony (.env):
DATABASE_URL="mysql://user_dbuser:wachtwoord@localhost/user_dbname"
Setting up cron jobs
Frameworks often have scheduled tasks.Creating a cron job
- Go to DirectAdmin
- Open Advanced Features and then Cron Jobs
- Click on Create Laravel scheduler:
* * * * * cd /home/user/domains/domain.nl/myproject && php artisan schedule:run >> /dev/null 2>&1
Symfony console:
0 */6* * * cd /home/user/domains/domain.nl/myproject && php bin/console app:my-command >> /dev/null 2>&1
Performance optimization
Optimize DirectAdmin for frameworks.Configuring OPcache
OPcache is enabled by default. Optimal settings via .htaccess or php.ini:opcache.enable=1
opcache.memory_consumption=128
opcache.max_accelerated_files=10000
opcache.validate_timestamps=0
Note: `validate_timestamps=0` requires manual cache reset during updates.
PHP memory limit
For larger applications:- Go to Domain Setup and then PHP Settings
- Increase `memory_limit` to 256M or 512M
- Save
php_value memory_limit 256M
Environment variables
Handle configuration securely..env security
Ensure that .env is not publicly accessible:- .env is above public/ (default safe)
- Add to .htaccess:
<Files .env> Order allow,deny Deny from all </Files>
Environment detection
Test if production is correctly detected: Laravel:php artisan env
Symfony:
php bin/console debug:container --env-vars
Configuring SSL/HTTPS
All frameworks must use HTTPS.Activating SSL
- Go to DirectAdmin
- Open SSL Certificates
- Select Let's Encrypt (free)
- Click on Save
Forcing HTTPS
In your framework's public/.htaccess:RewriteEngine On
RewriteCond %{HTTPS} off
RewriteRule ^(.*)$ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]
Deployment checklist
With every deployment:- Composer install with production flags
- Environment variables correct
- Cache cleared and warmed up
- Migrations executed
- File permissions checked
- SSL active
Related articles
- Laravel with Composer via SSH
- Artisan and Console commands via SSH
- Laravel .env and storage configuration
Need help?
We are here for you! Are you facing any issues or do you have questions? Our support team is happy to assist you personally. Send us a message via the ticket system - we usually respond within a few hours and are happy to help.
Was dit artikel nuttig?
0 van 0 vonden dit nuttig