서버 구축

kangking·2024년 5월 8일

기반기술

목록 보기
6/14
post-thumbnail

서버구축 실습

웹 앱 서버 | DB서버 나누기

구조:

내컴퓨터웹 앱 서버DB 서버
클라이언트DB클라이언트DB서버
  1. DB서버 준비

    • 가상 머신 준비
    • 가상 머신 네트워크 설정(ip등)
    • DB서버 프로그램 설치(mariaDB)
      yum install -y mariadb-server
    • 방화벽 해결
      setenforce 0
      systemctl stop firewalld
    • 사용자, DB 생성 및 권한설정
      CREATE USER '[이니셜]'@'%' IDENTIFIED BY 'qwer1234';
      CREATE DATABASE [DB 이름];
      GRANT ALL PRIVILEGES ON [DB 이름].* TO '[이니셜]'@'%';
  2. 윈도우 컴퓨터에 DB 클라이언트 준비

    • MySQL Workbench 설치
    • 워크벤치에서 서버로 접속
  3. 웹 서버 준비

    • nginx 설치
    yum install -y nginx
    • php 설치

      dnf install -y https://dl.fedoraproject.org/pub/epel/epel-release-latest-8.noarch.rpm
      dnf install -y https://rpms.remirepo.net/enterprise/remi-release-8.rpm 
      dnf module reset php 
      dnf install -y php php-mysqlnd php-fpm php-opcache php-curl php-json php-gd php-xml php-mbstring php-zip -y 
      
  4. php설정

    vi /etc/php-fpm.d/www.conf
     24 user = nginx
    		26 group = nginx
    		48 ;listen.owner = nginx
    		49 ;listen.group = nginx   
            
            systemctl restart php-fpm
  5. wordpress 설치

    	yum install -y wget
        wget https://ko.wordpress.org/latest-ko_KR.tar.gz
        tar zxvf latest-ko_KR.tar.gz
        mv wordpress /var/www/html/
  6. nginx 서버 설정

    vi /etc/nginx/conf.d/test.conf
    server {
       listen 80;
       server_name test [웹 서버 IP주소];
    
       root /var/www/html/wordpress;
       index index.php index.html index.htm;
    
       # set client body size to 100 MB #
       client_max_body_size 100M;
    
       location / {
          try_files $uri $uri/ /index.php?$args;
       }
       error_page 404 /404.html;
       error_page 500 502 503 504 /50x.html;
       location = /50x.html {
          root /usr/share/nginx/html;
       }
    
       location ~ \.php$ {
          try_files $uri =404;
          fastcgi_pass unix:/var/run/php-fpm/www.sock;
          fastcgi_index index.php;
          fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
          include fastcgi_params;
       }
    }
  7. 폴더 권한 설정

    chown -R nginx:nginx /var/www/html/wordpress
  8. nginx 서버 재실행

  9. 접속 확인

  10. 워드 프레스 접속 후 설정

profile
하루하루 의미있게

0개의 댓글