Install and Test PHP on Linux system

by Vivek Gite on August 22, 2006 · 4 comments

Q. How can I install and test PHP on Linux? How do I make sure it is working on my Linux system? I am using Red Hat Fedora Core Linux.

A. PHP (PHP Hypertext Preprocessor) is an open-source, programming language. Originally designed as a high level scripting language for producing dynamic Web pages, PHP is used mainly in server-side application software.

Task: Install PHP

If you are using Fedora Core or Cent Os Linux, type the following command:
# yum install php

If you are using Debian Linux, type the following command:
# apt-get install php5

Now restart Web Server:
# /etc/init.d/httpd restart

Task: Test php

Go to /var/www/html/ directory:
# cd /var/www/html/

Create a php file – phptest.php
# vi phptest.php

Append following lines:
<?php phpinfo(); ?>

Save and close the file.

Open a web browser and type the url : http://yourdomain.com/phptest.php or http://localhost/phptest.php or http://server-ip-address/phptest.php.

See sample output here

Featured Articles:

Share this with other sys admins!
Facebook it - Tweet it - Print it -

{ 4 comments… read them below or add one }

1 alaa ali August 22, 2009

when i try to test my php a window appears: you have chosen to open test.php which is a php scripts.. what is this means? and how to solve this problem.. thanks in advance

Reply

2 DEA September 2, 2009

Works great on Cent OS 5, Thanks!

Reply

3 mpande January 11, 2011

To complete shutdown and exit just enter the command
init 0
Though remember to be root.
i.e
#init 0

Reply

4 Andrew August 6, 2011

eroer 403, forbidden

Reply

Leave a Comment

You can use these HTML tags and attributes for your code and commands: <strong> <em> <ol> <li> <u> <ul> <blockquote> <pre> <a href="" title="">
What is 2 + 10 ?
Please leave these two fields as-is:
Solve the simple math so we know that you are a human and not a bot.



Previous post:

Next post: