서버 설치 · 5 min read · Sep 26, 2025

우분투 22.04에 LAMP 서버 스택 설치하는 방법

LAMP는 무료이며 오픈 소스이며 웹 개발자가 웹사이트와 애플리케이션을 온라인으로 구축, 배포 및 관리할 수 있도록 하는 가장 인기 있는 웹 개발 플랫폼 중 하나입니다. LAMP는 운영 체제로서의 Linux, 웹 서버로서의 Apache, 관계형 데이터베이스 관리 시스템으로서의 MySQL, 객체 지향 스크립팅 언어로서의 PHP/Perl/Python의 네 가지 오픈 소스 구성 요소를 사용합니다. LAMP 스택은 Joomla, Drupal 및 WordPress와 같은 다양한 웹사이트 프레임워크를 호스팅하는 데 충분하기 때문에 모든 웹 개발자의 주요 선택입니다.

특징

  • LAMP 서버는 무료이며 오픈 소스이므로 누구나 소스를 다운로드하고 변경 및 개선하여 전체 성능을 향상시킬 수 있습니다.
  • 사용자 정의가 가능합니다. 따라서 특정 애플리케이션의 요구에 맞게 모든 구성 요소를 다른 오픈 소스 솔루션으로 교체할 수 있습니다.
  • 더 큰 커뮤니티가 있어 지원을 쉽게 찾을 수 있습니다.
  • 설정이 쉬운 성숙한 스택입니다.

이 게시물에서는 우분투 22.04에 LAMP 서버를 설치하는 방법을 보여줍니다.

전제 조건

  • 우분투 22.04가 실행되는 서버.
  • 최소 1GB의 RAM과 5GB의 하드 디스크 공간.
  • 서버에 루트 비밀번호가 설정되어 있습니다.

우분투 22.04에 Apache 설치하기

Apache 웹 서버는 LAMP 스택의 주요 구성 요소입니다. 기본적으로 Apache 웹 서버 패키지는 우분투 22.04 기본 저장소에 포함되어 있습니다. 다음 명령어를 실행하여 쉽게 설치할 수 있습니다:

apt-get install apache2 -y

Apache 서버가 설치되면 다음 명령어를 사용하여 Apache 웹 서비스를 시작하고 활성화합니다:

systemctl start apache2  
systemctl enable apache2

이제 다음 명령어를 사용하여 Apache 서비스의 상태를 확인할 수 있습니다:

systemctl status apache2

다음 출력에서 Apache 상태를 확인할 수 있습니다:

? apache2.service - The Apache HTTP Server
     Loaded: loaded (/lib/systemd/system/apache2.service; enabled; vendor preset: enabled)
     Active: active (running) since Fri 2022-04-29 07:27:44 UTC; 4s ago
       Docs: https://httpd.apache.org/docs/2.4/
   Main PID: 923 (apache2)
      Tasks: 55 (limit: 4630)
     Memory: 5.1M
        CPU: 56ms
     CGroup: /system.slice/apache2.service
             ??923 /usr/sbin/apache2 -k start
             ??924 /usr/sbin/apache2 -k start
             ??925 /usr/sbin/apache2 -k start

Apr 29 07:27:44 ubuntu systemd[1]: Starting The Apache HTTP Server...

Apache 버전을 확인하려면 다음 명령어를 실행합니다:

apache2ctl -version

다음 출력에서 Apache 버전을 확인할 수 있습니다:

Server version: Apache/2.4.52 (Ubuntu)
Server built:   2022-03-25T00:35:40

웹 브라우저를 통해 URL http://your-server-ip를 사용하여 Apache 설치를 테스트할 수도 있습니다. 다음 화면에서 Apache 테스트 페이지를 볼 수 있어야 합니다:

작업이 끝나면 PHP 설치로 진행할 수 있습니다.

우분투 22.04에 PHP 설치하기

PHP는 PHP 페이지를 제공하는 데 사용되는 처리 언어입니다. 기본적으로 우분투 22.04는 최신 PHP 버전 8.1을 제공합니다. 다음 출력에서 다른 확장과 함께 설치할 수 있습니다:

apt-get install php8.1 libapache2-mod-php8.1 php8.1-mysql php8.1-gd php8.1-curl php8.1-xml -y

PHP가 설치되면 다음 명령어를 사용하여 PHP 버전을 확인할 수 있습니다:

php --version

다음 출력에서 PHP 버전을 확인할 수 있습니다:

PHP 8.1.2 (cli) (built: Apr  7 2022 17:46:26) (NTS)
Copyright (c) The PHP Group
Zend Engine v4.1.2, Copyright (c) Zend Technologies
    with Zend OPcache v8.1.2, Copyright (c), by Zend Technologies

작업이 끝나면 MySQL 서버 설치로 진행할 수 있습니다.

우분투 22.04에 MySQL 서버 설치하기

기본적으로 최신 버전의 MySQL은 우분투 22.04 기본 저장소에 포함되어 있습니다. 다음 명령어를 사용하여 설치할 수 있습니다:

apt-get install mysql-server -y

MySQL 서버가 설치되면 다음 명령어를 사용하여 MySQL 서비스를 시작하고 시스템 재부팅 시 자동으로 시작되도록 활성화합니다:

systemctl start mysql  
systemctl enable mysql

다음 명령어를 사용하여 MySQL의 상태를 확인할 수 있습니다:

systemctl status mysql

다음 출력을 받을 수 있습니다:

? mysql.service - MySQL Community Server
     Loaded: loaded (/lib/systemd/system/mysql.service; enabled; vendor preset: enabled)
     Active: active (running) since Fri 2022-04-29 07:43:21 UTC; 3s ago
    Process: 11468 ExecStartPre=/usr/share/mysql/mysql-systemd-start pre (code=exited, status=0/SUCCESS)
   Main PID: 11476 (mysqld)
     Status: "Server is operational"
      Tasks: 38 (limit: 4630)
     Memory: 358.2M
        CPU: 991ms
     CGroup: /system.slice/mysql.service
             ??11476 /usr/sbin/mysqld

Apr 29 07:43:20 ubuntu systemd[1]: Starting MySQL Community Server...
Apr 29 07:43:21 ubuntu systemd[1]: Started MySQL Community Server.

다음 명령어를 사용하여 MySQL 버전을 확인할 수 있습니다:

mysql --version

다음 출력을 받을 수 있습니다:

mysql  Ver 8.0.28-0ubuntu4 for Linux on x86_64 ((Ubuntu))

기본적으로 MySQL은 보안이 설정되어 있지 않으며 루트 비밀번호가 설정되어 있지 않습니다. 따라서 다음 스크립트를 실행하여 보안을 설정해야 합니다:

mysql_secure_installation

다음과 같이 새 MySQL 비밀번호를 설정합니다:

Securing the MySQL server deployment.

Connecting to MySQL using a blank password.

VALIDATE PASSWORD COMPONENT can be used to test passwords
and improve security. It checks the strength of password
and allows the users to set only those passwords which are
secure enough. Would you like to setup VALIDATE PASSWORD component?

Press y|Y for Yes, any other key for No: 
Please set the password for root here.

New password: 

Re-enter new password: 
By default, a MySQL installation has an anonymous user,
allowing anyone to log into MySQL without having to have
a user account created for them. This is intended only for
testing, and to make the installation go a bit smoother.
You should remove them before moving into a production
environment.

다음과 같이 익명 사용자를 제거합니다:

Remove anonymous users? (Press y|Y for Yes, any other key for No) : 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? (Press y|Y for Yes, any other key for No) : Y
Success.

By default, MySQL 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? (Press y|Y for Yes, any other key for No) : 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? (Press y|Y for Yes, any other key for No) : Y
Success.

All done! 

Verify PHP Installation

LAMP 서버를 설치한 후 Apache가 PHP 페이지를 처리하는지 확인해야 합니다.

확인하기 위해 샘플 PHP 페이지를 생성합니다:

nano /var/www/html/info.php

다음 코드를 추가합니다:


파일을 저장하고 닫은 후 웹 브라우저를 열고 URL http://your-server-ip/info.php를 사용하여 PHP 페이지에 접근합니다. 다음 화면에서 PHP 정보 페이지를 볼 수 있어야 합니다:

결론

축하합니다! 우분투 22.04 서버에 LAMP 서버를 성공적으로 설치했습니다. 이제 LAMP 스택을 사용하여 웹사이트를 생성하고 호스팅할 수 있습니다. 질문이 있으면 언제든지 문의해 주세요.

Share: X/Twitter LinkedIn

새 게시물을 받은 편지함에서 받기

스팸은 없습니다. 언제든지 구독 해지 가능합니다.