macOS – WordPress 설치 #3 – nginx

금일 리눅스 -> macOS 서버 이전을 하며 진행한 이력을 기록해본다.

  • 설치
    – macOS의 패키지 매니저는 brew를 사용하며, brew로 nginx 를 설치한다.
HumingCubis-iMac:~ $ brew install nginx
  • 설정 #1
    – path : /usr/local/etc/nginx/nginx.conf
    – https용 ssl 은 아직 미적용 상태 (주석처리 되어있음)
user  맥계정;
worker_processes  auto;
pid        nginx.pid;
#include /usr/local/etc/nginx/modules-enabled/*.conf;

events {
    worker_connections  1024;
}

http {
  #--------------------------------------
  # Basic Settings
  #--------------------------------------
  include       mime.types;
  default_type  application/octet-stream;

  sendfile        on;
  tcp_nopush     on;
  tcp_nodelay on;
  keepalive_timeout  65;
  types_hash_max_size 2048;

  #--------------------------------------
  # SSL Settings
  #--------------------------------------
  #ssl_protocols TLSv1 TLSv1.1 TLSv1.2 TLSv1.3;
  #ssl_prefer_server_ciphers on;

  #--------------------------------------
  # Logging Settings
  #--------------------------------------
  access_log  /로그디렉토리/access.log;
  error_log   /로그디렉토리/error.log;

  #--------------------------------------
  # Gzip Settings
  #--------------------------------------
  gzip on;
  gzip_disable "msie6";
  gzip_vary on;
  gzip_proxied any;
  gzip_comp_level 6;
  gzip_buffers 16 8k;
  gzip_http_version 1.1;
  gzip_types text/plain text/css application/json application/javascript text/xml application/xml application/xml+rss text/javascript;

  #--------------------------------------
  # Virtual host configs
  #--------------------------------------
  include /usr/local/etc/nginx/sites-enabled/blog/*;
}
  • 설정 #2
    – path : /usr/local/etc/nginx/sites-enabled
HumingCubis-iMac:sites-enabled $ ls -al
total 0
drwxr-xr-x   5 huming  admin  160 Oct 24 00:46 .
drwxr-xr-x  22 huming  admin  704 Oct 24 21:37 ..
lrwxr-xr-x   1 huming  admin   41 Oct 24 00:46 blog -> /usr/local/etc/nginx/sites-available/blog
lrwxr-xr-x   1 huming  admin   44 Oct 24 00:46 default -> /usr/local/etc/nginx/sites-available/default
lrwxr-xr-x   1 huming  admin   43 Oct 24 00:46 webdav -> /usr/local/etc/nginx/sites-available/webdav
  • 블로그 설정
    – ssl 관련설정은 주석처리 되어있음
##################################
# WORDPRESS NGINX CONFIGURATIONS
##################################

#server {
#  listen 80 default_server;
#  listen [::]:80 default_server;
#  return 301 https://$host$request_uri;
#}

server {
    listen 80;
    #listen 443 ssl;
    server_name leezakka.asuscomm.com;

    root 워드프레스 디렉토리 경로;

    # Cert
    #ssl_certificate     CERT경로/cert.pem;
    #ssl_certificate_key CERT경로/key.pem;
    #ssl_session_cache   shared:SSL:1m;
    #ssl_session_timeout 5m;
    #ssl_ciphers         HIGH:!aNULL:!MD5;

    # Max upload size
    client_max_body_size 64M;

    # Specify a charset
    charset utf-8;

    # Attempt to rewrite wordpress in sub directory
    rewrite ^/wp/([_0-9a-zA-Z-]+)/(xmlrpc\.php|wp-[0-9a-z-]+\.php) /wp/$2;
    rewrite ^/wp/([_0-9a-zA-Z-]+)/(wp-(admin|content|includes).*) /wp/$2;

    # Add trailing slash to */wp-admin requests
    rewrite /wp-admin$ $scheme://$host$uri/ permanent;

    # Root directory for WordPress
    location / {
        # For permalink change
        try_files $uri $uri/ /index.php?$args;
        # First attempt to serve request as file, then
        index index.html index.htm index.php;
    }

    # For PHP files to pass all .php onto a php-fpm or php-cgi server
    location ~ \.php$ {
        try_files                       $uri = 404;
        include                         fastcgi.conf;
        include                         fastcgi_params;
        fastcgi_pass                    127.0.0.1:설정한 phpfpm포트;
        fastcgi_split_path_info         ^(.+\.php)(/.+)$;
        fastcgi_read_timeout            3600s;
        fastcgi_buffer_size             128k;
        fastcgi_buffers                 4 128k;
        fastcgi_param                   SCRIPT_FILENAME $document_root/$fastcgi_script_name;
        fastcgi_index                   index.php;

    }

    location = /robots.txt {
        allow all;
        log_not_found off;
        access_log off;
    }

    location ~* \.(js|css|png|jpg|jpeg|gif|ico)$ {
        expires max;
        log_not_found off;
    }

    # This prevents hidden files (begining with a period) from being served
    location ~ /\. {
        #access_log                      off;
        #log_not_found                   off;
        #deny                            all;
    }

    # Send Expires headers and turn off 404 logging
    location ~* ^.+.(xml|ogg|ogv|svg|svgz|eot|otf|woff|mp4|ttf|css|rss|atom|js|jpg|jpeg|gif|png|ico|zip|tgz|gz|rar|bz2|doc|xls|exe|ppt|tar|mid|midi|wav|bmp|rtf)$ {
        access_log                      off;
        log_not_found                   off;
        expires                         max;
    }

    # Rewrite multisite '.../wp-.*' and '.../*.php'.
    if (!-e $request_filename) {
        rewrite /wp-admin$ $scheme://$host$uri/ permanent;
        rewrite ^/[_0-9a-zA-Z-]+(/wp-.*) /wp$1 last;
        rewrite ^/[_0-9a-zA-Z-]+(/.*\.php)$ /wp$1 last;
    }
}
  • 서비스 등록
    – brew 에 등록하여 재기동시 자동 시작
  • mariadb / php / nginx 확인 완료
HumingCubis-iMac:wordpress $ brew services start nginx
HumingCubis-iMac:wordpress $ brew services list
Name    Status  User   File
mariadb started huming ~/Library/LaunchAgents/homebrew.mxcl.mariadb.plist
nginx   started root   ~/Library/LaunchAgents/homebrew.mxcl.nginx.plist
php     started huming ~/Library/LaunchAgents/homebrew.mxcl.php.plist

답글 남기기