How to install and configure a PHP development environment in Ubuntu?

To install and configure a PHP development environment on Ubuntu, you can follow the steps below:

  1. Install PHP:
    Open the terminal and run the following command to install PHP:
sudo apt update
sudo apt install php
  1. Install PHP extensions:
    You may also need to install some PHP extensions to meet your development needs. For example, if you need to use a MySQL database, you can install PHP’s MySQL extension.
sudo apt install php-mysql
  1. Installing Apache Server:
    Typically, a web server is needed for running PHP scripts in a PHP development environment. You can install Apache server to work in conjunction with PHP.
sudo apt install apache2
  1. The configuration file for the default website in Apache can be found under /etc/apache2/sites-available/000-default.conf.
sudo nano /etc/apache2/sites-available/000-default.conf

In the configuration file, you can specify your website’s root directory and other settings.

  1. – The local host address is http://localhost/
  2. the listed address is http://127.0.0.1/
  3. – PHP index file
<?php
phpinfo();
?>

Save and close the file, then enter http://localhost/index.php in the browser. You should see a PHP information page, indicating that PHP has been successfully installed and configured.

By following the above steps, you can install and configure a PHP development environment in Ubuntu.

Leave a Reply 0

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


广告
Closing in 10 seconds
bannerAds