Installing PHP on Ubuntu is as straightforward as installing other web technologies. If you want to serve different pages under different circumstances, PHP is one of the best ways to do that. There are a lot of benefits to PHP, but here we will see how to install it on Ubuntu so that Apache uses it to generate web pages. After installing it, you would do well to learn how to configure PHP, as well.
To install PHP on Ubuntu, one can use Synaptic or Adept, the package manager for Kubuntu. These are just graphic front-ends for the underlying Ubuntu package manager. Simply search for "php5", select it, and click apply. Synaptic or Adept may ask you to confirm the installation of package dependencies. You can confirm their installation, and Ubuntu will take care of the rest.
This will give you a basic PHP installation. As you can tell from the number of results that are returned, there are a myriad of PHP functions - over 700 in all. And if you want to do anything beyond rendering HTML (for example, connecting with and querying a MySQL database), you will want to ensure the appropriate modules are available for PHP. But as it stands, using this method, you can get started with PHP and Apache on Ubuntu.
If you would rather not use the graphic program for the installation, you can use either Apt-Get or Aptitude to affect the installation. Both use the same basic syntax, but Aptitude tends to sort out program dependencies better. Invoke Apt-Get in the following way:
sudo apt-get install php5or use Aptitude as follows:
sudo apt-get install php5Again, you will be queried about dependencies. Simply confirm their installation, and Ubuntu will sort things out. Installing PHP on Ubuntu is that simple. But there is more to do if you want to do more sophisticated PHP programming. Depending on your needs, you may need to change PHP's default configuration or install more modules from the PHP library.
PHP Tutorials:
Apache Tutorials:
Install Apache | Basic Configuration | Apache In-Depth |
Recommend Web Hosting | Customising Apache | PHP Hosting |
Install MySQL | Basic MySQL Configuration | MySQL Configuration In-Depth |