Current Location: Home> Latest Articles> Complete Guide to Installing and Configuring OpenSSL for PHP on CentOS

Complete Guide to Installing and Configuring OpenSSL for PHP on CentOS

gitbox 2025-07-22

The Importance of Installing OpenSSL to Support PHP on CentOS

OpenSSL is a crucial component for ensuring data encryption and secure communication in modern web applications. For PHP servers running on CentOS, properly installing and configuring the OpenSSL extension is fundamental to securing your applications. This article will guide you through the installation and configuration steps to ensure your PHP environment supports OpenSSL.

Update System Packages

Before installing any new software, it's recommended to update system packages to avoid compatibility issues. Open the terminal and enter the following command:

<span class="fun">sudo yum update</span>

This command updates all available packages, ensuring your environment is up to date.

Install Required Development Tools

To support the upcoming installation processes, install the development tools group which includes the necessary libraries and tools for compilation:

<span class="fun">sudo yum groupinstall "Development Tools"</span>

This step prepares the system for compiling and installing OpenSSL and PHP extensions.

Install OpenSSL and Development Libraries

Run the following command to install OpenSSL and its development packages:

<span class="fun">sudo yum install openssl openssl-devel</span>

This ensures your system has the OpenSSL functionality and dependencies required for compilation.

Install PHP and Enable OpenSSL Extension

If PHP is not yet installed, you can install PHP along with the OpenSSL extension using:

<span class="fun">sudo yum install php php-openssl</span>

After installation, verify that the extension is enabled by running:

<span class="fun">php -m | grep openssl</span>

If "openssl" is returned, it means the extension is loaded correctly.

Restart Web Server to Apply Changes

After completing the configuration, restart your web server to make the changes effective. Depending on your server, run one of the following:

<span class="fun">sudo systemctl restart httpd</span>

or

<span class="fun">sudo systemctl restart nginx</span>

This ensures the PHP configuration is reloaded and OpenSSL features are activated.

Summary and Recommendations

By following these steps, you have successfully installed and enabled the OpenSSL extension for PHP on your CentOS system. This significantly improves the security of data transmission in your PHP applications. It is recommended to keep your system and extensions regularly updated to maintain a secure environment.

We hope this guide helps you configure PHP OpenSSL support on CentOS. Feel free to leave comments if you have any questions.