마음만은 한량 햄버거 메뉴
반응형
GCP (Ubuntu16.04) + PHP7 + Nginx + Mysql을 기반으로 합니다.
처음 세팅 해본 것으로 오류가 있을 수 있습니다.

2. 워드프레스
  • Mysql 
    • 접속 및 DB 생성

$ mysql -u root -p                                 # mysql 쉘 접속

$ CREATE DATABASE wordpress;          # wordpress라는 데이터베이스 생성

    • 사용자 추가
      • wordpressuser라는 사용자를 추가하고, password 자리에 사용할 패스워드를 적는다.

$ CREATE USER wordpressuser@localhost IDENTIFIED BY "password";

    • 사용자에게 액세스 권한 부여

$ GRANT ALL PRIVILEGES ON wordpress.* TO wordpressuser@localhost;

$ FLUSH PRIVILEGES;        # 권한 변경을 알리고 즉시 반영되도록 수행

    • 종료

$ exit


  • Nginx
    • 서버블록 생성
      • 워드프레스를 적용할 서버블록을 생성한다.

$ cd /etc/nginx/sites-available

$ sudo vi wordpress

# wordpess


server {

  listen 80;


  root /var/www/wordpress;

  index index.php index.html index.htm;


  server_name domain.com;                                    # 자신의 도메인 명


  error_page 404 /404.html;

  error_page 500 502 503 504 /50x.html;


  location = /50x.html {

    root /usr/share/nginx/html;

  }


  location / {

    try_files $uri $uri/ /index.php?q=$uri&$args;

  }


  location ~ .php$ {

    try_files $uri =404;

    fastcgi_split_path_info ^(.+.php)(/.+)$;

    fastcgi_pass unix:/run/php/php7.0-fpm.sock;

    fastcgi_index index.php;

    fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;

    include fastcgi_params;

  }


  location = /favicon.ico { 

    log_not_found off;

    access_log off;

  }


  location = /robots.txt {

    log_not_found off;

    access_log off;

    allow all; 

  }


  location ~* .(css|gif|ico|jpeg|jpg|js|png)$ {

    expires max;

    log_not_found off;

  }

}

    • 작동 테스트

$ sudo nginx -t


# 성공시 나오는 문구

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

nginx: configuration file /etc/nginx/nginx.conf test is successful

    • 서버 블록 활성화
      • 기존 서버 블록을 삭제하고, 위에서 생성한 wordpress 서버 블록을 활성화시킨다.
      • ln -s 옵션을 이용해 서버 블록을 가리키는 symbolic link를 sites-enabled 경로에 생성한다.

$ sudo rm /etc/nginx/sites-enabled/default

$ sudo ln -s /etc/nginx/sites-available/wordpress /etc/nginx/sites-enabled/wordpress

    • Nginx 로드

$ sudo service nginx reload


  • 워드프레스
    • 경로 생성 및 설치

$ sudo mkdir /var/www/wordpress

$ cd                                                           # 기본 디렉토리로 이동 후, 설치

$ curl -O https://wordpress.org/latest.tar.gz

    • 압축 해제 후 디렉토리로 복사

$ tar xzvf latest.tar.gz

$ sudo cp -a ~/wordpress/. /var/www/wordpress

    • 설정파일 수정
      • 샘플 파일을 복사한 후, 수정한다.

$ cd /var/www/wordpress

$ cp wp-config-sample.php wp-config.php

$ sudo vi wp-config.php

      • DB 정보 입력

# wp-config.php // ** MySQL settings - You can get this info from your web host ** //

/** The name of the database for WordPress */

define('DB_NAME', 'wordpress');                                                    # DB 명

/** MySQL database username */

define('DB_USER', 'wordpressuser');                                              # DB User 명

/** MySQL database password */

define('DB_PASSWORD', 'password');                                            # DB Password

      • 보안키 설정

# wp-config.php


define('AUTH_KEY',         'put your unique phrase here');

define('SECURE_AUTH_KEY',  'put your unique phrase here');

define('LOGGED_IN_KEY',    'put your unique phrase here');

define('NONCE_KEY',        'put your unique phrase here');

define('AUTH_SALT',        'put your unique phrase here');

define('SECURE_AUTH_SALT', 'put your unique phrase here');

define('LOGGED_IN_SALT',   'put your unique phrase here');

define('NONCE_SALT',       'put your unique phrase here');

  • 서버 루트 권한 부여

    $ sudo chown -R www-data:www-data /var/www/wordpress

    $ sudo usermod -a -G www-data www-data



    이제 자신이 지정한 도메인으로 접속해보자. 밑의 사진과 같은 화면이 뜬다면 설정 끝!



    Ps. 설치를 하며 수많은 오류가 있을 수 있습니다. 그럴때는 log를 참조하시는 것을 추천드립니다.

            /var/log/nginx/error.log


    반응형
    블로그카우, 티스토리 애드센스 강의

    웹 개발자가 알려주는 수익형 블로그 고속 성장 A to Z

    댓글
    위쪽 화살표
    로딩바