cPanel and DirectAdmin: Webservers & PHP
cPanel and DirectAdmin Comparison
- cPanel & DirectAdmin: The Basics
- cPanel & DirectAdmin: Webservers & PHP
- cPanel & DirectAdmin: SQL, DNS and Email
- cPanel & DirectAdmin: Development & Log Locations
cPanel and Directadmin both offer methods of implementing PHP and Webserver changes, modules and/or configurations. We’ll go into each respective methods of handling this and how they go about it while providing relevant information that you may or may not find as useful as we did. ๐
The Webserver and PHP Implementation
Because the PHP handler one can use depends on what webserver has been selected, one cannot really manage PHP’s configuration without also considering the webserver configuration. These are heavily interdependent on one another. Thus it makes sense for major panels to combine the management of both into a single task. This is smart because it allows the panel to prevent incompatible setups from even being attempted, much less built and deployed.
For DirectAdmin, PHP and webserver management is handled by CustomBuild. For cPanel, it is EasyApache.
CustomBuild versus EasyApache
Both systems are equally adept at what they do. Which you’d prefer depends on your priorities. Both systems support multiple versions of PHP, and both can integrate flawlessly with Cloudlinux to be able to use the secured EOL PHP versions CloudLinux offers as well. If you’d prefer to be able to quickly make changes to the configuration, then EA is for you, but if you prefer more control to be able to build your configuration with custom modules, then CB is for you. Also, CustomBuild is actually used to manage all software installations on the server, such as MySQL, Roundcube, ClamAV, and many more. A single CustomBuild instance could be used to update many different software installations.
Major Pros & Cons of Each
Pro | Con | |
---|---|---|
DirectAdmin | Many different software installations are highly extendable thanks to being built from source | Building from source is slow |
cPanel | Changes can be made very, very fast to PHP and the webserver | Pre-built RPMs mean a limited set of RMS and thus less custom modules |
Supported Webservers
DIRECTADMIN | CPANEL |
---|---|
Apache | Apache |
Nginx | Nginx |
Nginx Reverse Proxy + Apache | N/A |
Litespeed (requires paid license) | Litespeed (requires paid license) |
OpenLitespeed | N/A |
Usage via a Graphical Interface
CustomBuild has long been used via the command line, but many aren’t comfortable using a terminal, so DirectAdmin now supports a CustomBuild GUI plugin. See here: CustomBuild 2.0
EasyApache has long supported usage via both the command line and via WHM’s EasyApache interface. EasyApache 4 is essentially a graphical interface for yum.
Command Line Usage
CustomBuild
DirectAdmin facilitates CustomBuild usage and configuration via the build command.
There is so much that can be done with this command. To view all options, you could just run the following:
/usr/local/directadmin/custombuild/build
The following will show you your current configuration:
/usr/local/directadmin/custombuild/build used_configs
And the following will show you what the latest available version of a software is versus that you have installed:
/usr/local/directadmin/custombuild/build versions
Use the following to update those that require updates:
/usr/local/directadmin/custombuild/build update_versions
The following will show some of the more important options as set in the /usr/loca/directadmin/custombuild/options.conf:
/usr/local/directadmin/custombuild/build options
The syntax is as follows for setting an option to a value:
/usr/local/directadmin/custombuild/build set option_name value
After setting the option as desired, you may need to issue commands to rebuild and rewrite configuration files. For example, the following set of commands would set the primary default PHP version to 7.3 and then update, rebuild, and rewrite the configuration files:
cd /usr/local/directadmin/custombuild
./build set php1_release 7.3
./build update
./build php n
./build rewrite_confs
cPanel
EasyApache4 uses yum for installing modules from the EA4 repository. This means that you can also use rpm to review installed modules. One could use the following to view all installed PHP 7.3 modules:
rpm -qa | grep ea-php73-php
And as for yum, the following can be used to install the XML PHP extension:
yum install ea-php70-php-xml -y
The following command is used to view and help manage the PHP Handlers for each PHP version:
/usr/local/cpanel/bin/rebuild_phpconf
To view the current PHP handlers for each PHP version:
/usr/local/cpanel/bin/rebuild_phpconf --current
To set the PHP handler to LSAPI for PHP version 7.2:
/usr/local/cpanel/bin/rebuild_phpconf --ea-php72=lsapi
It is important to remember that the .htaccess and .ini files must be rewritten if a PHP handler is changed. The WHMAPI can be used to reapply all PHP versions to all domains following a handler changes with a for loop like so:
for d in $(awk -F: '{print $1}' /etc/userdomains | grep -v '*' | grep -Pv 'ns[\d]'); do v=$(grep -P "^$d" /etc/userdatadomains | grep -Po 'ea-php[\d][\d]'); [[ -z $v ]] && v=$(grep def /etc/cpanel/ea4/php.conf | grep -Po 'ea-php[\d][\d]'); whmapi1 php_set_vhost_versions version=$v vhost-0=$d; done
It is also important to ensure that the user’s PHP settings are consistent across these files. The /usr/local/bin/ea_sync_user_phpini_settings script syncs the php.ini , .user.ini, and .htaccess files for either a specified user:
/usr/local/bin/ea_sync_user_phpini_settings --user=username
Or for all users:
/usr/local/bin/ea_sync_user_phpini_settings --all-users
There are also many, many more WHM API commands that can be used to manage Apache and PHP from the CLI. See here: WHM API 1 Sections – PHP.
Customizations
Webserver
DirectAdmin
When customizing your webserver configuration files, you must follow guidelines set forth by your chosen panel for doing so. If you do not, then your customizations will be overwritten the next time the panel rewrites these files. This is true for both DirectAdmin and cPanel.
DirectAdmin allows you to make changes via customized template files so that your customizations are used anytime configuration file rewrites are done. This is actually true for any DirectAdmin server services that use a template-based configuration, such as Named.
For example, to change the docroot for all subdomains, you would rewrite a custom virtualhost template specifying this customization.
Question: How do I change the DocumentRoot of only one of my subdomains?
Answer: Using a custom VirtualHost template
If you want to instead modify the httpd.conf, you would either edit the designated customizations file /etc/httpd/conf/extra/httpd-includes.conf, or create a custom httpd.conf in the CustomBuild custom/ directory. Custom httpd.conf. Such changes requiring this would include adding custom modules. Also, editing configuration settings, such as MaxClients or ServerLimit is done similarly. To accomplish this, locate the value you need to change like so:
grep -Rli 'serverlimit\|maxclients' /etc/httpd/conf/
Once you’ve found the file containing the value to edit, copy it into the CustomBuild custom/ directory and make the desired changes. This way, CustomBuild will recognize that you’ve customized your configuration and not overwrite the file containing those customizations. You must remember this change if you decide to change your configuration in the future, though.
If you need to make a customization to only one domain’s virtualhost, you would do so via Admin Level โ Custom Httpd configurations โ domain.com, which creates a custom httpd configuration file in the user’s data directory, /usr/local/directadmin/data/users/USER/domains/DOMAIN.TLD.cust_httpd
To summarize, if you need a change that will be applied to the httpd configuration, use the CB custom/ directory or use the /etc/httpd/conf/extra/httpd-includes.conf file if you are adding code rather than removing or altering existing code. If you need a change applied to all Vhosts for all or some domains (such as the webmail or stats subdomains by default) you’d use the custom virtualhost template. Setting up webmail.domain.com as default for new domains If you need a change for a single domain’s vhost, use the Custom Httpd configurations interface for that domain.
cPanel
cPanel makes use of include files for making changes to specific domains. You must create the specified path to the include file and the file itself containing the customizations and rebuild and restart Apache in order for a domain’s custom changes to be included. The main configuration file specifies these include file paths/names. Modify the content of specific virtualhosts Creating the path and the file must be done via CLI.
cPanel also allows one to change the templates as well, which will change how cPanel writes the virtualhosts in the first place. Modify the content of specific virtualhosts You would use this method if you needed a custom subdomain created by default for all domains, for example.
You can also use WHM to edit the global httpd configuration. Use this method to edit global variables, such as Server Limit, for example.
To summarize, cPanel offers the same techniques to customize the webserver configuration as DirectAdmin for the most part. One would use a customized global template to modify the Virtual Host created by the panel for all domains, the domain’s include files (found in the user’s data in DA) to edit the configuration for a single domain, and lastly, the global include files for editing the global httpd configuration.
The only major difference that I see between the two is that DirectAdmin allows one to make changes to the custombuild files for Apache to change what components it is built from source with. This difference exists because the configuration is built from source rather than from RPMs as is the case with cPanel.
PHP
PHP customization’s in DirectAdmin can be accomplished in many, many different ways, and the files that you would edit depend on what type of webserver and PHP handler you are using. It is actually quite confusing to navigate this, though that is the price you pay for having a highly customizable environment. There is no single panel-specified method, so unexpected results can occur when multiple files are edited with different or conflicting settings, especially when a server is managed by a team rather than a single person. Overall, the single method that appears to offer the most flexibility and will likely work regardless of your configuration involves creating a uniquely named custom php.ini file within the directory /usr/local/lib/phpXX/php.conf.d/. I want per-domain or per-path settings for php. You can then proceed to specify a PATH or HOST section to apply the custom php directives to a certain path or domain, respectively.
cPanel, on the other hand, has explicit instructions for PHP customizations. WHM contains the MultiPHP Manger and the MutliPHP INI Editor. The MultiPHP INI Editor in WHM is used to apply global php.ini settings, either via a php.ini or a php-fpm.conf (but both are editable via the MultiPHP INI Editor interface). Within cPanel, a MultiPHP INI Editor also exists, which can be used to make edits on a per domain basis. One nice feature of cPanel’s setup is that their MultiPHP INI Editors will create and correctly edit:
- a custom php.ini
- a custom .user.ini
- an .htaccess
They do this all within the same directory for the changes and keep these 3 files synced. This is really very helpful as it keeps one from having to analyze their PHP, PHP Handler, and Webserver configuration thoroughly before adjusting php settings. It also prevents conflicting changes in different locations that could result in one very frustrated site/system admin.
For information on PHP Handlers and their differences check out: PHP Handlers and what they are.
Conclusion
While a lot of information to take in, you can see that the differences between DirectAdmin and cPanel are few and in between. Both provide decent webserver and PHP coverage to allow any websites that you were running on cPanel to run on DirectAdmin and vice versa. There should be little to any issue caused should you have swapped to a different control panel.
KnownHost offers 365 days a year, 24 hours a day, all 7 days of the week best in class technical support. A dedicated team is ready to help you should you need our assistance. Youโre not using KnownHost for the best web hosting experience? Well, why not? Check with our Sales team to see what can KnownHost do for you in improving your web hosting experience.