Home > Computer Tutorials > Computer Knowledge > How to install PHP and integrate with Apache on Debian 12

How to install PHP and integrate with Apache on Debian 12

王林
Release: 2024-02-20 14:30:40
forward
961 people have browsed it

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.

Prerequisite

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.

Install PHP and integrate Apache

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

Install PHP extension module

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

如何在 Debian 12 安装 PHP 及 和 Apache 集成

Test PHP processing

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!

Related labels:
source:mryunwei.com
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template