Home Computer Tutorials Computer Knowledge How to quickly set up a LAMP environment on Debian 12

How to quickly set up a LAMP environment on Debian 12

Feb 20, 2024 pm 12:39 PM
server debian Linux operating system lamp

LAMP refers to the abbreviation consisting of the first letters of the names of four open source components, often used to support web programs developed using PHP. When purchasing a VPS server, whether it is Alibaba Cloud ECS or VULTR VPS server, if you plan to install a Debian system and configure a LAMP environment, this article will provide you with some help.

Let’s introduce the specific meaning of LAMP in detail:

  • L – Linux operating system
  • A – Apache is the world’s most popular HTTP web server
  • M – MySQL or MariaDB relational database management system
  • P – PHP Programming Language

before the start

Before starting this tutorial, you may need a server with Debian 12 installed:

  • At least 1GB of RAM
  • Non-root users with sudo permissions (of course root users can also be used, but security considerations are not recommended)

Students who do not have a server can buy it here in China, and VPS servers abroad can buy it here.

Step 1. Install Apache

Apache is available in the default Debian 12 repositories. Installation is very simple, run the following command:

sudo apt update

sudo apt install apache2

After the installation is completed, the apache2 service runs automatically by default and can be viewed through the following command:

sudo systemctl status apache2

After the command is executed, you will see something similar to the following:

如何快速在 Debian 12 上搭建 LAMP 环境

Browser inputhttp://localhost displays the apache information page by default.

如何快速在 Debian 12 上搭建 LAMP 环境

Apache service start and stop commands:

sudo systemctl start apache2 //Start

sudo systemctl stop apache2 //Stop

Please refer to "How to install Apache on Debian 12".

Step 2. Install MariaDB / MySQL

The Debian 12 software source does not include the MySQL software package, which has been replaced by MariaDB. MariaDB is fully compatible with MySQL.

If you want to install MySql, you can check "How to install MySQL on Debian 12"

The following commands take the installation of MariaDB as an example:

sudo apt update

sudo apt install mariadb-server

After the installation is completed, the MariaDB service will automatically start and can be viewed through the following command.

sudo systemctl status mariadb

If it runs normally, you will see output similar to the following:

如何快速在 Debian 12 上搭建 LAMP 环境

Execute the following command to strengthen MariaDB database security according to the prompts.

sudo mysql_secure_installation

After the

command is executed, you will get a prompt in the terminal. Basically, you can enter y all the way.

For improved security, it is recommended to keep the default authentication plugin and allow the root user to authenticate only through Unix sockets.

If you want to change root authentication to classic authentication, you can do the following on the server:

sudo mysql

Then execute the following SQL.

ALTER USER ‘root’@’localhost’ IDENTIFIED VIA mysql_native_password;

ALTER USER ‘root’@’localhost’ IDENTIFIED BY ‘your_root_passwd’;

Hereyour_root_passwd is the root account password you set. After the above settings are completed, you can log in in the terminal through the following command.

mysql -u root -p

For more information, please refer to "How to install MariaDB on Debian 12"

Step 3. Install and configure PHP

The default installed php in Debian 12 environment is 8.2.

sudo apt update

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

Note: By default, php is installed with the latest version php8.2 in the Debian 12 software repository. If you need to install a specific version of PHP, you can do the following:

sudo apt install php[version]

For example, if you install version 7.3 of php, the command is as follows:

sudo apt install php7.3

Of course, the corresponding module also needs to specify the version, such as php7.3-mysql. Generally, the following modules are commonly used:

php7.3-cli

php7.3-common

php7.3-curl

php7.3-gd

php7.3-json

php7.3-mbstring

php7.3-mysql

php7.3-xml

php7.3-fpm

For more information, please refer to "How to install PHP on Debian 12"

Step 4. Visit LAMP

After the above three steps, we have installed Apache, MariaDB/MySQL, and PHP. Now we can add site content to access static files or php files.

First, enter the apache default site directory through the cd command.

cd /var/www/html

Secondly, create the info.php file through the touch command and edit the file using vi/vim.

sudo touch info.php

sudo vi info.php

Press the i key to enter editing mode and enter the following content

Press Esc, enter :wq, press Enter to save the file and return.

Finally, enter http://localhost/info.php in your local browser, you will see the following content:

如何快速在 Debian 12 上搭建 LAMP 环境

Write at the end

This tutorial has shown you how to set up a LAMP environment on Debian 12. If possible, I recommend you try it on your own Debian server.

The above is the detailed content of How to quickly set up a LAMP environment on Debian 12. For more information, please follow other related articles on the PHP Chinese website!

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

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

Video Face Swap

Video Face Swap

Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Tools

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

Complete guide to uninstalling Kali Linux software to solve system stability problems Complete guide to uninstalling Kali Linux software to solve system stability problems Mar 23, 2024 am 10:50 AM

This study provides a comprehensive and in-depth analysis of software uninstallation problems that may arise during the penetration testing and security audit process of KaliLinux, and contributes solutions to ensure system stability and reliability. 1. Understand the installation method of the software. Before uninstalling the software from kalilinux, it is a crucial step to first determine its installation path. Then, the appropriate offloading solution is selected accordingly based on the selected path. Common installation methods include apt-get, dpkg, source code compilation and other forms. Each strategy has its own characteristics and corresponding offloading measures. 2. Use the apt-get command to uninstall software. In the KaliLinux system, the apt-get functional component is widely used to execute software packages efficiently and conveniently.

How to install Snap on Debian 12 How to install Snap on Debian 12 Mar 20, 2024 pm 08:51 PM

Snap is an external package manager designed for Linux systems that provides you with a convenient way to install containerized applications. Snap allows you to easily download and install packages without worrying about installing additional dependencies. The manager automatically resolves the dependencies required by the package, ensuring that the package runs smoothly on your system. Snap complements the native apt package manager, giving you another option for installing and running applications on your system. In this guide, you will find a complete guide on how to install Snap on Debian12. Outline: How to install Snap on Debian12 How to find package availability on Snap How to find information about packages on Snap

How to install Steam on Debian 12 How to install Steam on Debian 12 Mar 21, 2024 pm 10:10 PM

STEAM is a popular gaming platform developed by Valve Corporation that allows you to buy, download, install and play games. It provides features such as automatic updates, matchmaking, and a community forum to resolve software-related issues. In addition to this, you can also use Steam to interact with other players and developers as it has extensive community support. In this guide you will learn: How to install Steam on Debian12 How to run Steam on Debian12 How to remove Steam from Debian12 Conclusion How to install Steam on Debian12 You can install Steam on Debian12: Debian Official Repository deb packages

A complete guide to installing the domestic operating system Kirin Linux, completed in 15 minutes A complete guide to installing the domestic operating system Kirin Linux, completed in 15 minutes Mar 21, 2024 pm 02:36 PM

Recently, the domestic operating system Kirin Linux has attracted much attention. As a senior computer engineer, I have a strong interest in technological innovation, so I have personally experienced the installation process of this system, and now I will share my experience with you. Before executing the installation procedure, I was fully prepared for the relevant steps. The first task is to download and copy the latest Kirin Linux operating system image to a USB flash drive; secondly, for 64-bit Linux, ensure that important data in personal devices have been backed up to deal with potential installation problems; finally, shut down the computer and insert the USB flash drive. After entering the installation interface and restarting the computer, press the F12 function key promptly, enter the system boot menu and select the USB priority boot option. With a beautiful and simple startup screen appearing in front of you

How to configure Dnsmasq as a DHCP relay server How to configure Dnsmasq as a DHCP relay server Mar 21, 2024 am 08:50 AM

The role of a DHCP relay is to forward received DHCP packets to another DHCP server on the network, even if the two servers are on different subnets. By using a DHCP relay, you can deploy a centralized DHCP server in the network center and use it to dynamically assign IP addresses to all network subnets/VLANs. Dnsmasq is a commonly used DNS and DHCP protocol server that can be configured as a DHCP relay server to help manage dynamic host configurations in the network. In this article, we will show you how to configure dnsmasq as a DHCP relay server. Content Topics: Network Topology Configuring Static IP Addresses on a DHCP Relay D on a Centralized DHCP Server

How to solve the problem of garbled characters displayed on the Linux command line How to solve the problem of garbled characters displayed on the Linux command line Mar 21, 2024 am 08:30 AM

Methods to solve the problem of garbled characters displayed on the Linux command line. In the Linux operating system, sometimes we will encounter garbled characters displayed when using the command line interface, which will affect our normal viewing and understanding of the command output results or file contents. The causes of garbled characters may be due to incorrect system character set settings, terminal software not supporting the display of specific character sets, inconsistent file encoding formats, etc. This article will introduce some methods to solve the problem of garbled characters displayed on the Linux command line, and provide specific code examples to help readers solve similar problems.

How to Install Java on Debian 12: A Step-by-Step Guide How to Install Java on Debian 12: A Step-by-Step Guide Mar 20, 2024 pm 03:40 PM

Java is a powerful programming language that enables users to create a wide range of applications, such as building games, creating web applications, and designing embedded systems. Debian12 is a powerful newly released Linux-based operating system that provides a stable and reliable foundation for Java applications to flourish. Together with Java and Debian systems you can open up a world of possibilities and innovations that can definitely help people a lot. This is only possible if Java is installed on your Debian system. In this guide, you will learn: How to install Java on Debian12 How to install Java on Debian12 How to remove Java from Debian12

Linux System Administrator Reveals: A Complete Guide to Analysis of Red Hat Linux Versions Linux System Administrator Reveals: A Complete Guide to Analysis of Red Hat Linux Versions Mar 29, 2024 am 09:16 AM

As a senior Linux system administrator, I already have a deep knowledge base and unique perspective on the analysis, diagnosis and treatment of RedHat version of Linux systems. This article will provide an in-depth analysis of all aspects of the RedHat version of the Linux system, including identifying its version characteristics, decoding the version number, and the actual steps for transmitting test version updates, etc., in order to help you fully grasp and efficiently utilize the features of the RedHat operating system. 1. Understand RedHat One of the Internet companies with the highest market value in the United States, RedHat has won a leading position in the global software market through its operating system products developed under the framework of open source technology. Its Linux distribution RedHat EnterpriseLinux (referred to as

See all articles