This blog post describes how I install PHP to Apache HTTP Server and test the installation on my Ubuntu installation.
- Verifying PHP5 Modules in Apache2 HTTP Folder
- Testing installation
The quick and simple way is to use Ubuntu Software Center (search term: php5).
This will install the latest version of PHP5 available in the Ubuntu Software Center.
Verifying PHP5 Modules in Apache2 HTTP Folder
After the installation is complete, you should see Apache HTTP modules for PHP in the mods-enabled folder.
By default (if you installed Apache HTTP server via Ubuntu Software Center), the installation folder is located at:
In the installation folder, there should be a folder labeled mods-enabled.
In this folder, you should see a php5.conf (that holds your configuration settings for PHP5) and php5.load (the actual Apache2 module for PHP5) file.
After you confirmed that PHP module is enabled in PHP, you can test your installation.
To do so, create a test.php file in Apache’s document root folder.
By default, the document root folder is located in /var/www/html.
However, the owner and group access for this folder belongs to the root user.
This means you need to access the /var/www/html folder as a superuser in order to make changes to the folder.
One way would be start a terminal session and enter the following commands:
gksudo caja /var/www/html &
If you are not using Mate desktop, replace “caja” with “nautilus” as in:
gksudo nautilus /var/www/html &
This command can be explained as follows:
gksudo – run command as superuser. This is similar to the sudo command. But because we are running the command in the background (see & below), the prompt to allow us to enter administrator’s credentials will be in the background as well. By using gksudo, we will get a prompt like the below, that allows us to enter administrator’s password.
caja (or nautilus) – command to activate your file manager
/var/www/html – parameter used by file manager. File manager use this parameter and open this folder when it start.
& – The ampersand indicates that this command is to run in the background. If this is missing, the terminal session will be dedicated to run the file manager until the file manager application terminated.
After you run the command, you should see:
In this folder, create a file call test.php with the following contents:
<title>PHP Test Page</title>
<h2>A PHP test page</h2>
<?php echo “hello world”; ?>
Now, your /var/www/html folder should look something like this:
Go to your browser and navigate to:
You should see a result like the below: