Pages

Saturday, May 18, 2024

Enabling the MsSQL Extension in cPanel/WHM: A Manual Installation Guide

While cPanel/WHM offers a wide range of PHP extensions out of the box, the MsSQL extension for connecting to Microsoft SQL Server databases requires a bit of manual effort. In this guide, we'll walk you through the step-by-step process of installing and configuring the MsSQL extension on your cPanel server.

Prerequisites:

  • Root Access: You'll need root privileges on your server to perform these steps.
  • Source Code: Instead of using RPM packages (which can lead to dependency issues), we'll compile the necessary components from source code.

Installing Required Modules

  1. unixODBC:

    • Download: Get the source code from the official unixODBC website.
    • Extract: tar -xvf unixODBC-X.X.X.tar.gz (replace X.X.X with the version you downloaded).
    • Configure and Install:
      cd unixODBC-X.X.X
      ./configure --prefix=/usr/local --enable-gui=no
      make
      make install
      
    • Download: Download FreeTDS version 0.82 (or a compatible older version) from ftp://ftp.freetds.org/pub/freetds/old/0.82/freetds-0.82.tar.gz.
    • Extract: tar -xvf freetds-0.82.tar.gz
    • Configure and Install:
      cd freetds-0.82
      ./configure --with-tdsver=8.0 --with-unixODBC=/usr/local
      make
      make install
      
    • Edit freetds.conf: Find the freetds.conf file (usually in /usr/local/etc or /etc) and add the following, replacing placeholders:
      [MSHOSTNAME]
      host = your_sql_server_hostname_or_IP
      port = 1433 
      tds version = 8.0
      

Compiling mssql.so

  1. Navigate to PHP Extension Directory:

    cd /home/cpeasyapache/src/php-X.X.X/ext/mssql

    (Replace X.X.X with your PHP version.)

  2. Prepare and Build:

    phpize
    ./configure
    make
    make install

Activating the Extension

  1. Locate php.ini: Find your PHP configuration file (php.ini). Its location can vary depending on your setup.
  2. Add Extension: Open php.ini in a text editor and add the following line:
    extension="mssql.so"
    
  3. Restart Apache:
    service httpd restart

Verifying Installation

To confirm that the extension is loaded, you have two options:

  • Check Modules: Run php -m | grep mssql. If the installation was successful, you'll see "mssql" in the output.
  • Create a phpinfo Page: Create a PHP file with the following content:
    <?php phpinfo(); ?>
    Open this file in your browser and search for "mssql." You should see detailed information about the MsSQL extension.

Troubleshooting Tip:

If you encounter an error during the FreeTDS configuration related to unixODBC, try using an older version of FreeTDS (like 0.82), as newer versions might have compatibility issues.

By carefully following these steps, you can manually install and enable the MsSQL extension in your cPanel/WHM environment, allowing your PHP applications to seamlessly interact with Microsoft SQL Server databases.

PEAR Management in cPanel

Installing PEAR in cPanel: A Guide for PHP Developers

PEAR (PHP Extension and Application Repository) is a valuable resource for PHP developers, offering a framework and distribution system for reusable PHP components. Whether you're building custom web applications or need specific functionality, PEAR can streamline your development process.

In this guide, we'll walk you through the steps for installing PEAR in your cPanel environment. The process varies slightly depending on your PHP version:

PHP Versions Less Than 5.3

  1. Download go-pear: Use the following command in your terminal or SSH session:

    wget http://pear.php.net/go-pear
  2. Install PEAR: Run the downloaded script:

    php go-pear.php

    Follow the on-screen prompts to customize your installation.

PHP Versions 5.3 and Above

  1. Download go-pear.phar: Fetch the updated installer:

    wget http://pear.php.net/go-pear.phar
  2. Install PEAR: Execute the installer using the following command:

    php go-pear.phar
    

Important Notes

  • Root Access: You'll need root access (via SSH or console) to perform these commands. If you're not comfortable with server administration, contact your hosting provider for assistance.
  • Alternative Method: cPanel may have a built-in PEAR installer available in the software section. Check if this option exists for a more user-friendly installation.
Once PEAR is installed, you can manage packages using the pear command line tool:
  • Installing a Package:
    pear install <package_name>
  • Upgrading a Package:
    pear upgrade <package_name>
  • Uninstalling a Package:
    pear uninstall <package_name>
  • Listing Installed Packages:
    pear list

Why PEAR Matters

PEAR simplifies PHP development by providing:

  • Reusable Components: A vast library of code packages for various tasks.
  • Consistent Structure: A standardized way to organize and manage PHP projects.
  • Easy Installation: Simple commands for adding and updating packages.
  • Community Support: A large and active community of developers for troubleshooting and support.

By leveraging PEAR's capabilities, you can save time and effort while building robust and reliable PHP applications.

Let me know if you have any further questions about using PEAR with cPanel!

Resolving "Sorry, that domain is already setup (remove it from httpd.conf)" Error in cPanel/WHM

If you're a cPanel/WHM administrator, you might have encountered the frustrating error "Sorry, that domain is already set up (remove it from httpd.conf)" when trying to add a new domain. This error typically indicates that the domain name you're attempting to use is already associated with another account or configuration on your server.

In this guide, we'll break down the causes of this error and provide step-by-step instructions on how to resolve it.

Why Does This Error Occur?

There are two main reasons you might encounter this error:

Reason 1: The domain is already in use.

  • The domain could be assigned as a primary, addon, or parked domain on another cPanel account.
  • It might be lingering in the server's configuration even after being removed from an account.

Reason 2: Technical Glitches

  • The removal process for the domain might not have been completed correctly, leaving remnants in the system.

Troubleshooting and Resolution

1. Check if the Domain is Actively Used

If the error is due to the domain already being associated with another account:

  • Remove the domain: Log into the cPanel account that's using the domain and remove it as an addon, parked, or primary domain.

If you encounter the error "Error from park wrapper: Sorry, you do not control the domain" while trying to remove it, proceed to the next step.

2. Identify the Domain Owner and Remove Entries

  1. Find the Owner: Use the following commands in the server's command line (SSH) to determine which account the domain is associated with:

    /scripts/whoowns example.com 

    If this doesn't yield results, try:

    grep example.com /var/cpanel/users/*

    (Replace "example.com" with the actual domain name.)

  2. Remove Domain Entries: Once you know the owner account, remove any references to the domain from the following files:

    • /var/named/example.com.db
    • /etc/httpd/conf/httpd.conf (remove the virtual host entry)
    • /var/cpanel/users/username (remove entries related to the domain)
    • /etc/userdomains
    • /etc/localdomains
    • /etc/named.conf (remove entries related to the domain)
    • Remove DNS entry in WHM: Go to the DNS Zone Manager in WHM and remove the DNS zone for the domain.
  3. Update User Domains: Finally, run the following command as root:

    /scripts/updateuserdomains

Important Considerations:

  • Backups: Before making any changes to configuration files, it's crucial to have a backup of your server in case of unintended consequences.
  • Technical Expertise: If you're not comfortable with editing configuration files, consider seeking help from your hosting provider or a qualified system administrator.

By following these steps, you should be able to resolve the "Sorry, that domain is already set up" error and successfully add the domain to the desired cPanel account.