Install PHP

Installing PHP on Ubuntu is not a complicated task. If you read the previous how-to, you will see that the php installation process is very similar to installing Apache or MySQL . Let’s get to work:

First login your Server, start Terminal and become root user using “sudo su”. Next type the following commands (we will also upgrade all installed packages to keep the server up to date):

apt-get -y update
apt-get -y upgrade
apt-get -y install php libapache2-mod-php

That’s it! PHP is now installed on your server.

Testing the installation

In order to test the installation, we will create a very small php script that will display all the information about the PHP packages installed on your server. For this, go to the /var/www/html server using the command:

cd /var/www/html

Using nano create a file named info.php

nano info.php

Paste the following in your file:

<?php
    phpinfo();
?> 

Save your file using <CTRL>-O. Finally go to your browser and enter the address http://xxx.xxx.xxx.xxx/info.php where xxx.xxx.xxx.xxx is the IP of your server. If you are using the browser on the server itself you can use the address http://127.0.0.1/info.php .

You should get a page looking like this:

If you get a different page, please leave a comment and I will do my best to help you or use our forum to post your question.

Further reading

PHP for Absolute Beginners
PHP: Learn PHP In 2 Hours
PHP FOR BEGINNERS: Your Guide to Easily Learn PHP In 1 Days Step by Step

1.00$5.00$10.00$25.00$50.00$
999999.99$

Posted in How to, PHP.

Leave a Reply

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