웹사이트 검색

Ubuntu 20.04에서 Nginx로 OSClass를 설치하는 방법


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

  • Ubuntu 20.04(Focal Fossa)
  • Ubuntu 18.04(Bionic Beaver)

이 페이지에서

  1. 전제 조건
  2. LEMP 스택 설치
  3. Osclass용 데이터베이스 만들기
  4. 오스클래스 다운로드
  5. Osclass용 Nginx 구성
  6. Lets Encrypt로 Osclass 보호\n
  7. 오스클래스 액세스
  8. 결론

Osclass는 자체 서버에서 분류된 웹사이트를 만드는 데 사용할 수 있는 사용자 친화적인 무료 오픈 소스 애플리케이션입니다. 기능이 풍부한 편집기, 사용자 친화적인 관리 포털, 기술적 지식 없이도 자신만의 리스팅 사이트를 만들 수 있도록 도와주는 유연한 템플릿 시스템이 함께 제공됩니다. 다국어, 캡차, 대시보드, SEO 친화적, 통합 검색 엔진, 무료 사이트 생성기 등을 포함한 기능 로그가 있습니다.

이 튜토리얼에서는 Ubuntu 20.04 서버에서 Nginx와 Lets Encrypt SSL을 사용하여 Osclass 분류 웹사이트 cms를 설치하는 방법을 설명합니다.

전제 조건

  • Ubuntu 20.04를 실행하는 서버.\n
  • 서버 IP를 가리키는 유효한 도메인 이름입니다.\n
  • 루트 암호는 서버에 구성됩니다.\n

LEMP 스택 설치

먼저 서버에 Nginx 웹 서버, MariaDB 서버, PHP 및 기타 필수 패키지를 설치해야 합니다. 다음 명령으로 모두 설치할 수 있습니다.

apt-get install nginx mariadb-server php7.4 php7.4-cli php7.4-fpm php7.4-common php7.4-mysql php7.4-gd php7.4-xml curl gnupg2 unzip -y

모든 패키지를 설치한 후 다음 단계로 진행할 수 있습니다.

Osclass용 데이터베이스 생성

다음으로 Osclass에 대한 데이터베이스와 사용자를 만들어야 합니다. 먼저 다음 명령을 사용하여 MariaDB에 로그인합니다.

mysql

로그인한 후 다음 명령을 사용하여 Osclass에 대한 데이터베이스 및 사용자를 만듭니다.

MariaDB [(none)]> CREATE DATABASE osclass;
MariaDB [(none)]> GRANT ALL PRIVILEGES ON osclass.* TO 'osclass'@'localhost' IDENTIFIED BY 'password';

그런 다음 권한을 플러시하고 다음 명령을 사용하여 MariaDB 셸을 종료합니다.

MariaDB [(none)]> FLUSH PRIVILEGES;
MariaDB [(none)]> EXIT;

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

오스클래스 다운로드

먼저 Git 저장소에서 최신 버전의 Osclass를 다운로드해야 합니다. 다음 명령으로 다운로드할 수 있습니다.

wget https://github.com/Dis555/Osclass/releases/download/4.2.0/Osclass-Evolution4.2.0.zip

다운로드가 완료되면 다음 명령을 사용하여 Nginx 루트 디렉터리에 다운로드한 파일의 압축을 풉니다.

unzip Osclass-Evolution4.2.0.zip -d /var/www/html/osclass

다음으로 osclass 디렉토리의 소유권을 www-data로 변경하고 다음 명령을 사용하여 적절한 권한을 부여합니다.

chown -R www-data:www-data /var/www/html/osclass
chmod -R 755 /var/www/html/osclass

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

Osclass용 Nginx 구성

다음으로 Osclass를 제공하기 위해 Nginx 가상 호스트 구성 파일을 만들어야 합니다. 다음 명령으로 만들 수 있습니다.

nano /etc/nginx/sites-available/osclass.conf

다음 줄을 추가합니다.

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

    server_name osclass.linuxbuz.com;
    root /var/www/html/osclass;

    index index.php index.html;

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

    location ~ \.php$ {
        include snippets/fastcgi-php.conf;
        fastcgi_pass unix:/var/run/php/php7.4-fpm.sock; # Check this
    }
}

파일을 저장하고 닫은 후 다음 명령을 사용하여 Nginx 가상 호스트를 활성화합니다.

ln -s /etc/nginx/sites-available/osclass.conf /etc/nginx/sites-enabled/

다음으로 다음 명령을 사용하여 구성 오류가 있는지 Nginx를 확인합니다.

nginx -t

다음 출력이 표시되어야 합니다.

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

마지막으로 Nginx 서비스를 다시 시작하여 변경 사항을 적용합니다.

systemctl restart nginx

다음으로 다음 명령을 사용하여 Nginx 서비스의 상태를 확인합니다.

systemctl status nginx

다음 출력이 표시되어야 합니다.

? nginx.service - A high performance web server and a reverse proxy server
     Loaded: loaded (/lib/systemd/system/nginx.service; enabled; vendor preset: enabled)
     Active: active (running) since Thu 2020-08-13 06:21:23 UTC; 4s ago
       Docs: man:nginx(8)
    Process: 13399 ExecStartPre=/usr/sbin/nginx -t -q -g daemon on; master_process on; (code=exited, status=0/SUCCESS)
    Process: 13412 ExecStart=/usr/sbin/nginx -g daemon on; master_process on; (code=exited, status=0/SUCCESS)
   Main PID: 13415 (nginx)
      Tasks: 3 (limit: 2353)
     Memory: 3.5M
     CGroup: /system.slice/nginx.service
             ??13415 nginx: master process /usr/sbin/nginx -g daemon on; master_process on;
             ??13416 nginx: worker process
             ??13417 nginx: worker process

Aug 13 06:21:23 ubunt4 systemd[1]: Starting A high performance web server and a reverse proxy server...
Aug 13 06:21:23 ubunt4 systemd[1]: Started A high performance web server and a reverse proxy server.

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

Lets Encrypt로 안전한 Osclass

Lets Encrypt SSL로 Osclass 웹사이트를 보호하는 것은 항상 좋은 생각입니다. 먼저 서버에 Certbot 클라이언트를 설치해야 합니다. Certbot은 도메인의 SSL 인증서를 관리하는 데 사용되는 Lets Encrypt 클라이언트입니다. 다음 명령을 사용하여 Certbot 클라이언트를 설치할 수 있습니다.

apt-get install python3-certbot-nginx -y

Certbot 클라이언트를 설치한 후 다음 명령을 실행하여 웹 사이트에 대한 Lets Encrypt SSL을 설치합니다.

certbot --nginx -d osclass.linuxbuz.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): 

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
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 osclass.linuxbuz.com
Waiting for verification...
Cleaning up challenges
Deploying Certificate to VirtualHost /etc/nginx/sites-enabled/osclass.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/sites-enabled/osclass.conf

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Congratulations! You have successfully enabled https://osclass.linuxbuz.com

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

IMPORTANT NOTES:
 - Congratulations! Your certificate and chain have been saved at:
   /etc/letsencrypt/live/osclass.linuxbuz.com/fullchain.pem
   Your key file has been saved at:
   /etc/letsencrypt/live/osclass.linuxbuz.com/privkey.pem
   Your cert will expire on 2020-11-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.

이 시점에서 Osclass 웹사이트는 Lets Encrypt SSL로 보호됩니다.

액세스 오스클래스

이제 웹 브라우저를 열고 URL https://osclass.linuxbuz.com을 입력하십시오. 다음 화면으로 리디렉션됩니다.

INSTALL 버튼을 클릭하여 설치를 시작합니다. 다음 화면이 표시됩니다.

모든 요구 사항이 충족되었는지 확인한 다음 설치 실행 버튼을 클릭합니다. 다음 화면이 표시됩니다.

데이터베이스 이름, 데이터베이스 사용자 이름, 암호를 제공하고 NEXT 버튼을 클릭합니다. 다음 화면이 표시됩니다.

관리자 사용자 이름, 비밀번호, 이메일을 제공하고 다음 버튼을 클릭합니다. 설치가 완료되면 다음 화면이 표시됩니다.

마침 및 관리 패널로 이동 버튼을 클릭합니다. 아래와 같이 Osclass 로그인 화면으로 리디렉션됩니다.

관리자 사용자 이름, 비밀번호를 제공하고 로그인 버튼을 클릭합니다. 다음 화면에 Osclass 대시보드가 표시되어야 합니다.

결론

이 가이드에서는 Ubuntu 20.04 서버에서 Nginx와 함께 Osclass cms를 설치하는 방법을 배웠습니다. Lets Encrypt SSL을 사용하여 Osclass를 보호하는 방법도 배웠습니다. 이제 Osclass로 나만의 분류된 웹 사이트를 쉽게 만들 수 있기를 바랍니다.