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
All these frameworks share similar configuration requirements.

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

  1. Log in to DirectAdmin
  2. Go to Domain Setup (under your domain)
  3. Click on PHP Version Manager or PHP Settings
  4. Select the desired PHP version
  5. Click on Save or Apply
The change is immediately active for that domain.

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)
This prevents direct access to configuration files.
# 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

  1. Go to DirectAdmin
  2. Open Domain Setup
  3. Change Document Root to:
    domains/jouwdomein.nl/myproject/public
  4. 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

  1. Go to DirectAdmin
  2. Open Account Manager and then SSH Keys
  3. Click on Generate Key or upload your own key
  4. Activate SSH access
See also: 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

  1. Go to DirectAdmin
  2. Open Account Manager and then MySQL Management
  3. Click on Create new Database
  4. Fill in:
    • Database name
    • Username
    • Password
  5. 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

  1. Go to DirectAdmin
  2. Open Advanced Features and then Cron Jobs
  3. Click on Create
  4. 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:
  1. Go to Domain Setup and then PHP Settings
  2. Increase `memory_limit` to 256M or 512M
  3. Save
Or via .htaccess:
php_value memory_limit 256M

Environment variables

Handle configuration securely.

.env security

Ensure that .env is not publicly accessible:
  1. .env is above public/ (default safe)
  2. 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

  1. Go to DirectAdmin
  2. Open SSL Certificates
  3. Select Let's Encrypt (free)
  4. 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:
  1. Composer install with production flags
  2. Environment variables correct
  3. Cache cleared and warmed up
  4. Migrations executed
  5. File permissions checked
  6. SSL active

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.