How To Install PHP In CentOS 7
PHP is a prevalent open-source scripting language that is ideal for web-based development. It is executed on the server-side and is used in a variety of websites/web-based applications. PHP is also an integral part of a LAMP stack, a widely used method to host websites, as it can do things such as process code to display content dynamically and connect to a MySQL database. Unfortunately, this wonderful package does not come pre-installed on CentOS 7; however, you can have it up and running in no time with a few commands. The focus of this article will be to instruct you on how to install PHP on a CentOS 7 based server.
Before getting started, you'll need to log in to your server using SSH. If you're not familiar with how to do this or like our articles, please take a moment and read through the following: Connecting to Your Server via SSH. Once you have connected to your server via SSH, you may proceed with the installation. You'll use the Yum package manager to install PHP and the php-mysql package:
yum install php php-mysql
Once the installation process is complete, it is advisable to restart the Apache webserver to begin working in tandem with PHP. This can be done by issuing the following command:
systemctl restart httpd.service
That's it! If you followed the process described above and completed it without any errors, PHP should now be installed and ready to use! You can also install and configure additional PHP modules to extend the functionality of PHP by using our guide: How to install PHP modules (CentOS 7).