웹사이트 검색

Debian 9에서 PHP + MySQL(LEMP)로 Nginx를 설치하는 방법


이 튜토리얼은 다음 OS 버전에 대해 존재합니다.

  • 데비안 7(Wheezy)

이 페이지에서

  1. 서문
  2. Debian 시스템 업데이트
  3. Nginx 설치
  4. MySQL 또는 MariaDB 설치
    1. MySQL 설치
    2. MariaDB 설치

    1. 자체 서명 SSL 인증서 만들기
    2. 무료 Lets Encrypt SSL 인증서 사용

    1. SSH 로그인
    2. MySQL 로그인

    이 튜토리얼은 Debian 9(Stretch)에 Nginx 웹 서버를 설치하는 방법을 보여줍니다. Nginx("엔진 x"로 발음)는 무료 오픈 소스 고성능 HTTP 서버입니다. Nginx는 안정성, 풍부한 기능 세트, 간단한 구성 및 낮은 리소스 소비로 유명합니다. 이 가이드에서는 PHP를 지원하는 Nginx(PHP-FPM 사용)와 MySQL 및 MariaDB를 설치하는 방법을 보여줍니다. 이 설정은 종종 LEMP=Linux + nginx(\engine x\로 발음) + MySQL + PHP) .

    서문

    이 자습서에서는 호스트 이름 server1.example.com을 IP 주소 192.168.1.100과 함께 사용합니다. 이러한 설정은 사용자에 따라 다를 수 있으므로 적절하게 교체해야 합니다. Debian 9 서버가 있어야 합니다. 이 튜토리얼에서는 Debian 최소 서버를 기본 시스템으로 사용하겠습니다.

    데비안 시스템 업데이트

    Nginx 설정을 시작하기 전에 패키지 목록을 업데이트하고 보류 중인 업데이트를 설치하는 것이 좋습니다. 보류 중인 업데이트를 설치하려면 다음 명령을 실행하십시오.

    apt-get update
    apt-get upgrade -y

    나중에 nano 편집기를 사용하여 구성 파일을 편집하겠습니다. Nano는 다음 명령으로 설치할 수 있습니다.

    apt-get -y install nano

    Nginx 설치

    Nginx는 다음 명령으로 설치할 수 있는 Debian 9용 패키지로 제공됩니다.

    apt-get -y install nginx

    이제 Nginx 웹 서버를 시작합니다.

    systemctl start nginx.service

    웹 서버 IP 주소 또는 호스트 이름을 브라우저에 입력하면(예: http://192.168.1.100) 다음 페이지가 표시됩니다.

    Debian Linux의 기본 nginx 문서 루트는 /var/www/html입니다.

    MySQL 또는 MariaDB 설치

    이 단계에서는 MySQL 또는 MariaDB를 설치하는 방법을 보여줍니다. 원하는 데이터베이스 시스템을 자유롭게 선택할 수 있습니다. MySQL과 MariaDB를 함께 설치하지 않고 하나의 데이터베이스 엔진만 설치해야 합니다.

    MySQL 설치

    Debian 9용 MySQL 패키지는 Oracle에서 직접 구할 수 있습니다. Oracle은 Oracle MySQL 리포지토리를 Debian에 통합하는 MySQL 리포지토리 패키지를 제공하므로 apt로 MySQL을 설치하고 업데이트할 수 있습니다. 다운로드 URL 변경으로 인해 아래의 wget 다운로드가 실패하는 경우 여기에서 MySQL apt 저장소 패키지를 다운로드하세요.

    cd /tmp
    wget https://dev.mysql.com/get/mysql-apt-config_0.8.9-1_all.deb
    dpkg -i mysql-apt-config_0.8.9-1_all.deb

    목록에서 확인을 구성하도록 선택한 다음 바닥글에서 확인 버튼에 초점을 맞추고 Enter 키를 누릅니다. 이렇게 하면 현재 안정적인 버전인 MySQL 5.7이 선택됩니다.

    이제 패키지 목록을 업데이트하고 MySQL 서버 및 클라이언트 패키지를 설치하십시오.

    apt-get update
    apt-get -y install mysql-community-client mysql-community-server

    MySQL 설치 프로그램은 MySQL 루트 사용자의 암호를 설정하도록 요청합니다. 길고 안전한 암호를 선택하십시오. 이 암호는 MySQL 데이터베이스에 대한 전체 관리 액세스를 허용합니다.

    요청에 따라 암호를 다시 입력하십시오.

    MariaDB 설치

    MariaDB를 설치하기 위해 다음을 실행합니다.

    apt-get -y install mariadb-server mariadb-client

    MySQL 설치 프로그램과 달리 MariaDB 설치 프로그램은 설치 중에 루트 암호를 설정하지 않습니다. MariaDB 설치를 보호하려면 익명 사용자를 제거하고 테스트 데이터베이스를 비활성화하려면 다음 명령을 실행하십시오.

    mysql_secure_installation

    다음과 같이 질문에 답하십시오.

    Change the root password? [Y/n] <-- y
    New password: <-- Enter a new MySQL root password
    Re-enter new password: <-- Repeat the MySQL root password
    Remove anonymous users? [Y/n] <-- y
    Disallow root login remotely? [Y/n] <-- y
    Remove test database and access to it? [Y/n] <-- y
    Reload privilege tables now? [Y/n] <-- y

    PHP 설치

    PHP-FPM(PHP FastCGI Process Manager)을 통해 nginx에서 PHP가 작동하도록 할 수 있습니다. 이것은 모든 크기의 사이트, 특히 더 바쁜 사이트에 유용한 몇 가지 추가 기능이 있는 대체 PHP FastCGI 구현입니다. 다음과 같이 PHP 7을 설치합니다.

    apt-get -y install php7.0-fpm

    PHP-FPM은 소켓 /var/run/php/php7.0-fpm.sock에서 FastCGI 서버를 실행하는 데몬 프로세스(시스템 단위 파일 php7.0-fpm.service 포함)입니다.

    Nginx 구성

    Nginx 구성은 지금 여는 /etc/nginx/nginx.conf에 있습니다.

    nano /etc/nginx/nginx.conf

    구성은 이해하기 쉽습니다(https://www.nginx.com/resources/wiki/에서 자세히 알아볼 수 있음).

    먼저 keepalive_timeout을 2초와 같은 합리적인 값으로 설정합니다.

    [...]
    keepalive_timeout 2;
    [...]

    가상 호스트는 서버 {} 컨테이너에 정의됩니다. 기본 가상 호스트는 /etc/nginx/sites-available/default 파일에 정의되어 있습니다. 다음과 같이 수정할 수 있습니다.

    nano /etc/nginx/sites-available/default
    [...]
    server {
    listen 80 default_server;
    listen [::]:80 default_server;

    # SSL configuration
    #
    # listen 443 ssl default_server;
    # listen [::]:443 ssl default_server;
    #
    # Note: You should disable gzip for SSL traffic.
    # See: https://bugs.debian.org/773332
    #
    # Read up on ssl_ciphers to ensure a secure configuration.
    # See: https://bugs.debian.org/765782
    #
    # Self signed certs generated by the ssl-cert package
    # Don't use them in a production server!
    #
    # include snippets/snakeoil.conf;

    root /var/www/html;

    # Add index.php to the list if you are using PHP
    index index.php index.html index.htm index.nginx-debian.html;

    server_name _;

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

    # pass PHP scripts to FastCGI server
    #
    location ~ \.php$ {
    include snippets/fastcgi-php.conf;

    # With php-fpm (or other unix sockets):
    fastcgi_pass unix:/var/run/php/php7.0-fpm.sock;
    # With php-cgi (or other tcp sockets):
    # fastcgi_pass 127.0.0.1:9000;
    }

    # deny access to .htaccess files, if Apache's document root
    # concurs with nginx's one
    #
    location ~ /\.ht {
    deny all;
    }
    } [...]

    서버 이름 _; 이것을 기본 포괄 가상 호스트로 만듭니다(물론 여기에 www.example.com과 같은 호스트 이름을 지정할 수도 있습니다).

    인덱스 라인에 index.php를 추가했습니다. 루트 /var/www/html; 문서 루트가 /var/www/html 디렉토리임을 의미합니다.

    PHP에서 중요한 부분은 위치 ~ \\.php${} 스탠자입니다. 활성화하려면 위와 같이 주석을 해제하십시오. 두 개의 fastcgi_pass 행이 포함되어 있으며 php-7.0-fpm.sock 파일에 대한 주석 하나만 제거하십시오.

    이제 파일을 저장하고 Nginx를 다시 로드합니다.

    systemctl reload nginx.service

    다음 열기 /etc/php/7.0/fpm/php.ini...

    nano /etc/php/7.0/fpm/php.ini

    ... 그리고 cgi.fix_pathinfo=0을 설정합니다:

    [...]
    ; cgi.fix_pathinfo provides *real* PATH_INFO/PATH_TRANSLATED support for CGI.  PHP's
    ; previous behaviour was to set PATH_TRANSLATED to SCRIPT_FILENAME, and to not grok
    ; what PATH_INFO is.  For more information on PATH_INFO, see the cgi specs.  Setting
    ; this to 1 will cause PHP CGI to fix its paths to conform to the spec.  A setting
    ; of zero causes PHP to behave as before.  Default is 1.  You should fix your scripts
    ; to use SCRIPT_FILENAME rather than PATH_TRANSLATED.
    ; http://php.net/cgi.fix-pathinfo
    cgi.fix_pathinfo=0
    [...]

    ... 그러면 POST 제한과 파일 업로드 제한을 높일 수 있습니다.

    post_max_size = 25M
    upload_max_filesize = 20M

    PHP로 대용량 파일을 업로드할 계획이라면 값을 500M 이상으로 올려야 합니다. 여기서 M은 메가바이트를 의미합니다.

    마지막으로 시간대를 현지 시간대로 설정할 수 있습니다. 내 경우 시간대는 다음과 같습니다.

    date.timezone = 'Europe/Berlin'

    여기에서 지원되는 시간대 목록을 찾을 수 있습니다.

    변경 사항을 적용하려면 PHP-FPM을 다시 로드하십시오.

    systemctl reload php7.0-fpm.service

    이제 문서 루트 /var/www/html/에 다음 PHP 파일을 만듭니다.

    nano /var/www/html/info.php
    <?php
    phpinfo();

    이제 브라우저에서 해당 파일을 호출합니다(예: http://192.168.1.100/info.php).

    보시다시피 PHP 7이 작동 중이며 서버 API 라인에 표시된 것처럼 FPM/FastCGI를 통해 작동합니다. 더 아래로 스크롤하면 PHP에서 이미 활성화된 모든 모듈이 표시됩니다. MySQL은 목록에 없습니다. 이는 아직 PHP에서 MariaDB/MySQL 지원이 없음을 의미합니다.

    PHP에서 MySQL/MariaDB 지원 받기

    PHP에서 MySQL 지원을 받으려면 php7.0-mysqlnd 패키지를 설치할 수 있습니다. 다른 PHP 모듈을 설치하는 것이 좋으며 애플리케이션에 필요할 수도 있습니다. 다음과 같이 사용 가능한 PHP 모듈을 검색할 수 있습니다.

    apt-cache search php7.0

    필요한 것을 선택하고 다음과 같이 설치하십시오.

    apt-get -y install php7.0-mysqlnd php7.0-curl php7.0-gd php7.0-intl php-pear php-imagick php7.0-imap php7.0-mcrypt php-memcache php7.0-intl php7.0-pspell php7.0-recode php7.0-sqlite3 php7.0-tidy php7.0-xmlrpc php7.0-xsl

    이제 PHP-FPM을 다시 로드합니다.

    systemctl reload php7.0-fpm.service

    이제 브라우저에서 http://192.168.1.100/info.php를 다시 로드하고 모듈 섹션으로 다시 스크롤하십시오. 이제 MySQLi 및 MySQLnd 모듈을 포함하여 많은 새 모듈을 찾을 수 있습니다.

    PHP-FPM이 TCP 연결을 사용하도록 만들기(선택 사항)

    기본적으로 PHP-FPM은 소켓 /var/run/php/php7.0-fpm.sock에서 수신 대기하며 이는 PHP를 Nginx에 연결하는 가장 빠르고 권장되는 방법입니다. 그러나 Nginx가 네트워크를 통해 PHP에 연결하도록 하려는 설정이 있을 수 있습니다. PHP-FPM이 TCP 연결을 사용하도록 할 수 있습니다. 이렇게 하려면 /etc/php/7.0/fpm/pool.d/www.conf...를 엽니다.

    nano /etc/php/7.0/fpm/pool.d/www.conf

    ... 다음과 같이 청취 라인을 만듭니다.

    [...]
    ;listen = /var/run/php5-fpm.sock
    listen = 127.0.0.1:9000
    [...]

    이렇게 하면 PHP-FPM이 IP 127.0.0.1(localhost)의 포트 9000에서 수신 대기하게 됩니다. 시스템에서 사용하지 않는 포트를 사용하고 있는지 확인하십시오.

    그런 다음 PHP-FPM을 다시 로드합니다.

    systemctl reload php7.0-fpm.service

    다음으로 Nginx 구성과 모든 가상 호스트를 살펴보고 fastcgi_pass unix:/var/run/php7.0-fpm.sock; 줄을 변경합니다. to fastcgi_pass 127.0.0.1:9000;, 예. 이와 같이:

    nano /etc/nginx/sites-available/default
    [...]
    location ~ \.php$ {
    include snippets/fastcgi-php.conf;

    # With php-fpm (or other unix sockets):
    # fastcgi_pass unix:/var/run/php/php7.0-fpm.sock;
    # With php-cgi (or other tcp sockets):
    fastcgi_pass 127.0.0.1:9000;
    } [...]

    마지막으로 Nginx를 다시 로드합니다.

    systemctl reload nginx.service

    Nginx에서 SSL 및 HTTP/2 활성화

    오늘날 대부분의 웹사이트는 SSL(TLS)을 사용하여 보안 액세스를 제공합니다. 이 장에서는 SSL 인증서를 생성하는 방법과 Nginx에서 SSL을 활성화하는 방법을 보여드리겠습니다. 자체 서명된 SSL 인증서를 사용하거나 Lets encrypt에서 공식적으로 서명된 SSL 인증서를 요청할 수 있습니다. Let#s encrypt SSL 인증서는 무료로 사용할 수 있지만 이미 DNS에서 서버를 가리키는 유효한 도메인 이름이 있어야 합니다. 아직 도메인 이름이 없거나 서버가 로컬 네트워크에 있고 외부에서 액세스할 수 없는 경우 자체 서명된 SSL 인증서를 사용하십시오. 자체 서명된 SSL 인증서에 대한 단계 또는 아래의 Lets encrypt 인증서를 따르되 둘 다 수행하지는 마십시오.

    자체 서명된 SSL 인증서 생성

    OpenSSL 명령어로 SSL 키 파일을 만듭니다.

    openssl genrsa -out /etc/ssl/private/nginx.key 4096

    그런 다음 자체 서명된 SSL 인증서를 만듭니다.

    openssl req -new -x509 -key /etc/ssl/private/nginx.key -out /etc/ssl/certs/nginx.pem -days 3650

    명령은 국가, 주, 도시, 회사 이름 및 도메인 이름과 같은 세부 정보를 묻습니다.

    Nginx에서 자체 서명된 SSL 인증서를 활성화합니다. 이렇게 하려면 nginx.conf 파일을 다시 편집합니다.

    나노 /etc/nginx/sites-available/default

    서버 부분을 다음과 같이 만듭니다.

    server {
    listen 80 default_server;
    listen [::]:80 default_server;

    # SSL configuration

    listen 443 ssl http2 default_server;
    listen [::]:443 ssl http2 default_server;

    ssl on;
    ssl_certificate_key /etc/ssl/private/nginx.key;
    ssl_certificate /etc/ssl/certs/nginx.pem;
    ssl_protocols TLSv1 TLSv1.1 TLSv1.2;
    ssl_ciphers 'ECDHE-ECDSA-CHACHA20-POLY1305:ECDHE-RSA-CHACHA20-POLY1305:ECDHE-ECDSA-AES128-GCM-SHA256:ECDHE-RSA-AES128-GCM-SHA256:ECDHE-ECDSA-AES256-GCM-SHA384:ECDHE-RSA-AES256-GCM-SHA384:DHE-RSA-AES128-GCM-SHA256:DHE-RSA-AES256-GCM-SHA384:ECDHE-ECDSA-AES128-SHA256:ECDHE-RSA-AES128-SHA256:ECDHE-ECDSA-AES128-SHA:ECDHE-RSA-AES256-SHA384:ECDHE-RSA-AES128-SHA:ECDHE-ECDSA-AES256-SHA384:ECDHE-ECDSA-AES256-SHA:ECDHE-RSA-AES256-SHA:DHE-RSA-AES128-SHA256:DHE-RSA-AES128-SHA:DHE-RSA-AES256-SHA256:DHE-RSA-AES256-SHA:ECDHE-ECDSA-DES-CBC3-SHA:ECDHE-RSA-DES-CBC3-SHA:EDH-RSA-DES-CBC3-SHA:AES128-GCM-SHA256:AES256-GCM-SHA384:AES128-SHA256:AES256-SHA256:AES128-SHA:AES256-SHA:DES-CBC3-SHA:!DSS';
    ssl_prefer_server_ciphers on;

    # Note: You should disable gzip for SSL traffic.
    # See: https://bugs.debian.org/773332
    #
    # Read up on ssl_ciphers to ensure a secure configuration.
    # See: https://bugs.debian.org/765782
    #
    # Self signed certs generated by the ssl-cert package
    # Don't use them in a production server!
    #
    # include snippets/snakeoil.conf;

    root /var/www/html;

    # Add index.php to the list if you are using PHP
    index index.php index.html index.htm index.nginx-debian.html;

    server_name _;

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

    # pass PHP scripts to FastCGI server
    #
    location ~ \.php$ {
    include snippets/fastcgi-php.conf;

    # With php-fpm (or other unix sockets):
    fastcgi_pass unix:/var/run/php/php7.0-fpm.sock;
    # With php-cgi (or other tcp sockets):
    # fastcgi_pass 127.0.0.1:9000;
    }

    # deny access to .htaccess files, if Apache's document root
    # concurs with nginx's one
    #
    location ~ /\.ht {
    deny all;
    }
    }

    변경 사항을 적용하려면 Nginx를 다시 시작하십시오.

    systemctl restart nginx.service

    이제 브라우저에서 서버의 https URL을 엽니다. https://192.169.1.100/. 진행하려면 수락해야 하는 보안 경고가 표시됩니다. 그런 다음 Nginx 시작 페이지가 표시되고 브라우저의 URL 표시줄에 있는 경고 아이콘은 자체 서명된 SSL 인증서를 사용함을 나타냅니다.

    무료 Lets Encrypt SSL 인증서 사용

    이 장에서는 무료 Lets encrypt SSL 인증서를 사용하여 Nginx 서버를 보호하는 방법을 설명합니다. 전제 조건은 현재 Nginx를 설치하는 서버의 IP를 가리키는 도메인 이름을 소유하고 있다는 것입니다.

    무료 SSL 인증서를 얻는 데 사용되는 Lets encrypt 클라이언트인 Certbot을 설치합니다.

    apt-get -y install certbot python-certbot-nginx

    웹사이트 구성 파일 /etc/nginx/sites-available/default를 편집하고 server_name 줄에 도메인 이름을 설정합니다.

    nano /etc/nginx/sites-available/default

    편집 후 줄은 다음과 같아야 합니다.

    server_name example.com;

    example.com을 자신의 도메인 이름으로 바꾸십시오. 도메인 이름 또는 하위 도메인이 여러 개인 경우 공백으로 구분하여 추가하십시오.

    server_name example.com www.example.com otherdomain.tld;

    이제 Certbot의 nginx 플러그인을 사용하여 암호화하자에서 SSL 인증서를 요청합니다.

    certbot --nginx -d example.com

    -d 옵션을 반복하여 여러 도메인을 추가할 수 있습니다. 예:

    certbot certonly --webroot -d example.com -d www.example.com

    Certbot은 갱신 알림을 보낼 이메일 주소를 묻습니다. 여기에 유효한 이메일 주소를 입력하세요.

    Enter email address (used for urgent renewal and security notices) (Enter 'c' to cancel): 

    A를 입력하여 라이선스 조건에 동의합니다.

    -------------------------------------------------------------------------------
    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-v01.api.letsencrypt.org/directory
    -------------------------------------------------------------------------------
    (A)gree/(C)ancel: A

    여기에 SSL 인증서를 요청하는 추가 대화 상자가 있습니다. 내 답변을 빨간색으로 추가했습니다.

    Saving debug log to /var/log/letsencrypt/letsencrypt.log
    Obtaining a new certificate
    Performing the following challenges:
    http-01 challenge for example.com
    http-01 challenge for www.example.com
    Select the webroot for example.com:
    -------------------------------------------------------------------------------
    1: Enter a new webroot
    -------------------------------------------------------------------------------
    Press 1 [enter] to confirm the selection (press 'c' to cancel): 1
    Input the webroot for example.com: (Enter 'c' to cancel):/var/www/html
    Select the webroot for www.example.com:
    -------------------------------------------------------------------------------
    1: Enter a new webroot
    2: /var/www/html
    -------------------------------------------------------------------------------
    Select the appropriate number [1-2] then [enter] (press 'c' to cancel): 2
    Waiting for verification...
    Cleaning up challenges
    Generating key (2048 bits): /etc/letsencrypt/keys/0000_key-certbot.pem
    Creating CSR: /etc/letsencrypt/csr/0000_csr-certbot.pem
    IMPORTANT NOTES:
    - Congratulations! Your certificate and chain have been saved at
    /etc/letsencrypt/live/example.com/fullchain.pem. Your cert will
    expire on 2018-04-23. To obtain a new or tweaked version of this
    certificate in the future, simply run certbot again. To
    non-interactively renew *all* of your certificates, run "certbot
    renew"
    - 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

    Certbot에서 --nginx 옵션을 사용하는 다른 방법이 있지만 이 방법은 Lets encrypt의 TLS-SNI-01 문제로 인해 현재 작동하지 않는 것 같습니다. 위에 표시된 것처럼 webroot 방법은 잘 작동합니다.

    새로 생성된 SSL 인증서는 /etc/letsencrypt/live/ 폴더의 하위 폴더에 있습니다. 정확한 경로는 Certbot 출력에 표시됩니다.

    이제 이 SSL 인증서를 Nginx 웹사이트 파일에 추가하십시오. Nginx 기본 파일을 편집합니다.

    nano /etc/nginx/sites-available/default

    다음과 같이 SSL 섹션을 변경합니다.

    [...]
    server {
    listen 80 default_server;
    listen [::]:80 default_server;

    # SSL configuration

    listen 443 ssl http2 default_server;
    listen [::]:443 ssl http2 default_server;

    ssl on;
    ssl_certificate_key /etc/letsencrypt/live/example.com/privkey.pem;
    ssl_certificate /etc/letsencrypt/live/example.com/fullchain.pem;
    ssl_protocols TLSv1 TLSv1.1 TLSv1.2;
    ssl_ciphers 'ECDHE-ECDSA-CHACHA20-POLY1305:ECDHE-RSA-CHACHA20-POLY1305:ECDHE-ECDSA-AES128-GCM-SHA256:ECDHE-RSA-AES128-GCM-SHA256:ECDHE-ECDSA-AES256-GCM-SHA384:ECDHE-RSA-AES256-GCM-SHA384:DHE-RSA-AES128-GCM-SHA256:DHE-RSA-AES256-GCM-SHA384:ECDHE-ECDSA-AES128-SHA256:ECDHE-RSA-AES128-SHA256:ECDHE-ECDSA-AES128-SHA:ECDHE-RSA-AES256-SHA384:ECDHE-RSA-AES128-SHA:ECDHE-ECDSA-AES256-SHA384:ECDHE-ECDSA-AES256-SHA:ECDHE-RSA-AES256-SHA:DHE-RSA-AES128-SHA256:DHE-RSA-AES128-SHA:DHE-RSA-AES256-SHA256:DHE-RSA-AES256-SHA:ECDHE-ECDSA-DES-CBC3-SHA:ECDHE-RSA-DES-CBC3-SHA:EDH-RSA-DES-CBC3-SHA:AES128-GCM-SHA256:AES256-GCM-SHA384:AES128-SHA256:AES256-SHA256:AES128-SHA:AES256-SHA:DES-CBC3-SHA:!DSS';
    ssl_prefer_server_ciphers on;

    # Note: You should disable gzip for SSL traffic.
    # See: https://bugs.debian.org/773332
    #
    # Read up on ssl_ciphers to ensure a secure configuration.
    # See: https://bugs.debian.org/765782
    #
    # Self signed certs generated by the ssl-cert package
    # Don't use them in a production server!
    #
    # include snippets/snakeoil.conf;

    root /var/www/html;

    # Add index.php to the list if you are using PHP
    index index.php index.html index.htm index.nginx-debian.html;

    server_name _;

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

    # pass PHP scripts to FastCGI server
    #
    location ~ \.php$ {
    include snippets/fastcgi-php.conf;

    # With php-fpm (or other unix sockets):
    fastcgi_pass unix:/var/run/php/php7.0-fpm.sock;
    # With php-cgi (or other tcp sockets):
    # fastcgi_pass 127.0.0.1:9000;
    }

    # deny access to .htaccess files, if Apache's document root
    # concurs with nginx's one
    #
    location ~ /\.ht {
    deny all;
    }
    } [...]

    SSL 인증서 경로의 example.com을 자신의 도메인 이름으로 바꿉니다. 변경 사항을 적용하려면 Nginx를 다시 시작하십시오.

    systemctl restart nginx.service

    가상 머신 이미지

    이 튜토리얼은 Howtoforge 구독자를 위해 OVA/OVF 형식의 가상 머신을 사용할 준비가 된 상태로 제공됩니다. VM 형식은 VMWare 및 Virtualbox 및 아마도 이 형식을 가져올 수 있는 다른 도구와 호환됩니다. 상단 오른쪽 메뉴에서 다운로드 링크를 찾을 수 있습니다. 파일 이름을 클릭하면 다운로드가 시작됩니다.

    VM의 로그인 세부 정보는 다음과 같습니다.

    SSH 로그인

    사용자 이름: administrator
    비밀번호: howtoforge

    su를 실행하여 루트 사용자가 되십시오. 루트 암호도 howtoforge입니다.

    가상 머신 이미지는 MySQL을 데이터베이스 서버로 사용합니다.

    MySQL 로그인

    사용자 이름: root
    비밀번호: howtoforge

    최초 부팅 후 암호를 변경하십시오.

    VM은 정적 IP 192.168.1.100에 대해 구성되며 IP는 /etc/network/interfaces 파일에서 변경할 수 있습니다.

    연결

    • nginx: https://nginx.net/
    • PHP:
    • MySQL: https://www.mysql.com/
    • MariaDB: https://mariadb.org/
    • 데비안: https://www.debian.org/