Write and Deploy Hello World in PHP

Install Prerequisites

yum update -y
yum install httpd php php-cli php-devel -y


Start Apache and make sure that it starts again on boot

chkconfig --level 235 httpd on
service httpd start


Open Port 80 on IPTables

iptables -I INPUT -p tcp --dport 80 -j ACCEPT
service iptables save

Hello World

Create PHP hello world file in our Apache web directory, so that it can be read by Apache and displayed as a webpage. (Replace "vim" with "nano", if you're not familiar with vim)

vim /var/www/html/helloworld.php

Insert the following text

echo 'Hello, World!';


Give it file permissions so that it can be read by Apache

chmod 755 /var/www/html/helloworld.php


Navigate to the server’s IP address using your browser.  You should now be able to see a web page showing "Hello World!!"


Was this article helpful?

mood_bad Dislike 0
mood Like 0
visibility Views: 2057