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
- 30 Handy Bash Shell Aliases For Linux / Unix / Mac OS X
- Top 30 Nmap Command Examples For Sys/Network Admins
- 25 PHP Security Best Practices For Sys Admins
- 20 Linux System Monitoring Tools Every SysAdmin Should Know
- 20 Linux Server Hardening Security Tips
- Linux: 20 Iptables Examples For New SysAdmins
- Top 20 OpenSSH Server Best Security Practices
- Top 20 Nginx WebServer Best Security Practices
- 20 Examples: Make Sure Unix / Linux Configuration Files Are Free From Syntax Errors
- 15 Greatest Open Source Terminal Applications Of 2012

- My 10 UNIX Command Line Mistakes
- Top 10 Open Source Web-Based Project Management Software
- Top 5 Email Client For Linux, Mac OS X, and Windows Users
- The Novice Guide To Buying A Linux Laptop











{ 6 comments… read them below or add one }
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
Works great on Cent OS 5, Thanks!
To complete shutdown and exit just enter the command
init 0
Though remember to be root.
i.e
#init 0
eroer 403, forbidden
I can’t do step 2. Restart the web service.
There is no httpd in /etc/init.d/
What is the wrong. I’m using Ubuntu 11.10 with fvwm-crystal
httpd does not exits.
that is because you need to install Apache web server.
after that you may find the file exists in /etc/apache/init.d/httpd