PHP is a popular scripting language that is especially suited to web development. It is fast, flexible, and pragmatic. PHP powers everything from your blog to the most popular websites in the world.
In this tutorial, we will guide you through the process of installing PHP 5.3 on CentOS or RHEL using the Webtatic repository. This tutorial is applicable to both 32-bit and 64-bit versions of CentOS or RHEL.
Installing Basic PHP Packages
To begin with, we will install the basic PHP packages. This can be done using the following command:
yum --enablerepo=webtatic install php
This command will enable the Webtatic repository and install the PHP package. The output will show the installation process, including the resolution of dependencies, the transaction check, and the installation of the PHP package and its dependencies.
[root@server /]# yum --enablerepo=webtatic install php Loaded plugins: fastestmirror Loading mirror speeds from cached hostfile * addons: ftp.oss.eznetsols.org * base: ftp.oss.eznetsols.org * extras: ftp.oss.eznetsols.org * updates: ftp.oss.eznetsols.org Setting up Install Process Resolving Dependencies --> Running transaction check ---> Package php.x86_64 0:5.3.5-1.1.w5 set to be updated --> Processing Dependency: php-cli = 5.3.5-1.1.w5 for package: php --> Processing Dependency: php-common = 5.3.5-1.1.w5 for package: php --> Running transaction check ---> Package php-cli.x86_64 0:5.3.5-1.1.w5 set to be updated ---> Package php-common.x86_64 0:5.3.5-1.1.w5 set to be updated --> Finished Dependency Resolution Dependencies Resolved ================================================================================ Package Arch Version Repository Size ================================================================================ Installing: php x86_64 5.3.5-1.1.w5 webtatic 1.3 M Installing for dependencies: php-cli x86_64 5.3.5-1.1.w5 webtatic 2.5 M php-common x86_64 5.3.5-1.1.w5 webtatic 567 k Transaction Summary ================================================================================ Install 3 Package(s) Upgrade 0 Package(s) Total download size: 4.3 M Is this ok [y/N]: y Downloading Packages: (1/3): php-common-5.3.5-1.1.w5.x86_64.rpm | 567 kB 00:00 (2/3): php-5.3.5-1.1.w5.x86_64.rpm | 1.3 MB 00:00 (3/3): php-cli-5.3.5-1.1.w5.x86_64.rpm | 2.5 MB 00:00 -------------------------------------------------------------------------------- Total 8.8 MB/s | 4.3 MB 00:00 Running rpm_check_debug Running Transaction Test Finished Transaction Test Transaction Test Succeeded Running Transaction Installing : php-common 1/3 Installing : php-cli 2/3 Installing : php 3/3 Installed: php.x86_64 0:5.3.5-1.1.w5 Dependency Installed: php-cli.x86_64 0:5.3.5-1.1.w5 php-common.x86_64 0:5.3.5-1.1.w5 Complete!
Installing PHP Packages for MySQL Integration and phpMyAdmin Management
Next, we will install the PHP packages that will integrate with MySQL and will be managed through phpMyAdmin. This can be done using the following command:
yum --enablerepo=webtatic install php php-mbstring php-common php-pdo php-mysql php-cli php-mcrypt php-gd
This command will install several PHP packages, including php-mbstring, php-common, php-pdo, php-mysql, php-cli, php-mcrypt, and php-gd. The output will show the installation process, including the resolution of dependencies, the transaction check, and the installation of the PHP packages.
[root@server /]# yum --enablerepo=webtatic install php php-mbstring php-common php-pdo php-mysql php-cli php-mcrypt php-gd Loaded plugins: fastestmirror Loading mirror speeds from cached hostfile * addons: ftp.oss.eznetsols.org * base: ftp.oss.eznetsols.org * extras: ftp.oss.eznetsols.org * updates: ftp.oss.eznetsols.org addons | 951 B 00:00 base | 2.1 kB 00:00 extras | 2.1 kB 00:00 updates | 1.9 kB 00:00 webtatic | 951 B 00:00 Setting up Install Process Resolving Dependencies --> Running transaction check ---> Package php.x86_64 0:5.3.5-1.1.w5 set to be updated ---> Package php-cli.x86_64 0:5.3.5-1.1.w5 set to be updated ---> Package php-common.x86_64 0:5.3.5-1.1.w5 set to be updated ---> Package php-gd.x86_64 0:5.3.5-1.1.w5 set to be updated ---> Package php-mbstring.x86_64 0:5.3.5-1.1.w5 set to be updated ---> Package php-mcrypt.x86_64 0:5.3.5-1.1.w5 set to be updated ---> Package php-mysql.x86_64 0:5.3.5-1.1.w5 set to be updated ---> Package php-pdo.x86_64 0:5.3.5-1.1.w5 set to be updated --> Finished Dependency Resolution Dependencies Resolved ================================================================================ Package Arch Version Repository Size ================================================================================ Installing: php x86_64 5.3.5-1.1.w5 webtatic 1.3 M php-cli x86_64 5.3.5-1.1.w5 webtatic 2.5 M php-common x86_64 5.3.5-1.1.w5 webtatic 567 k php-gd x86_64 5.3.5-1.1.w5 webtatic 107 k php-mbstring x86_64 5.3.5-1.1.w5 webtatic 1.2 M php-mcrypt x86_64 5.3.5-1.1.w5 webtatic 30 k php-mysql x86_64 5.3.5-1.1.w5 webtatic 90 k php-pdo x86_64 5.3.5-1.1.w5 webtatic 64 k Transaction Summary ================================================================================ Install 8 Package(s) Upgrade 0 Package(s) Total download size: 5.7 M Is this ok [y/N]: y Downloading Packages: (1/8): php-mcrypt-5.3.5-1.1.w5.x86_64.rpm | 30 kB 00:00 (2/8): php-pdo-5.3.5-1.1.w5.x86_64.rpm | 64 kB 00:00 (3/8): php-mysql-5.3.5-1.1.w5.x86_64.rpm | 90 kB 00:00 (4/8): php-gd-5.3.5-1.1.w5.x86_64.rpm | 107 kB 00:00 (5/8): php-common-5.3.5-1.1.w5.x86_64.rpm | 567 kB 00:00 (6/8): php-mbstring-5.3.5-1.1.w5.x86_64.rpm | 1.2 MB 00:00 (7/8): php-5.3.5-1.1.w5.x86_64.rpm | 1.3 MB 00:00 (8/8): php-cli-5.3.5-1.1.w5.x86_64.rpm | 2.5 MB 00:00 -------------------------------------------------------------------------------- Total 8.2 MB/s | 5.7 MB 00:00 Running rpm_check_debug Running Transaction Test Finished Transaction Test Transaction Test Succeeded Running Transaction Installing : php-common 1/8 Installing : php-cli 2/8 Installing : php-pdo 3/8 Installing : php-mcrypt 4/8 Installing : php-mbstring 5/8 Installing : php 6/8 Installing : php-mysql 7/8 Installing : php-gd 8/8 Installed: php.x86_64 0:5.3.5-1.1.w5 php-cli.x86_64 0:5.3.5-1.1.w5 php-common.x86_64 0:5.3.5-1.1.w5 php-gd.x86_64 0:5.3.5-1.1.w5 php-mbstring.x86_64 0:5.3.5-1.1.w5 php-mcrypt.x86_64 0:5.3.5-1.1.w5 php-mysql.x86_64 0:5.3.5-1.1.w5 php-pdo.x86_64 0:5.3.5-1.1.w5 Complete!
Commands Mentioned
- yum –enablerepo=webtatic install php – This command enables the Webtatic repository and installs the PHP package.
- yum –enablerepo=webtatic install php php-mbstring php-common php-pdo php-mysql php-cli php-mcrypt php-gd – This command installs several PHP packages that integrate with MySQL and can be managed through phpMyAdmin.
Conclusion
Installing PHP 5.3 on CentOS or RHEL using the Webtatic repository is a straightforward process that involves enabling the repository and using the yum command to install the necessary packages. This tutorial has provided step-by-step instructions for this process, as well as explanations of the commands used. By following these steps, you can successfully install PHP 5.3 on your CentOS or RHEL server and begin developing dynamic web content.
Remember, it’s important to keep your PHP installation and other server software up-to-date to ensure you have the latest features and security updates.
Whether you’re using a dedicated, VPS, or cloud hosting, keeping your server software up-to-date is a crucial part of maintaining a secure and efficient server environment.
We hope this tutorial has been helpful in guiding you through the process of installing PHP 5.3 on CentOS or RHEL.
If you have any further questions or need additional help, feel free to reach out.
Happy coding!
FAQ
-
What is the purpose of installing PHP on CentOS or RHEL?
PHP is a popular scripting language used in web development. By installing PHP on CentOS or RHEL, you enable your server to process PHP scripts, which can be used to create dynamic content on your websites or applications.
-
What is the Webtatic repository?
The Webtatic EL yum repository is a CentOS/RHEL repository that provides updated web-related packages. It includes the latest versions of packages like PHP, MySQL, among others, which are often more current than those included in CentOS and RHEL distributions.
-
Why do we need to install additional PHP packages like php-mbstring, php-common, php-pdo, php-mysql, php-cli, php-mcrypt, and php-gd?
These additional PHP packages provide extra functionalities. For example, php-mbstring provides multibyte specific string functions, php-mysql provides MySQL database server access, php-mcrypt provides encryption capabilities, php-gd provides image processing capabilities, and so on. These packages enhance the capabilities of your PHP installation, allowing you to create more complex and feature-rich applications.
-
What is phpMyAdmin and why is it mentioned in this tutorial?
phpMyAdmin is a free and open-source tool written in PHP, intended to handle the administration of MySQL or MariaDB with the use of a web browser. It can perform various tasks such as managing databases, tables, columns, relations, indexes, users, permissions, and so on. In this tutorial, it is mentioned because the PHP packages installed will be managed through phpMyAdmin.
-
What does the –enablerepo=webtatic option do in the yum command?
The –enablerepo=webtatic option in the yum command enables the Webtatic repository for that particular yum command. This allows yum to install packages from the Webtatic repository, which often contains more current versions of web-related packages than the default CentOS or RHEL repositories.