Debian 12에서 LEMP를 설치하고 구성하는 방법

이 튜토리얼에서는 Debian 12에서 LEMP를 설치하고 구성하기 위해 따라야 하는 단계를 보여줍니다. Nginx, MariaDB 및 PHP는 데모 웹사이트, 블로그 또는 온라인 상점 등 고성능 웹 호스팅에 필요한 소프트웨어 패키지입니다.

LEMP는 다음의 약어입니다. Linux, Nginx, MySQL/MariaDB, PHP 등이 있으며 전 세계 많은 웹 프로젝트와 웹 애플리케이션의 기반이 됩니다. 그렇지 않으면 뒤쳐지면 이 글을 볼 수 없을 것입니다. stealthsettings.com에는 당사 웹사이트의 온라인 운영을 보장하기 위한 모든 패키지가 없을 것입니다.

데비안(Debian)은 다음을 기반으로 하는 오픈 소스 운영 체제입니다. Linux, 안정성, 보안 및 유연성으로 유명합니다. 오랜 역사와 활발한 개발자 커뮤니티를 통해 데비안은 사용자의 다양한 요구를 충족시키기 위해 광범위한 소프트웨어 패키지와 라이브러리를 제공합니다. 이 운영 체제는 회사를 위한 안정적이고 효율적인 서버를 만드는 데 자주 사용되지만 개인용으로도 조정할 수 있습니다.

Debian 12에서 LEMP를 설치하고 구성하는 방법

Debian 12에 LEMP를 설치하고 구성하기 전 첫 번째 단계는 SSH를 통해(또는 로컬 액세스 권한이 있는 경우 콘솔에서 직접) 서버에 연결하는 것입니다. LEMP 또는 cPanel과 같은 관리 시스템에서 서버에 이미 설치된 패키지가 없는지 확인하십시오. VestaCP 또는 다른 사람.

이 튜토리얼의 명령 세트는 "로 시작합니다.sudo", 하지만 사용자 "로 서버에 연결되어 있는 경우root", 그럴 필요는 없어"sudo” 명령줄 앞에. 주문하다 "sudo"는 명령줄 앞에 사용되어 일반 사용자에게 임시로 슈퍼유저 권한을 부여하여 소프트웨어 설치 또는 구성, 시스템 관리 또는 기타 민감한 작업 수행과 같이 특별한 권한이 필요하거나 보호된 리소스에 대한 액세스가 필요한 명령을 실행할 수 있도록 합니다.

Update 소프트웨어.

LAMP 설치를 시작하기 전에 운영 체제와 이미 설치된 소프트웨어 패키지를 모두 업데이트하는 것이 좋습니다.

sudo apt update
sudo apt upgrade

사용 가능한 패키지가 있는 경우 update, 누르다 "Y"라는 질문을 받았을 때:

Do you want to continue? [Y/n] Y

Debian 12에서 Nginx 웹 서버 설치 및 구성

웹서버가 방문자에게 웹페이지를 제공하기 위해서는, Nginx Web Server 올바르게 설치 및 구성되어야 합니다.

sudo apt install nginx

유형 "Y”을 클릭하여 Nginx 웹 서버 설치를 확인합니다.

Do you want to continue? [Y/n] Y
Install Debian 12의 Nginx 웹 서버
Install Debian 12의 Nginx 웹 서버

설치 프로세스가 끝나면 다음 줄이 표시됩니다.

Setting up nginx-common (1.22.1-9) ...
Created symlink /etc/systemd/system/multi-user.target.wants/nginx.service → /lib/systemd/system/nginx.service.
Setting up nginx (1.22.1-9) ...
Upgrading binary: nginx.
Processing triggers for man-db (2.11.2-2) ...

마지막으로 모든 것이 제대로 작동하는지 확인하려면 다음 주소로 이동하세요. IP 웹 브라우저에서. http://your_server_ip.

NGINX 페이지에 오신 것을 환영합니다
NGINX 페이지에 오신 것을 환영합니다

Nginx 서비스가 서버에서 실행 중이며 웹 페이지를 제공할 준비가 되었습니다.

관련 :

Debian 12에서 MariaDB 서버 설치 및 구성

MariaDB는 MySQL에 비해 향상된 성능, 더 빠른 복제 속도, 향상된 보안 조치 및 추가 스토리지 엔진을 제공합니다.

아래 명령줄을 실행하고 “Y" 설치를 확인하려면 MariaDB Server.

sudo apt install mariadb-server

설치 후 다음 스크립트를 실행하여 MariaDB 서버를 보호해야 합니다. mysql_secure_installation. 서버에 대한 액세스를 제한하고 사용하지 않는 계정을 제거합니다.

명령줄을 실행합니다.

sudo mysql_secure_installation

누르다 "Enter" 현재 사용자 비밀번호 "root".

Debian 12에서 LEMP를 설치하고 구성하는 방법
보안 SQL #1
Switch to unix_socket authentication [Y/n] Y

비밀번호 설정 MariaDB:

Change the root password? [Y/n] Y     
New password: 
Re-enter new password: 
Password updated successfully!
Reloading privilege tables..
 ... Success!

다음으로 저장한 권한과 데이터베이스를 삭제합니다. default 설치 중 MariaDB Server.

Remove anonymous users? [Y/n] Y
 ... Success!

Normally, root should only be allowed to connect from 'localhost'.  This
ensures that someone cannot guess at the root password from the network.

Disallow root login remotely? [Y/n] Y
 ... Success!

By default, MariaDB comes with a database named 'test' that anyone can
access.  This is also intended only for testing, and should be removed
before moving into a production environment.

Remove test database and access to it? [Y/n] Y
 - Dropping test database...
 ... Success!
 - Removing privileges on test database...
 ... Success!

Reloading the privilege tables will ensure that all changes made so far
will take effect immediately.

Reload privilege tables now? [Y/n] Y
 ... Success!

Cleaning up...

All done!  If you've completed all of the above steps, your MariaDB
installation should now be secure.

Thanks for using MariaDB!

“계정에 대해 위에서 설정한 비밀번호입니다.root”는 원격 서버에 로그인할 때 필요합니다. 원격. 비밀번호는 다음과 같습니다 MariaDB.

SQL Server 설치를 테스트하십시오.

root@mars:~# mysql
Welcome to the MariaDB monitor.  Commands end with ; or \g.
Your MariaDB connection id is 41
Server version: 10.11.3-MariaDB-1 Debian 12

Copyright (c) 2000, 2018, Oracle, MariaDB Corporation Ab and others.

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

MariaDB [(none)]> select version();
+-------------------+
| version()         |
+-------------------+
| 10.11.3-MariaDB-1 |
+-------------------+
1 row in set (0.000 sec)

MariaDB [(none)]> quit
Bye
root@mars:~# 

Debian 12에서 PHP/PHP-FPM 설치 및 구성

이 단계까지 모든 것이 잘 작동했다면 Debian 12에서 LEMP를 설치하고 구성하려면 PHP 소프트웨어도 필요합니다. Nginx에서 PHP를 지원하려면 PHP-FPM도 설치해야 합니다.

sudo apt install php-fpm php-mysql php-gd php-cli php-curl php-mbstring php-zip php-opcache php-xml

설치 프로세스가 완료될 때까지 기다립니다. PHP-FPM, 가장 중요한 PHP 모듈과 함께.

결국 튜토리얼에서 설치할 수있었습니다. PHP 8.2 데비안 12 운영 체제에서.

root@mars:~# php -v
PHP 8.2.7 (cli) (built: Jun  9 2023 19:37:27) (NTS)
Copyright (c) The PHP Group
Zend Engine v4.2.7, Copyright (c) Zend Technologies
    with Zend OPcache v8.2.7, Copyright (c), by Zend Technologies
root@mars:~# 

이 시점에서 LEMP의 모든 요소가 설치되었지만 아직 수행해야 할 구성이 남아 있습니다. Nginx PHP 파일을 실행합니다.

PHP 파일을 실행하도록 NGINX 구성

페이지에 대해 Nginx를 구성하려면 “default", 편집하다 "/etc/nginx/sites-enabled/default". 나는 선호한다 "nano" 편집을 위해.

"로 대체location /"라인 :

location / {
    # First attempt to serve request as file, then
    # as directory, then fall back to displaying a 404.
    try_files $uri $uri/ =404;
     }

라인:

location / {
    try_files $uri $uri/ /index.php?$args;
    }

다음으로, “ 블록에 아래 줄을 추가하세요.server” Nginx가 PHP를 처리할 수 있도록 합니다.

location ~ \.php$ {
     include snippets/fastcgi-php.conf;
     fastcgi_pass unix:/var/run/php/php-fpm.sock;
     }
}
Debian 12에서 LEMP를 설치하고 구성하는 방법
Debian 12에서 LEMP를 설치하고 구성하는 방법

파일을 저장하고 구성을 확인합니다.

root@mars:~# nginx -t
nginx: the configuration file /etc/nginx/nginx.conf syntax is ok
nginx: configuration file /etc/nginx/nginx.conf test is successful
root@mars:~# 

구성 테스트에 성공하면 서비스를 다시 시작합니다. nginx.

sudo systemctl restart nginx

Debian 12에서 LEMP를 성공적으로 설치하고 구성했는지 테스트하세요.

Debian 12(LEMP)에 Nginx, MariaDB 및 PHP를 설치하고 구성한 후에는 모든 것이 작동하는지 테스트할 차례입니다. 테스트하려면 info.php 파일을 만드는 것이 가장 쉽습니다.

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

브라우저에서 액세스 "https://your_server_ip/info.php".

PHP 버전 정보
PHP 버전 정보

PHP 페이지는 Debian 12용 LEMP가 성공적으로 설치되었음을 의미합니다.

축하합니다!

기술에 대한 열정, 나는 기쁨으로 글을 씁니다. StealthSettings2006년부터 .com을 운영하고 있습니다. 저는 운영 체제 분야에서 폭넓은 경험을 갖고 있습니다. macOS, Windows 과 Linux, 프로그래밍 언어 및 블로그 플랫폼(WordPress) 및 온라인 상점의 경우(WooCommerce, 마젠토, 프레스타샵).

방법 » Web Hosting » Debian 12에서 LEMP를 설치하고 구성하는 방법
코멘트 남김