PHP is a popular programming language that is widely used to develop various website applications. Many well-known websites and open source programs are developed using PHP, such as WordPress, Magento, and Laravel.
This tutorial will introduce how to install PHP in Debian 12 and the integration of PHP and Apache.
You need to have a server with Debian 12 installed to facilitate the drill operation on it. Of course, it is also recommended that you purchase an Alibaba Cloud VPS or Tencent Cloud VPS virtual host. If you prefer foreign servers, I recommend you try VPS on Vultr. You will get a $50 experience when you sign up, which is very cost-effective.
Of course there is a host. For security reasons, it is not recommended to use the root account. It is recommended to create a user with sudo permissions.
To install PHP and Apache PHP modules, please run the following command:
sudo apt update sudo apt install php libapache2-mod-php
The default installed php is 8.2.
After the installation is complete, restart Apache to load the PHP module. The command is as follows:
sudo systemctl restart apache2
Core PHP functionality can be enhanced by installing different extensions. PHP extensions are usually provided as software packages and can be quickly installed by simply entering the corresponding command.
sudo apt install php-[extname]
For example, to install PHP common extensions, you would run the following command:
sudo apt install php-opcache php-cli php-gd php-curl php-mysql
If you use Nginx as a web service, remember to install the php-fpm module.
sudo apt install php-fpm
Because php is 8.2, php8.2-fpm is installed by default. You can use the following command to check the running status of php-fpm after installation
sudo systemctl status php8.2-fpm
To test that your web server is properly configured for PHP processing, use the following code to create a file named info.php
in the /var/www/html
directory New file for:
The above is the detailed content of How to install PHP and integrate with Apache on Debian 12. For more information, please follow other related articles on the PHP Chinese website!