How To Install PHP on a CentOS server

Following command will install PHP on your CentOS server / VPS.

Login to your server as root via SSH and run following command.

yum install php php-mysql


yum install php

Installation wizard will ask your confirmation. Press Y to complete installation.

Check Installation

Once PHP is installed, you can check the PHP version installed using below command

php -v

It will show something like this:

[[email protected] ~]# php -v
PHP 5.3.3 (cli) (built: Nov 22 2013 10:45:17)
Copyright (c) 1997-2010 The PHP Group
Zend Engine v2.3.0, Copyright (c) 1998-2010 Zend Technologies

Restart Apache

After installing PHP, restart Apache using below command

service httpd restart

Test PHP

After installing PHP and restarting Apache, its time to test PHP installation on the server.
Create a phpinfo.php fie in /var/www/html/ with following code:


Now open your http://Server-IP/phpinfo.php in any browser.
This should show PHP settings on your server. You have successfully installed PHP on your server.

You can now edit various PHP settings like memory_limit, max_execution_time, max_upload_size, post_max_size etc. in:



Our Recommended VPS Hosting

1 Comment

Leave us a Reply

Your email address will not be published. Required fields are marked *

* *