본문 바로가기

개발노트/MAC

[OS X, 맥 OS X] 맥에 wordpress 설치형 블로그, 설치형 사이트 설치하기.

1. 최신 wordpress 설치


$ brew install wp-cli


2. 워드프레스를 설치할 디렉토리 생성

/home 에 생성할 것이기 때문에 우선 $ sudo vi /etc/auto_master 를 입력하고 /home 으로 시작하는 줄을 주석처리하고 저장한다.(/home 디렉토리 하위에 디렉토리가 생성되지 않았기 때문)


터미널을 종료(세션을 끊음)하고 다시 터미널을 열어서 아래 명령어로 원하는 디렉토리를 만든다.


$ sudo mkdir -p wordpress 

$ cd worldpress

$ sudo mkdir -p webapp


/home 경로에 만들어서 워드프레스를 설치하려고 하니 경고가 뜨는데, 보안상 이슈가 있는 듯 해서 디렉토리를 바꿔주었다.


$ cd ~

$ sudo mkdir -p wordpress

$ cd wordpress

$ sudo mkdir -p webapp


3. mariaDB 에 계정과 데이터베이스를 생성한다.


$ mysql -u root -p

[MariaDB]> create user 'wordpress'@'localhost' IDENTIFIED BY 'password';

[MariaDB]> create database wordpress;

[MariaDB]> GRANT ALL ON wordpress.* TO 'wordpress'@'localhost';



4. 내가 만든 디렉토리로 이동하고 워드프레스를 설치한다.


$ sudo chmod 775 webapp/

$ cd /home/wordpress/webapp

$ cd webapp/

$ wp core download

wp core config --dbname=wordpress --dbuser=wordpress --dbpass=password

wp core install --url=http://<도메인or아이피>/ --title='<제목>' --admin_user=<사용할 관리자계정 아이디> --admin_password=<사용할 패스워드> --admin_email=<관리자 이메일 주소>



----- 2017-01-17 수정사항

워드프레스 설치 경로가 위 처럼 하니까 워드프레스가 로드가 안 되었다.

/var/www/wordpress/ 라고 경로를 만들고 거기에 워드프레스를 설치하니 워드프레스를 볼 수 있었다.


----- 2017-01-20 수정사항

맥(OS X)에서는 워드프레스 설치 경로를 선택할 때 아주 신중히 해야할 것 같다.

sudo 로 명령어를 실행해도 permission denied 가 되는 경우도 있었고, 그럴 땐 리커버리 모드로 부팅한 다음 csrutil disable 명령어로 SIP(System Integration Protection)을 일시적으로 끄고 난 다음 해야하는 등의 여러가지 문제가 있었다. 근데 가장 큰 문제는 그런 번거로운 과정을 거치고 나서도 문제가 해결되지 않았다.


아래는 문제 사항과 해결 과정을 대략적으로 기억나는대로 기록해본 것.


1. nginx 재설치

=> 깃허브에서 가져온 설정때문에 뭔가 내가 하고자 하는 설정과 충돌나는 부분이 있을 것 같아서 재설치 해주었다.

결과적으로는 재설치 하지 않아도 됐었다. 하지만 nginx의 default 설정에서 조금씩 바꾸면서 해봤던 게 nginx.conf 설정 파일을 다루는 데 많은 도움이 되었다.


2. wordpress 재설치

=> /var/www/wordpress 에다가 wp core download 를 하고 wp core config 및 wp core install 과정을 적어도 3번이상은 해봤다. 안 됐다.


3. /var/www/ 경로에 리컬시브하게(recursively) 755 권한 주기.

=> /var/ 디렉토리는 심볼릭링크였는데 private/var/ 로서 도대체 private/var/ 로 권한을 주려고 해도, /private/var/ 로 권한을 주려고 해도 안 됐었다.


4. 최종적으로 /usr/local/var/www/ 에다가 wp core 를 다운로드하고, 설정하고, 설치하였다.

=> 404, 502를 뱉어냈지만 이건 금방 해결하였다.




본 과정을 진행하면서 보았던 에러는 403 forbidden, 404 not found, 502 bad gateway 였다.


403 forbidden : 이걸 해결하는 데 가장 오래 걸렸고 힘들었던 것 같다. 결국 wp core 설치 디렉토리 패스(path) 문제였고 /usr/local/var/www/ 에 설치를 해주니 해결되었다. 이 때 특이했던 점은 html, txt, md 확장자를 가진 파일은 정상적으로 웹브라우저에서 열렸는데 php 파일은 403 forbidden 을 뱉어내는 것이었다.


404 not found : document root 를 잘못 설정해서 나왔던 것 같다.


502 bad gateway : 여러번의 재부팅과 리커버리 모드를 왔다갔다 하다보니 php-fpm 이 실행되지 않는 상태였었다. php-fpm 을 실행시켜주니 잘 되었다!



 맥에 wordpress 설치형 블로그, 설치형 사이트 설치하기 과정을 최종적으로 아래에 다시 순서대로 기록함.



1. 최신 wordpress 설치


$ brew install wp-cli



2. 워드프레스를 설치할 디렉토리 생성


$ sudo mkdir -p /usr/local/var/www/wordpress/



3. mariaDB 에 계정과 데이터베이스를 생성한다.


$ mysql -u root -p

[MariaDB]> create user 'wordpress'@'localhost' IDENTIFIED BY 'password';

[MariaDB]> create database wordpress;

[MariaDB]> GRANT ALL ON wordpress.* TO 'wordpress'@'localhost';



4. 내가 만든 디렉토리로 이동하고 워드프레스를 설치한다.


($ sudo chmod -r 755 /usr/        : 만약 /usr 이하 디렉토리나 파일의 권한이 755가 아닐 경우 이 명령을 실행한다.)


$ cd /usr/local/var/www/wordpress/

$ wp core download

wp core config --dbname=wordpress --dbuser=wordpress --dbpass=<password>

wp core install --url=http://<도메인or아이피>/ --title='<제목>' --admin_user=<사용할 관리자계정 아이디> --admin_password=<사용할 패스워드> --admin_email=<관리자 이메일 주소>        : 도메인or아이피에는 localhost 로 적은 사람도 있었고 도메인을 적는 사람도 있었다. 나는 no-ip에서 제공받아 사용하는 DDNS 도메인 주소를 적어주었음.


5. nginx를 설정한다.

/usr/local/etc/nginx/nginx.conf      (단 도메인 주소 제외하고 필터링 없이 그대로 적어놨음. 고뇌의 흔적이 주석에... -_- 이게 뭐라고)

#user  staff;

#user  root;

#user  nobody;

#user  nginx;


worker_processes  1;


error_log /usr/local/etc/nginx/logs/error.log debug;


pid        /usr/local/var/run/nginx.pid;



events {

    worker_connections  1024;

}



http {

    include       mime.types;

    default_type  application/octet-stream;


    log_format  main  '$remote_addr - $remote_user [$time_local] "$request" '

                      '$status $body_bytes_sent "$http_referer" '

                      '"$http_user_agent" "$http_x_forwarded_for"';


    access_log  /usr/local/etc/nginx/logs/access.log  main;


    sendfile        on;

    tcp_nopush     on;


    #keepalive_timeout  0;

    keepalive_timeout  65;


    #gzip  on;

    #gzip  on;


    server {

        listen       80;

        server_name  localhost;

        root        /usr/local/var/www/;

        index    index.html index.htm index.php;


        #charset koi8-r;


        access_log  /usr/local/etc/nginx/logs/host.access.log  main;


        location / {

            #include /usr/local/etc/nginx/conf.d/php-fpm;

            #root   /var/www/wordpress/;

            index  index.html index.htm;

            #allow   127.0.0.1;

            #allow   all;

            try_files $uri /index.php?$args;

            #autoindex on;


            location ~ \.php$ {

                try_files      $uri = 404;

                fastcgi_pass   127.0.0.1:9000;

                fastcgi_index  index.php;

                fastcgi_param  SCRIPT_FILENAME $document_root$fastcgi_script_name;

                include        fastcgi_params;

            }

        }


        location /wordpress {

            alias /var/www/wordpress;

            index  index.php;

        }


        location = /info {

            allow   127.0.0.1;

            deny    all;

            rewrite (.*) /.info.php;

        }


        error_page  404              /404.html;


        # redirect server error pages to the static page /50x.html

        #

        error_page   500 502 503 504  /50x.html;

        location = /50x.html {

            root   /var/www/;

        }


        # proxy the PHP scripts to Apache listening on 127.0.0.1:80

        #

        #location ~ \.php$ {

        #    proxy_pass   http://127.0.0.1;

        #}


        # pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000

        #

        location ~ \.php$ {

            #root           html;

            try_files      $uri = 404;

            fastcgi_pass   127.0.0.1:9000;

            fastcgi_index  index.php;

            fastcgi_param  SCRIPT_FILENAME  /scripts$fastcgi_script_name;

            include        fastcgi_params;

        }


        # deny access to .htaccess files, if Apache's document root

        # concurs with nginx's one

        #

        location ~ /\.ht {

            deny  all;

        }

    }



    # another virtual host using mix of IP-, name-, and port-based configuration

    #

    #server {

    #    listen       8000;

    #    listen       somename:8080;

    #    server_name  somename  alias  another.alias;


    #    location / {

    #        root   html;

    #        index  index.html index.htm;

    #    }

    #}



    # HTTPS server

    #

    #server {

    #    listen       443 ssl;

    #    server_name  localhost;


    #    ssl_certificate      cert.pem;

    #    ssl_certificate_key  cert.key;


    #    ssl_session_cache    shared:SSL:1m;

    #    ssl_session_timeout  5m;


    #    ssl_ciphers  HIGH:!aNULL:!MD5;

    #    ssl_prefer_server_ciphers  on;


    #    location / {

    #        root   html;

    #        index  index.html index.htm;

    #    }

    #}

    include servers/*;

}



<autoindex on 관련된 내용>

autoindex on 을 하지 않으면 http://localhost/wp-admin 에서 403 forbidden 이 나왔었다.

아래는 그 해결방법.





6. http://localhost/wordpress 에 접속한다. 아래처럼 잘 나왔을 때 감격이...




소감....)

실제 블로그나 사이트를 운영하기 위해 만든 건 아니지만, 맥에서 nginx, php, mariaDB 를 설치하고 운영하기위해 참고하는 레퍼런스가 생각보다 적었고, 회사에서 프론트엔드 개발자들이 주로 NPM을 이용해 개발을 하기 때문에 나도 알아두면 좋을 것 같아서 해본 것인데 막상 하는 도중에 막힌 부분들이 많아서 꽤나 오기가 생겼었다. 최종적으로 잘 된 것을 보니 기뻤고, 회사에서 프론트엔드 개발자들과 대화할 수 있는 범위가 좀 더 넓어지겠거니 싶다.


반응형