Laravel 설치 · 8 min read · Nov 01, 2025

AlmaLinux 8에 Nginx와 무료 Let's Encrypt SSL로 Laravel PHP 프레임워크 설치하는 방법

Laravel은 PHP 기반 웹 애플리케이션을 구축하는 데 사용되는 무료, 오픈 소스, 경량 PHP 웹 프레임워크입니다. 우아한 문법, 고급 기능 및 강력한 도구 세트 덕분에 인기가 높습니다. Symfony 프레임워크를 기반으로 하며 개발자가 웹 애플리케이션 개발을 단순화하는 데 도움을 줍니다. 또한 애플리케이션 작업을 수행하기 위한 Artisan 명령줄 인터페이스를 제공합니다. Artisan, MVC 아키텍처, 객체-관계 매핑, 템플릿 엔진, 단위 테스트 및 데이터베이스 마이그레이션 시스템을 포함한 강력한 기능을 제공합니다.

이 게시물에서는 Alma Linux 8에서 Nginx와 함께 Laravel을 설치하는 방법을 보여줍니다.

전제 조건

  • Alma Linux 8이 실행되는 서버.
  • 서버 IP를 가리키는 유효한 도메인 이름.
  • 서버에 구성된 루트 비밀번호.

LEMP 서버 설치

먼저, 서버에 Nginx, MariaDB, PHP 및 기타 필요한 PHP 확장을 설치해야 합니다. 다음 명령을 실행하여 모두 설치할 수 있습니다:

dnf install nginx mariadb-server php php-fpm php-common php-xml php-mbstring php-json php-zip php-mysqlnd curl unzip -y

모든 패키지를 설치한 후 php-fpm 구성 파일을 편집하고 Nginx를 사용하도록 구성합니다:

nano /etc/php-fpm.d/www.conf

다음 줄을 변경합니다:

listen.owner = nginx
listen.group = nginx

파일을 저장하고 닫은 후 PHP 구성 파일을 편집하고 기본 값을 변경합니다:

nano /etc/php.ini

다음 줄을 변경합니다:

date.timezone = Asia/Kolkata
cgi.fix_pathinfo=1

파일을 저장하고 닫은 후 다음 명령을 사용하여 Nginx, MariaDB 및 PHP-FPM 서비스를 시작하고 활성화합니다:

systemctl start nginx  
systemctl start mariadb  
systemctl start php-fpm  
systemctl enable nginx  
systemctl enable mariadb  
systemctl enable php-fpm

작업이 완료되면 다음 단계로 진행할 수 있습니다.

Composer 설치

이 게시물에서는 Composer를 사용하여 Laravel을 설치합니다. 따라서 시스템에 Composer를 설치해야 합니다. 다음 명령을 실행하여 설치할 수 있습니다:

curl -sS https://getcomposer.org/installer | php

다음과 같은 출력을 받게 됩니다:

All settings correct for using Composer
Downloading...

Composer (version 2.2.3) successfully installed to: /root/composer.phar
Use it: php composer.phar

다음으로, Composer 바이너리를 시스템 경로로 이동하고 다음 명령으로 적절한 권한을 설정합니다:

mv composer.phar /usr/local/bin/composer  
chmod +x /usr/local/bin/composer

다음으로, 다음 명령으로 Composer 버전을 확인합니다:

composer --version

다음과 같은 출력을 받게 됩니다:

Composer version 2.2.3 2021-12-31 12:18:53

Alma Linux 8에 Laravel 설치

다음으로, Nginx 웹 루트 디렉토리로 변경하고 Composer를 사용하여 Laravel을 설치합니다:

cd /var/www/html/  
composer create-project --prefer-dist laravel/laravel laravel

다음과 같은 출력을 받게 됩니다:

Discovered Package: facade/ignition
Discovered Package: fideloper/proxy
Discovered Package: fruitcake/laravel-cors
Discovered Package: laravel/tinker
Discovered Package: nesbot/carbon
Discovered Package: nunomaduro/collision
Package manifest generated successfully.
69 packages you are using are looking for funding.
Use the `composer fund` command to find out more!
> @php artisan key:generate --ansi
Application key set successfully.

다음으로, Laravel에 적절한 소유권과 권한을 설정합니다:

chown -R nginx:nginx /var/www/html/laravel/  
chown -R nginx:nginx /var/www/html/laravel/storage/  
chown -R nginx:nginx /var/www/html/laravel/bootstrap/cache/  
chmod -R 0777 /var/www/html/laravel/storage/  
chmod -R 0775 /var/www/html/laravel/bootstrap/cache/

작업이 완료되면 다음 단계로 진행할 수 있습니다.

Laravel을 위한 Nginx 가상 호스트 생성

다음으로, Laravel을 위한 Nginx 구성 파일을 생성해야 합니다. 다음 명령을 사용하여 생성할 수 있습니다:

nano /etc/nginx/conf.d/laravel.conf

다음 줄을 추가합니다:

server {
       listen 80;
       server_name laravel.exampledomain.com;
       root        /var/www/html/laravel/public;
       index       index.php;
       charset utf-8;
       gzip on;
    gzip_types text/css application/javascript text/javascript application/x-javascript  image/svg+xml text/plain text/xsd text/xsl text/xml image/x-icon;
        location / {
         try_files $uri $uri/ /index.php?$query_string;
        }

        location ~ \.php {
                include fastcgi.conf;
                fastcgi_split_path_info ^(.+\.php)(/.+)$;
                fastcgi_pass unix:/run/php-fpm/www.sock;
        }
        location ~ \.ht {
                deny all;
        }
}

파일을 저장하고 닫은 후 Laravel의 구성 오류를 확인합니다:

nginx -t

다음과 같은 출력을 받아야 합니다:

nginx: the configuration file /etc/nginx/nginx.conf syntax is ok
nginx: configuration file /etc/nginx/nginx.conf test is successful

다음으로, 변경 사항을 적용하기 위해 Nginx 및 PHP-FPM 서비스를 재시작합니다:

systemctl restart php-fpm  
systemctl restart nginx

다음 명령을 사용하여 Nginx 상태를 확인할 수도 있습니다:

systemctl status nginx

다음과 같은 출력을 받게 됩니다:

? nginx.service - The nginx HTTP and reverse proxy server
   Loaded: loaded (/usr/lib/systemd/system/nginx.service; disabled; vendor preset: disabled)
  Drop-In: /usr/lib/systemd/system/nginx.service.d
           ??php-fpm.conf
   Active: active (running) since Fri 2022-01-07 08:29:11 UTC; 4s ago
  Process: 8186 ExecStart=/usr/sbin/nginx (code=exited, status=0/SUCCESS)
  Process: 8184 ExecStartPre=/usr/sbin/nginx -t (code=exited, status=0/SUCCESS)
  Process: 8182 ExecStartPre=/usr/bin/rm -f /run/nginx.pid (code=exited, status=0/SUCCESS)
 Main PID: 8188 (nginx)
    Tasks: 2 (limit: 11411)
   Memory: 3.7M
   CGroup: /system.slice/nginx.service
           ??8188 nginx: master process /usr/sbin/nginx
           ??8189 nginx: worker process

Jan 07 08:29:11 linux systemd[1]: nginx.service: Succeeded.
Jan 07 08:29:11 linux systemd[1]: Stopped The nginx HTTP and reverse proxy server.
Jan 07 08:29:11 linux systemd[1]: Starting The nginx HTTP and reverse proxy server...
Jan 07 08:29:11 linux nginx[8184]: nginx: the configuration file /etc/nginx/nginx.conf syntax is ok
Jan 07 08:29:11 linux nginx[8184]: nginx: configuration file /etc/nginx/nginx.conf test is successful
Jan 07 08:29:11 linux systemd[1]: nginx.service: Failed to parse PID from file /run/nginx.pid: Invalid argument
Jan 07 08:29:11 linux systemd[1]: Started The nginx HTTP and reverse proxy server.

Laravel을 위한 방화벽 구성

다음으로, firewalld 방화벽을 통해 포트 80과 443을 허용해야 합니다. 다음 명령으로 허용할 수 있습니다:

firewall-cmd --zone=public --permanent --add-service=http  
firewall-cmd --zone=public --permanent --add-service=https

다음으로, 변경 사항을 적용하기 위해 firewalld를 다시 로드합니다:

firewall-cmd --reload

Laravel 웹 UI 접근

이제 웹 브라우저를 열고 URL http://laravel.exampledomain.com을 사용하여 Laravel 웹 UI에 접근합니다. 다음 화면에서 Laravel 기본 페이지를 볼 수 있어야 합니다:

Laravel

Laravel 웹사이트에서 SSL 활성화

연결을 안전하게 하기 위해 Laravel 웹사이트에서 SSL을 활성화하는 것이 좋습니다. Let’s Encrypt는 도메인에 대한 SSL/TLS 인증서를 얻고, 갱신하고, 관리하는 무료 SSL을 제공합니다. 먼저, 다음 명령으로 Certbot 클라이언트를 설치합니다:

dnf install epel-release -y  
dnf install certbot -y

다음으로, 다음 명령을 실행하여 Laravel 도메인에 대한 Let’s Encrypt SSL을 다운로드합니다:

certbot --nginx -d laravel.exampledomain.com

유효한 이메일을 제공하고 서비스 약관에 동의하라는 메시지가 표시됩니다:

Saving debug log to /var/log/letsencrypt/letsencrypt.log
Plugins selected: Authenticator nginx, Installer nginx
Enter email address (used for urgent renewal and security notices) (Enter 'c' to
cancel): [email protected]

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Please read the Terms of Service at
https://letsencrypt.org/documents/LE-SA-v1.2-November-15-2017.pdf. You must
agree in order to register with the ACME server at
https://acme-v02.api.letsencrypt.org/directory
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
(A)gree/(C)ancel: A

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Would you be willing to share your email address with the Electronic Frontier
Foundation, a founding partner of the Let's Encrypt project and the non-profit
organization that develops Certbot? We'd like to send you email about our work
encrypting the web, EFF news, campaigns, and ways to support digital freedom.
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
(Y)es/(N)o: Y
Obtaining a new certificate
Performing the following challenges:
http-01 challenge for laravel.exampledomain.com
Waiting for verification...
Cleaning up challenges
Deploying Certificate to VirtualHost /etc/nginx/conf.d/laravel.conf

다음으로, HTTP 트래픽을 HTTPS로 리디렉션할지 여부를 선택합니다:

Please choose whether or not to redirect HTTP traffic to HTTPS, removing HTTP access.
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
1: No redirect - Make no further changes to the webserver configuration.
2: Redirect - Make all requests redirect to secure HTTPS access. Choose this for
new sites, or if you're confident your site works on HTTPS. You can undo this
change by editing your web server's configuration.
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Select the appropriate number [1-2] then [enter] (press 'c' to cancel): 2

2를 입력하고 Enter를 눌러 프로세스를 시작합니다. 인증서가 설치되면 다음과 같은 출력을 보게 됩니다:

Redirecting all traffic on port 80 to ssl in /etc/nginx/conf.d/laravel.conf

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Congratulations! You have successfully enabled https://laravel.exampledomain.com

You should test your configuration at:
https://www.ssllabs.com/ssltest/analyze.html?d=laravel.exampledomain.com
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

IMPORTANT NOTES:
 - Congratulations! Your certificate and chain have been saved at:
   /etc/letsencrypt/live/laravel.exampledomain.com/fullchain.pem
   Your key file has been saved at:
   /etc/letsencrypt/live/laravel.exampledomain.com/privkey.pem
   Your cert will expire on 2022-04-11. To obtain a new or tweaked
   version of this certificate in the future, simply run certbot again
   with the "certonly" option. To non-interactively renew *all* of
   your certificates, run "certbot renew"
 - Your account credentials have been saved in your Certbot
   configuration directory at /etc/letsencrypt. You should make a
   secure backup of this folder now. This configuration directory will
   also contain certificates and private keys obtained by Certbot so
   making regular backups of this folder is ideal.
 - If you like Certbot, please consider supporting our work by:

   Donating to ISRG / Let's Encrypt:   https://letsencrypt.org/donate
   Donating to EFF:                    https://eff.org/donate-le

 - We were unable to subscribe you the EFF mailing list because your
   e-mail address appears to be invalid. You can try again later by
   visiting https://act.eff.org.

이 시점에서, 당신의 Laravel 웹사이트는 Let’s Encrypt SSL로 보호됩니다. 이제 URL https://laravel.exampledomain.com을 사용하여 안전하게 접근할 수 있습니다.

결론

축하합니다! Alma Linux 8에 Nginx와 Let’s Encrypt SSL로 Laravel을 성공적으로 설치했습니다. 이제 Laravel 프레임워크를 사용하여 PHP 기반 애플리케이션 개발을 시작할 수 있습니다. 질문이 있으면 언제든지 문의해 주세요.

Share: X/Twitter LinkedIn

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

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