Current Location: Home> Latest Articles> How to Install PHP on Debian 8 - Complete Guide

How to Install PHP on Debian 8 - Complete Guide

gitbox 2025-06-30

In this article, we will show you how to install PHP on Debian 8. PHP is a widely used server-side scripting language, commonly used for web development. Whether you are a beginner or an experienced developer, these steps will guide you through the process of installing PHP with ease.

Preparation

Before starting the installation, make sure your Debian 8 system is updated to the latest version. You can update your system using the following commands:

sudo apt-get update
sudo apt-get upgrade

Install PHP and Extensions

Next, use the APT package manager to install PHP and commonly used extensions. Run the following command:

sudo apt-get install php libapache2-mod-php php-mysql

This command will install PHP's core package, the Apache module, and the MySQL extension.

Verify PHP Installation

After installation, you can verify whether PHP was correctly installed by running the following command:

php -v

If the command returns the PHP version information, it means PHP has been successfully installed.

Configure Apache to Support PHP

To ensure Apache can parse PHP files, we need to restart the Apache server. Use the following command to do so:

sudo systemctl restart apache2

Create a Test PHP File

To test if your PHP configuration is working correctly, you can create a simple PHP file. Create a file named info.php in the root directory of Apache and add the following content:

<?php
phpinfo();
?>

You can create this file using the following command:

echo "<?php
phpinfo();
?>" | sudo tee /var/www/html/info.php

Then, you can visit http://your-server-ip/info.php in your browser to view the PHP configuration information.

Conclusion

With this tutorial, you have successfully learned how to install and configure PHP on Debian 8. By following these simple steps, you can set up a complete PHP environment for your web projects. We hope you complete the installation smoothly and start developing your applications based on this setup.

If you encounter any issues during the installation, you can refer to the official documentation or seek help from the developer community. Happy coding!