🌟 Table of Contents
🎯 Introduction
- 🧾 1.1 Overview of EasyApache 4
- 🏆 1.2 Benefits of EasyApache 4
- ⚙️ 1.3 Introduction to cPanel and WHM
- 🛡️ 1.4 Overview of CloudLinux
- 🔗 1.5 Advantages of Integrating EasyApache 4 with CloudLinux
🛠️ Prerequisites
- ✅ 2.1 System Requirements
- 🔑 2.2 Necessary Permissions and Access
- 💾 2.3 Backup Considerations
📦 Installing EasyApache 4
- 🔄 3.1 Updating the System
- 🌐 3.2 Accessing WHM (Web Host Manager)
- 🔄 3.3 Migrating from EasyApache 3 to EasyApache 4
- 🚀 3.4 EasyApache 4 Installation Steps
⚙️ Configuring EasyApache 4 in cPanel
- 🖥️ 4.1 Navigating to EasyApache 4 in WHM
- 📁 4.2 Understanding Profiles
- 🔧 4.2.1 Default Profiles
- 🌐 4.2.2 CloudLinux Profiles in EasyApache 4
- 🌟 CloudLinux + All PHP Options + OpCache
- ⚡ CloudLinux + All PHP Options + OpCache + mod_lsapi
- 🔒 CloudLinux + All PHP Options + ZendGuard
- 🔥 CloudLinux + All PHP Options + ZendGuard + mod_lsapi
- 🌍 CloudLinux + cPanel Default
- 🌟 CloudLinux + cPanel Default + mod_lsapi
- 🚀 CloudLinux + cPanel Default + Passenger
- 🛠️ CloudLinux + No PHP
- 🏎️ CloudLinux + cPanel Worker MPM
- ⚡ 4.3 Selecting and Customizing a Profile
- 🛠️ 4.4 Choosing Apache MPM Modules
- 📜 4.5 Selecting PHP Versions
- 🔧 4.6 Enabling/Disabling Apache and PHP Modules
- 🛑 4.7 Reviewing and Building the Profile
🔗 Integrating CloudLinux with cPanel
- 🌟 5.1 Installing CloudLinux OS
- 🔄 5.1.1 Converting from CentOS to CloudLinux
- 🔒 5.2 Registering the CloudLinux License
- 📦 5.3 Updating CloudLinux Components
- ✅ 5.4 Verifying Installation
🛠️ Configuring PHP Selector with CloudLinux
- 🛡️ 6.1 Overview of PHP Selector
- ⚙️ 6.2 Enabling PHP Selector in WHM
- 🔄 6.3 Configuring Multiple PHP Versions
- 🔧 6.4 Managing PHP Extensions per User
- 🌍 6.5 Setting Default PHP Version
⚡ Optimizing Apache with CloudLinux
- 🚀 7.1 Installing mod_lsapi
- 🏆 7.1.1 Benefits of mod_lsapi
- 🔧 7.2 Enabling mod_lsapi in EasyApache 4
- 🔗 7.3 Configuring Apache Handlers for mod_lsapi
- ⚡ 7.4 Performance Tuning with mod_lsapi
🔐 Implementing CageFS for Enhanced Security
- 🛡️ 8.1 Overview of CageFS
- 🔧 8.2 Enabling CageFS in WHM
- ⚙️ 8.3 Configuring CageFS Settings
- 🔒 8.4 Managing User Access with CageFS
Introduction
1.1 Overview of EasyApache 4
EasyApache 4 is a powerful suite developed by cPanel that allows system administrators to easily configure and manage the Apache web server and PHP on a cPanel & WHM server. It provides a modular and flexible architecture that simplifies the installation, configuration, and updating of web server components. EasyApache 4 replaces its predecessor, EasyApache 3, by introducing RPM (Red Hat Package Manager) packages for better stability, faster updates, and easier management.
Key features of EasyApache 4 include:
- Modular Design: Install only the components you need.
- Multiple PHP Versions: Support for concurrent PHP versions.
- Automated Updates: Seamless integration with cPanel's update system.
- Customization: Ability to create and manage custom profiles.
- Improved Performance: Enhanced handling of Apache and PHP modules.
1.2 Benefits of EasyApache 4
EasyApache 4 brings several advantages over its predecessor and other web server management tools:
- Efficiency: RPM-based package management speeds up installations and updates.
- Flexibility: Easily switch between different versions of Apache and PHP.
- Stability: Improved dependency management reduces conflicts and downtime.
- Security: Quicker deployment of security patches via RPM updates.
- User-Friendly Interface: Intuitive GUI in WHM for easy configuration.
- Automation: Supports automated provisioning and scripting for advanced users.
1.3 Introduction to cPanel and WHM
cPanel & WHM is a widely used web hosting control panel that provides a graphical interface and automation tools for simplifying website hosting and server management tasks.
- cPanel: The end-user interface where website owners can manage their sites, emails, databases, and more.
- WHM (Web Host Manager): The administrator interface used by server administrators and resellers to manage server-wide settings, hosting accounts, and services.
Key features include:
- Account Management: Create and manage user accounts and packages.
- Service Configuration: Control services like Apache, PHP, MySQL, and email servers.
- Security Tools: Implement firewalls, SSL certificates, and security policies.
- Automation: Schedule backups, updates, and maintenance tasks.
1.4 Overview of CloudLinux
CloudLinux OS is a specialized operating system designed for shared hosting environments. It enhances server stability, security, and performance by isolating users and allocating server resources efficiently.
Key features of CloudLinux include:
- Lightweight Virtual Environment (LVE): Isolates each user to prevent resource hogging.
- CageFS: A virtualized file system that encapsulates each user, improving security.
- PHP Selector: Allows users to choose their PHP version and modules.
- MySQL Governor: Monitors and restricts MySQL resource usage.
- Hardened Kernel: Provides enhanced security against exploits.
1.5 Advantages of Integrating EasyApache 4 with CloudLinux
Combining EasyApache 4 with CloudLinux offers a robust and efficient hosting environment:
- Resource Management: Use LVE to limit CPU, memory, and IO for each user, preventing a single account from affecting others.
- Multiple PHP Versions: EasyApache 4's support for multiple PHP versions complements CloudLinux's PHP Selector.
- Enhanced Security: Features like CageFS and HardenedPHP protect against various security threats.
- Performance Optimization: Modules like
mod_lsapi
improve PHP performance. - Ease of Use: Seamless integration simplifies management through WHM.
Prerequisites
2.1 System Requirements
Before proceeding, ensure your server meets the following requirements:
- Operating System: CloudLinux OS 7 or later.
- cPanel & WHM: Version 11.52 or higher (latest stable version recommended).
- Hardware:
- CPU: Minimum 1.1 GHz processor (multi-core recommended).
- RAM: Minimum 2 GB (4 GB or more recommended for optimal performance).
- Disk Space: At least 40 GB of free disk space.
- Network: Stable internet connection for downloads and updates.
- Licenses:
- Valid cPanel & WHM license.
- Valid CloudLinux license.
2.2 Necessary Permissions and Access
You will need:
- Root SSH Access: Full administrative privileges to execute commands and install software.
- WHM Access: Root-level access to the WHM interface.
- Firewall Access: Ability to open ports if necessary (e.g., ports 2087 for WHM).
2.3 Backup Considerations
Before making any significant changes:
- Full Server Backup: Use cPanel's backup tools or third-party solutions to back up all data.
- Configuration Backup:
- Export current Apache and PHP configurations.
- Backup custom configuration files (e.g.,
.htaccess
,php.ini
).
- Database Backup: Ensure all databases are backed up and can be restored if needed.
- Verify Backups: Test restoring backups in a staging environment to confirm data integrity.
Important: Proceeding without backups risks data loss or extended downtime.
Installing EasyApache 4
3.1 Updating the System
Keeping your system up-to-date ensures compatibility and security.
-
Update System Packages:
Log in via SSH as the root user and run:
yum update -y
-
Reboot if Necessary:
If the kernel or critical libraries were updated:
Note: Schedule downtime if rebooting a production server.reboot
3.2 Accessing WHM (Web Host Manager)
EasyApache 4 is managed through WHM.
-
Log into WHM:
- Open a web browser.
- Navigate to
https://your-server-ip:2087
orhttps://your-domain:2087
. - Enter your root username and password.
-
Verify Access:
- Ensure you can navigate the WHM interface without issues.
- Check that all necessary menus and options are visible.
3.3 Migrating from EasyApache 3 to EasyApache 4 (if applicable)
If you're currently using EasyApache 3:
-
Backup Current Configuration:
- Navigate to Home » Backup » Backup Configuration in WHM.
- Ensure backups are enabled and have been run recently.
-
Review EasyApache 3 Configuration:
- Go to Home » Software » EasyApache 3.
- Note your Apache and PHP versions, modules, and custom settings.
-
Check Compatibility:
- Some modules in EasyApache 3 may not be available in EasyApache 4.
- Visit cPanel's Module Compatibility List for details.
-
Run the Migration Tool:
- In WHM, navigate to Home » Software » EasyApache 4 Migration Tool.
- Click Start Migration.
- Review the report for any conflicts or deprecated modules.
-
Resolve Conflicts:
- Remove or replace incompatible modules.
- Adjust configurations as suggested by the migration tool.
-
Begin Migration:
- Once the configuration is compatible, proceed with the migration.
- Confirm any prompts to start the process.
-
Monitor the Migration:
- The migration may take some time.
- Watch for errors and address them if they occur.
-
Post-Migration Testing:
- Verify that websites are functioning correctly.
- Check PHP scripts, applications, and services.
3.4 EasyApache 4 Installation Steps
If EasyApache 4 is not installed:
Step 1: Access EasyApache 4 in WHM
-
Navigate to EasyApache 4:
- In WHM, go to Home » Software » EasyApache 4.
-
Install Prompt:
- If EasyApache 4 is not installed, you will be prompted to install it.
- Click Install EasyApache 4.
Step 2: Choose a Profile
-
Select a Profile:
- Available Profiles:
- cPanel Default: Basic Apache and PHP setup.
- CloudLinux Profiles: Optimized for CloudLinux environments.
- Available Profiles:
-
For CloudLinux Integration:
- Choose CloudLinux + All PHP Options + OpCache for a comprehensive setup.
Step 3: Customize the Profile (Optional)
-
Customize Modules:
- Click on Customize to modify the selected profile.
-
Apache Modules:
- Under Apache Modules, select or deselect modules as needed.
- Recommended modules:
mod_rewrite
: For URL rewriting.mod_security2
: For enhanced security.
-
PHP Versions:
- Under PHP Versions, select the PHP versions you wish to install.
- It's recommended to install multiple versions to support various applications.
-
PHP Extensions:
- Under each PHP version, select the necessary extensions (e.g.,
mysqli
,curl
,gd
).
- Under each PHP version, select the necessary extensions (e.g.,
-
Additional Packages:
- Under Additional Packages, consider installing:
mod_lsapi
: For improved PHP performance.mod_hostinglimits
: For CloudLinux resource management.
- Under Additional Packages, consider installing:
Step 4: Review and Provision
-
Review Selections:
- Go to the Review tab.
- Verify all selected modules and extensions.
-
Resolve Conflicts:
- If any conflicts or dependencies are noted, address them before proceeding.
-
Provision:
- Click Provision to begin the installation.
- Confirm the action when prompted.
Step 5: Monitor the Installation
-
Installation Progress:
- The provisioning process will display a progress bar.
- Do not navigate away from the page until it completes.
-
Completion Message:
- Once finished, a success message will appear.
- Read any notes or warnings provided.
Step 6: Verify Installation
-
Check Apache Status:
- In WHM, navigate to Home » Server Status » Apache Status.
- Ensure Apache is running without errors.
-
Verify PHP Versions:
- Use MultiPHP Manager in WHM to see installed PHP versions.
- Assign PHP versions to domains as needed.
-
Test Websites:
- Visit hosted websites to confirm they are functioning.
- Check for errors in logs:
- Apache logs:
/usr/local/apache/logs/error_log
- PHP logs: Depending on configuration, often in
/var/log/
- Apache logs:
Step 7: Post-Installation Configuration
-
Configure PHP Handlers:
- In MultiPHP Manager, set the PHP handlers (e.g.,
php-fpm
,lsapi
). mod_lsapi
is recommended for performance.
- In MultiPHP Manager, set the PHP handlers (e.g.,
-
Update PHP Settings:
- Use MultiPHP INI Editor to adjust
php.ini
settings. - Common adjustments:
memory_limit
upload_max_filesize
post_max_size
max_execution_time
- Use MultiPHP INI Editor to adjust
-
Restart Services:
-
Restart Apache to apply changes:
service httpd restart
- If using PHP-FPM:
service php-fpm restart
-
Step 8: Enable CloudLinux Features
-
Install CloudLinux Components (if not already installed):
-
Via SSH, run:
yum install lvemanager
-
Enable CageFS:
- In WHM, navigate to Home » Plugins » CageFS User Manager.
- Enable CageFS for desired users.
-
Configure LVE Manager:
- In WHM, go to Home » Plugins » LVE Manager.
- Set resource limits as appropriate.
-
Note: Always refer to the official documentation for the most accurate and up-to-date information:
Important: After installation, monitor server performance and logs closely to ensure everything is operating smoothly.
Configuring EasyApache 4 in cPanel
4.1 Navigating to EasyApache 4 in WHM
EasyApache 4 is managed through the WHM interface, providing an intuitive way to configure your Apache and PHP settings.
Steps to Navigate to EasyApache 4:
-
Log into WHM:
- Open your web browser.
- Navigate to
https://your-server-ip:2087
orhttps://your-domain:2087
. - Enter your root username and password.
-
Access EasyApache 4:
- Once logged in, use the search bar on the left side of the WHM interface.
- Type "EasyApache 4" into the search bar.
- Click on "EasyApache 4" under the Software section.
-
EasyApache 4 Interface:
- You will now be in the EasyApache 4 dashboard.
- From here, you can view and manage your Apache and PHP configurations.
4.2 Understanding Profiles
Profiles in EasyApache 4 are collections of configurations that define how Apache and PHP are set up on your server. They allow you to quickly deploy a set of predefined modules and settings.
4.2.1 Default Profiles
EasyApache 4 provides several default profiles designed for common use cases:
- cPanel Default: A basic configuration that includes Apache 2.4 and PHP 7.x versions with essential modules.
- All PHP Options + OpCache: Offers multiple PHP versions and includes all available PHP options with OpCache for performance optimization.
- MPM Event + PHP-FPM: Configures Apache to use the Event MPM with PHP-FPM, improving handling of concurrent connections.
These profiles serve as starting points and can be customized further to meet your specific needs.
4.2.2 CloudLinux Profiles in EasyApache 4
When integrating with CloudLinux, specialized profiles are available to leverage its features fully. These profiles include modules and settings optimized for CloudLinux's resource management and security capabilities.
4.2.2.1 CloudLinux + All PHP Options + OpCache
- Description: Contains Apache 2.4,
mod_hostinglimits
, PHP versions from 8.2 down to 5.1, and all PHP options with OpCache enabled. - Components:
- Apache 2.4: The latest stable version of the Apache web server.
- mod_hostinglimits: A CloudLinux module that enforces resource limits per user.
- PHP Versions 8.2 to 5.1: Supports a wide range of PHP versions.
- All PHP Options: Includes all available PHP extensions and modules.
- OpCache: Enhances PHP performance by caching precompiled script bytecode.
Use Case: Ideal for hosting environments that require flexibility with PHP versions and maximum performance.
4.2.2.2 CloudLinux + All PHP Options + OpCache + mod_lsapi
- Description: Contains Apache 2.4,
mod_hostinglimits
,mod_lsapi
, PHP versions from 8.2 down to 5.1, all PHP options, and OpCache. - Components:
- mod_lsapi: A high-performance PHP handler developed by CloudLinux.
- Benefits:
- Faster PHP execution compared to traditional handlers like suPHP or FastCGI.
- Lower memory consumption.
Use Case: Suitable for servers that demand high PHP performance and efficiency.
4.2.2.3 CloudLinux + All PHP Options + ZendGuard
- Description: Contains Apache 2.4,
mod_hostinglimits
, PHP versions from 8.2 down to 5.1, all PHP options, and ZendGuard. - Components:
- ZendGuard: Allows the execution of PHP scripts encoded with Zend Guard.
- Benefits:
- Supports legacy applications that require ZendGuard.
Use Case: Necessary when hosting applications encoded with ZendGuard.
4.2.2.4 CloudLinux + All PHP Options + ZendGuard + mod_lsapi
- Description: Contains Apache 2.4,
mod_hostinglimits
,mod_lsapi
, PHP versions from 8.2 down to 5.1, all PHP options, and ZendGuard. - Benefits:
- Combines high performance with compatibility for ZendGuard-encoded scripts.
Use Case: Ideal for environments needing both performance and ZendGuard support.
4.2.2.5 CloudLinux + cPanel Default
- Description: Contains Apache 2.4,
mod_hostinglimits
, and PHP versions from 8.2 down to 5.1. - Use Case: Provides a standard setup optimized for CloudLinux without additional PHP options or modules.
4.2.2.6 CloudLinux + cPanel Default + mod_lsapi
- Description: Contains Apache 2.4,
mod_hostinglimits
,mod_lsapi
, and PHP versions from 8.2 down to 5.1. - Benefits:
- Enhanced PHP performance while maintaining a standard configuration.
Use Case: For those who want a default setup with improved PHP handling.
4.2.2.7 CloudLinux + cPanel Default + Passenger
- Description: Contains Apache 2.4,
mod_hostinglimits
,mod_passenger
, and PHP versions from 8.2 down to 5.1. - Components:
- mod_passenger: Enables hosting of Ruby, Python, and Node.js applications.
- Use Case: Suitable for servers that need to support multiple programming languages.
4.2.2.8 CloudLinux + No PHP
- Description: Contains Apache 2.4,
mod_hostinglimits
, and no PHP. - Use Case: Ideal for servers where PHP is managed separately or not required.
4.2.2.9 CloudLinux + cPanel Worker MPM
- Description: Contains Apache 2.4,
mod_hostinglimits
, and PHP versions from 8.2 down to 5.1, optimized for the Worker MPM. - Benefits:
- The Worker MPM uses threads instead of processes, offering better scalability.
- Use Case: For environments that can benefit from threaded processing.
4.3 Selecting and Customizing a Profile
After understanding the available profiles, you can select one that best fits your needs and customize it further.
Steps to Select and Customize a Profile:
-
Select a Profile:
- In the EasyApache 4 interface, under "Currently Installed Packages", click on "Customize" to modify your current configuration.
- Alternatively, to start with a new profile, click on the "Profiles" tab.
- Choose the desired CloudLinux profile by clicking "Provision" next to it.
-
Customize the Profile:
- Click on "Customize" to adjust the selected profile before provisioning.
-
Modify Apache Modules:
- Navigate to the "Apache Modules" section.
- Enable or disable modules as required.
- Common Modules to Consider:
mod_rewrite
: For URL rewriting.mod_security2
: For security enhancements.mod_ssl
: For SSL/TLS support.
- Common Modules to Consider:
-
Select PHP Versions:
- Go to the "PHP Versions" section.
- Select the PHP versions you wish to install.
- It's recommended to install multiple versions to accommodate different applications.
-
Configure PHP Extensions:
- Under each PHP version, click on "PHP Extensions".
- Enable extensions needed by your applications.
- Common Extensions:
mysqli
orpdo_mysql
: For MySQL database interactions.gd
: For image processing.curl
: For data transfer with URL syntax.mbstring
: For multibyte string handling.
- Common Extensions:
-
Add Additional Packages:
- In the "Additional Packages" section, you can enable modules like:
mod_lsapi
: If not already included, for better PHP performance.mod_passenger
: If you need to support Ruby, Python, or Node.js applications.
- In the "Additional Packages" section, you can enable modules like:
-
Review Customizations:
- Once you've made your selections, proceed to the "Review" tab.
- Verify all the components you've selected.
-
Save as a Custom Profile (Optional):
- If you plan to reuse this configuration, you can save it as a custom profile.
- Click on "Save as profile", give it a name, and save.
4.4 Choosing Apache MPM Modules
Apache's Multi-Processing Modules (MPMs) determine how it handles client requests. Selecting the appropriate MPM can significantly affect your server's performance.
Available MPMs in EasyApache 4:
- Prefork MPM:
- Uses multiple child processes with one thread each.
- Compatible with non-thread-safe libraries.
- Higher memory usage.
- Worker MPM:
- Uses multiple child processes with many threads each.
- Better performance and lower memory usage.
- Event MPM:
- Similar to Worker MPM but optimizes handling of keep-alive connections.
Steps to Choose an MPM:
-
Navigate to Apache MPM Section:
- In the EasyApache 4 customization interface, click on "Apache MPM".
-
Select an MPM:
- Choose only one MPM. If unsure, Event MPM is generally recommended for most setups.
- Considerations:
- Use Prefork MPM if you need compatibility with non-thread-safe modules.
- Event MPM provides better performance for high-traffic servers.
-
Review Compatibility:
- Ensure that the PHP handler you plan to use is compatible with your chosen MPM.
- For example,
mod_lsapi
works well with all MPMs.
- For example,
- Ensure that the PHP handler you plan to use is compatible with your chosen MPM.
4.5 Selecting PHP Versions
Having multiple PHP versions allows you to support a broader range of applications.
Steps to Select PHP Versions:
-
Go to PHP Versions Section:
- In the EasyApache 4 customization interface, select "PHP Versions".
-
Select Desired Versions:
- Check the boxes next to the PHP versions you wish to install.
- Recommendations:
- Include the latest stable version (e.g., PHP 8.2).
- Include older versions if you host legacy applications.
- Be cautious with unsupported versions due to security risks.
-
Understand Support Levels:
- Supported Versions:
- Receive security updates and patches.
- End-of-Life (EOL) Versions:
- No longer receive official updates; consider using CloudLinux's HardenedPHP for security patches.
- Supported Versions:
4.6 Enabling/Disabling Apache and PHP Modules
Customizing modules allows you to tailor your server to your applications' requirements.
Enabling/Disabling Apache Modules:
-
Navigate to Apache Modules:
- In the customization interface, click on "Apache Modules".
-
Enable Modules:
- Check the boxes for modules you need.
- Essential Modules:
mod_rewrite
: For URL rewriting.mod_deflate
: For compression.mod_security2
: For a web application firewall.
- Essential Modules:
- Check the boxes for modules you need.
-
Disable Unnecessary Modules:
- Uncheck modules that are not needed to reduce resource usage and potential security vulnerabilities.
Enabling/Disabling PHP Extensions:
-
Select PHP Extensions:
- Under each PHP version, click on "PHP Extensions".
-
Enable Extensions:
- Check the extensions required by your applications.
- Common Extensions:
mysqli
orpdo_mysql
: Database interactions.gd
andimagick
: Image processing.json
: JSON data handling.xml
: XML parsing.
- Common Extensions:
- Check the extensions required by your applications.
-
Disable Unneeded Extensions:
- Uncheck extensions not used by your applications to optimize performance.
Considerations:
- Dependencies: Some modules and extensions depend on others. Review any dependency warnings.
- Security: Only enable what is necessary to minimize attack surfaces.
4.7 Reviewing and Building the Profile
After customizing your profile, you need to review your selections and provision the configuration.
Steps to Review and Build:
-
Review Selections:
- Click on the "Review" tab.
- This page summarizes all the changes you've made.
-
Check for Conflicts:
- Look for any warnings or conflicts.
- Resolve issues by adjusting your selections if necessary.
-
Confirm the Provisioning List:
- Ensure all desired components are listed under "Provisioning".
- Verify that unwanted modules are not included.
-
Start Provisioning:
- Click the "Provision" button.
- A confirmation dialog will appear; click "Provision" again to confirm.
-
Monitor the Provisioning Process:
- A progress bar will show the status of the installation.
- Important: Do not navigate away from the page until the process is complete.
-
Completion:
- Once finished, you will see a "Success" message.
- Review any notes or warnings provided.
-
Restart Services (if necessary):
- Some changes may require restarting Apache or PHP-FPM.
- You can restart services via WHM or command line:
- Apache:
service httpd restart
- PHP-FPM:
service php-fpm restart
- Apache:
-
Verify the Configuration:
- Check your websites to ensure they are functioning correctly.
- Use tools like
phpinfo()
to verify PHP versions and extensions.
-
Check Logs for Errors:
- Review Apache and PHP error logs for any issues:
- Apache Error Log:
/usr/local/apache/logs/error_log
- PHP Error Log: Depending on your configuration, often found in
/var/log/
or specified inphp.ini
.
- Apache Error Log:
- Review Apache and PHP error logs for any issues:
-
Tips:
- Backup Configurations: Before making significant changes, it's wise to back up your current configurations.
- Test Changes: If possible, test changes in a staging environment before applying them to a production server.
- Regular Updates: Keep your server and modules up to date for security and performance improvements.
By carefully selecting and customizing your EasyApache 4 profile, you can optimize your server's performance, security, and compatibility with the applications you host. CloudLinux's specialized profiles and modules provide additional benefits, especially in shared hosting environments where resource management and isolation are critical.
Remember to regularly review and update your configurations to adapt to changing requirements and to maintain optimal server health.
Integrating CloudLinux with cPanel
Integrating CloudLinux with cPanel enhances server stability, security, and performance. CloudLinux OS is designed specifically for shared hosting environments, providing features that isolate users and allocate server resources efficiently.
5.1 Installing CloudLinux OS
Before you can take advantage of CloudLinux features, you need to install CloudLinux OS on your server. If you are currently running CentOS, you can convert your existing system to CloudLinux without reinstalling the operating system.
5.1.1 Converting from CentOS to CloudLinux (if applicable)
Prerequisites:
- A valid CloudLinux license key.
- Root SSH access to your server.
- Ensure you have a full backup of your server before proceeding.
Steps to Convert CentOS to CloudLinux:
-
Obtain Your License Key:
- Purchase a CloudLinux license from the CloudLinux website.
- You will receive a license key via email or from your CloudLinux account dashboard.
-
Log into Your Server via SSH as Root:
ssh root@your-server-ip
-
Download and Run the Conversion Script:
-
Execute the following command, replacing
YOUR_LICENSE_KEY
with your actual license key:wget https://repo.cloudlinux.com/cloudlinux/sources/cln/cldeploy sh cldeploy -k YOUR_LICENSE_KEY
- The script will download and install the necessary packages to convert your CentOS system to CloudLinux.
-
-
Reboot the Server:
-
After the installation completes, reboot your server to boot into the CloudLinux kernel:
reboot
-
-
Verify the Conversion:
-
After the server reboots, log back in via SSH and run:
uname -r
-
-
Update the System:
-
Run the following commands to update all packages:
yum update -y
-
5.2 Registering the CloudLinux License
After installing CloudLinux, ensure your license is properly registered.
Steps to Register the License:
-
Run the Registration Command:
/usr/sbin/rhnreg_ks --activationkey=YOUR_LICENSE_KEY --force
- Replace
YOUR_LICENSE_KEY
with your CloudLinux license key. -
Verify License Status:
-
Check that the license is registered and active:
/usr/bin/cldetect --check-license
- The output should confirm that the license is valid.
-
5.3 Updating CloudLinux Components
To ensure that you have the latest features and security updates, update all CloudLinux components.
Steps to Update CloudLinux Components:
-
Update the System:
yum update -y
-
Install CloudLinux Packages:
-
Install key CloudLinux components:
yum install kernel lve-utils lvemanager --enablerepo=cloudlinux-updates-testing
-
-
Reboot the Server:
-
Reboot to ensure that the latest kernel and components are in use:
reboot
-
5.4 Verifying Installation
Confirm that CloudLinux is correctly installed and integrated with cPanel.
Steps to Verify Installation:
-
Check the Kernel Version:
Ensure it shows a CloudLinux kernel.uname -r
-
Verify LVE Manager Installation:
- Log into WHM.
- Navigate to Home » Server Configuration » CloudLinux LVE Manager.
- If the LVE Manager is accessible, it indicates proper integration.
-
Check cPanel Integration:
- In WHM, you should see CloudLinux-related options under the Plugins section.
-
Test Server Functionality:
- Ensure websites are running correctly.
- Check logs for any errors related to CloudLinux components.
Configuring PHP Selector with CloudLinux
The PHP Selector feature in CloudLinux allows users to select the PHP version and modules they need for their applications. This is especially useful in shared hosting environments where different users might have different requirements.
6.1 Overview of PHP Selector
PHP Selector enables end-users to choose their desired PHP version from a range provided by the server administrator. It also allows users to enable or disable PHP extensions and adjust PHP settings (like memory limit, execution time, etc.) within predefined limits.
Benefits:
- Flexibility: Users can select PHP versions from 4.4 to the latest stable release.
- Customization: Users can enable/disable PHP modules as needed.
- Isolation: Changes made by one user do not affect others.
6.2 Enabling PHP Selector in WHM
To use PHP Selector, it must be enabled and configured in WHM.
Steps to Enable PHP Selector:
-
Install the Required Packages:
-
Via SSH, install the PHP Selector components:
yum groupinstall alt-php yum install lvemanager
-
-
Enable PHP Selector in LVE Manager:
- Log into WHM.
- Navigate to Home » Server Configuration » CloudLinux LVE Manager.
- Click on the Options tab.
- Ensure PHP Selector is enabled.
-
Update CageFS Skeleton:
-
Run the following command to update CageFS:
cagefsctl --force-update
-
6.3 Configuring Multiple PHP Versions
By default, the PHP Selector supports various PHP versions. You can configure which versions are available to users.
Steps to Configure PHP Versions:
-
Access PHP Selector Configuration:
- In WHM, navigate to Home » Server Configuration » CloudLinux LVE Manager.
- Click on the Selector tab.
-
Select PHP Versions:
- Under the PHP Versions section, check or uncheck the PHP versions you want to make available.
-
Save Changes:
- Click Save to apply the changes.
6.4 Managing PHP Extensions per User
Users can enable or disable PHP extensions for their account through cPanel.
Steps for Users to Manage Extensions:
-
Log into cPanel:
- Navigate to the user's cPanel interface.
-
Access PHP Selector:
- Click on Select PHP Version under the Software section.
-
Select PHP Version:
- Choose the desired PHP version from the dropdown menu.
- Click Set as current.
-
Manage Extensions:
- Check or uncheck the extensions required.
- Extensions are grouped for easy navigation.
-
Adjust PHP Options:
- Click on Switch to PHP Options to adjust settings like
memory_limit
,upload_max_filesize
, etc.
- Click on Switch to PHP Options to adjust settings like
-
Save Changes:
- Click Save after making changes.
Note for Administrators:
- You can limit which extensions are available to users via the LVE Manager in WHM.
6.5 Setting Default PHP Version
As an administrator, you can set the default PHP version that will be applied to all users who have not selected a specific version.
Steps to Set Default PHP Version:
-
Access PHP Selector Configuration:
- In WHM, navigate to Home » Server Configuration » CloudLinux LVE Manager.
- Click on the Selector tab.
-
Set Default Version:
- Under Default PHP version, select the desired version from the dropdown.
-
Save Changes:
- Click Save to apply the new default.
Notes:
- The default version should be a stable and widely compatible version to minimize issues for users.
- Users can override the default by selecting their own PHP version in cPanel.
Optimizing Apache with CloudLinux
Optimizing Apache is crucial for performance and resource management. CloudLinux provides mod_lsapi
, a high-performance module for serving PHP pages.
7.1 Installing mod_lsapi
mod_lsapi
is a replacement for traditional PHP handlers like mod_php
, suPHP
, or FastCGI
. It offers better performance and lower memory consumption.
7.1.1 Benefits of mod_lsapi
- High Performance: Faster than other PHP handlers.
- Low Memory Footprint: Efficient memory usage, suitable for high-traffic servers.
- Opcode Caching: Compatible with opcode caching mechanisms like OPcache.
- Compatibility: Supports PHP directives from
.htaccess
and PHP ini files. - Security: Works with CageFS to isolate users.
Steps to Install mod_lsapi
:
-
Install the Package:
-
Via SSH, run:
yum install liblsapi liblsapi-devel
-
-
Install
mod_lsapi
for Apache:-
Run the installer:
/usr/bin/cloudlinux-install-liblsapi --apache
-
-
Restart Apache:
-
To apply changes:
service httpd restart
-
7.2 Enabling mod_lsapi
in EasyApache 4
After installing mod_lsapi
, enable it within EasyApache 4.
Steps to Enable mod_lsapi
:
-
Access EasyApache 4:
- Log into WHM.
- Navigate to Home » Software » EasyApache 4.
-
Customize Your Profile:
- Click on Customize next to your current profile.
-
Enable
mod_lsapi
:- Go to the Apache Modules section.
- Search for
mod_lsapi
. - Check the box to enable it.
-
Provision the Changes:
- Click on Review.
- Verify that
mod_lsapi
is selected for installation. - Click Provision to apply changes.
-
Restart Apache:
- Ensure Apache is restarted to load the new module.
7.3 Configuring Apache Handlers for mod_lsapi
Set mod_lsapi
as the handler for PHP to ensure it's used for processing PHP scripts.
Steps to Configure PHP Handlers:
-
Access MultiPHP Manager:
- In WHM, navigate to Home » Software » MultiPHP Manager.
-
Set PHP Handlers:
- Click on the PHP Handlers tab.
- For each PHP version you want to use
mod_lsapi
with, selectlsapi
as the handler.
-
Apply to Domains:
- Ensure that domains are assigned the correct PHP version.
-
Verify Configuration:
- Create a
phpinfo()
page on a test domain. - Access the page and check that the
Server API
showsLiteSpeed V6.6
.
- Create a
7.4 Performance Tuning with mod_lsapi
Fine-tuning mod_lsapi
can further enhance performance.
Adjust mod_lsapi
Settings:
-
Edit Configuration File:
-
The configuration file is located at:
/etc/apache2/conf.d/lsapi.conf
-
-
Key Parameters:
LSAPI_CHILDREN
: Number of child processes per virtual host.LSAPI_MAX_REQUESTS
: Number of requests before the process is recycled.LSAPI_MAX_IDLE
: Maximum idle time before the process is terminated.
-
Example Configuration:
<IfModule lsapi_module> LSAPI_Max_CHILDREN 10 LSAPI_Max_REQUESTS 500 LSAPI_Max_IDLE 300 </IfModule>
-
Restart Apache:
-
Apply changes by restarting Apache:
service httpd restart
-
Enable Opcode Caching:
-
OPcache:
- Ensure OPcache is enabled in PHP settings for better performance.
-
Steps to Enable OPcache:
- In cPanel, users can enable OPcache via the Select PHP Version interface.
- Alternatively, set
opcache.enable=1
in thephp.ini
file.
Implementing CageFS for Enhanced Security
CageFS is a virtualized per-user file system that encapsulates each user in their own environment. It prevents users from seeing each other's files and sensitive information.
8.1 Overview of CageFS
Features of CageFS:
- User Isolation: Each user operates in a separate virtual environment.
- Prevent Information Disclosure: Users cannot see other users' processes or system files.
- Secure Defaults: Blocks access to potentially dangerous functions.
- Customizable: Administrators can modify CageFS templates.
Benefits:
- Improved Security: Mitigates privilege escalation and information disclosure attacks.
- Stability: Malicious users cannot affect other users or the system.
- Compliance: Helps meet security standards and compliance requirements.
8.2 Enabling CageFS in WHM
To start using CageFS, you need to install and enable it on your server.
Steps to Enable CageFS:
-
Install CageFS:
-
Via SSH, run:
yum install cagefs
-
-
Initialize CageFS:
-
Set up the CageFS skeleton:
cagefsctl --init
-
-
Enable CageFS in WHM:
- Log into WHM.
- Navigate to Home » Plugins » CageFS User Manager.
- The interface allows you to manage CageFS settings and users.
8.3 Configuring CageFS Settings
Customize CageFS to suit your server's requirements.
Steps to Configure CageFS:
-
Access CageFS Configuration:
-
Via SSH, configuration files are located at:
/etc/cagefs/
-
-
Modify Configuration Files:
cagefs.conf
: Main configuration file.enable_mount_points.conf
: Directories to be mounted inside CageFS.etc
andskel
Directories: Templates for the virtualized environment.
-
Common Configurations:
-
Disable Certain Programs:
-
Edit
/etc/cagefs/conf.d/custom.cfg
. -
Add executables to disable, e.g.:
[disabled] /usr/bin/php
Modify Available Shells:
- Ensure only safe shells are available inside CageFS.
-
Update CageFS:
-
After making changes, update CageFS:
cagefsctl --force-update
-
-
-
8.4 Managing User Access with CageFS
Control which users are contained within CageFS.
Steps to Manage Users:
-
Enable CageFS for a User:
-
Via SSH:
cagefsctl --enable username
- Or enable for all users:
cagefsctl --enable-all
-
-
Disable CageFS for a User:
-
Via SSH:
cagefsctl --disable username
-
-
Manage Users via WHM:
- In WHM, navigate to Home » Plugins » CageFS User Manager.
- Use the interface to enable or disable CageFS per user.
-
Check User Status:
-
To list users and their CageFS status:
cagefsctl --list-enabled cagefsctl --list-disabled
-
Notes:
- User Experience: Users with CageFS enabled should not notice any difference in their hosting experience, except for increased security.
- Compatibility: CageFS is compatible with most applications, but if users experience issues, you may need to adjust CageFS settings.
By integrating CloudLinux with cPanel and configuring features like PHP Selector, mod_lsapi
, and CageFS, you enhance your server's performance, security, and flexibility. These tools help you provide a stable and secure hosting environment for all your users.
For a deeper dive into optimizing performance and securing your hosting environment, check out our companion article:
🔗 Advanced Security and Performance Optimization with CloudLinux and EasyApache 4 in cPanel
This guide includes:
- Setting Up SecureLinks Protection: Protect your hosting environment from symbolic link attacks.
- Managing and Updating Packages: Keep your CloudLinux and EasyApache 4 packages updated and secure.
- Monitoring and Resource Management: Effectively manage and monitor resources for optimal performance.
- Performance Optimization: Tips for configuring Apache, OPcache, HTTP/2, and more.
- Security Enhancements: Implement CSF, ModSecurity with OWASP rules, and SSL/TLS for enhanced security.
- Troubleshooting Common Issues: Resolve logs, module conflicts, PHP handler issues, and more.
- Best Practices: Backup strategies, regular updates, and compliance measures for long-term success.