본문 바로가기
IT/PHP,WORDPRESS

wordpress와 nginx 연동하기

by 골든크랩 2022. 2. 6.
728x90
반응형

ubuntu : 20.04

 

사전작업...먼저 nginx와 mysql 설치를 한다.

 

1. nginx 설치하기

 

아래 글 읽고 정리함. 장고와 연동하는것도 있는 듯 함.

참고) https://twpower.github.io/39-install-nginx-on-ubuntu-by-using-apt-get-and-brief-explanation

 

1. sudo apt update

2. sudo apt upgrade

3. sudo apt install nginx

4. cd /etc/init.d

5. sudo service nginx start/restart/stop/reload

6. sudo service nginx status

7. curl localhost:80

8. sudo find / -name nginx.conf 2> /dev/null       ==> /etc/nginx/nginx.conf

9. sudo find / -name sites-enabled 2> /dev/null  ==> /etc/nginx/sites-enabled

10. sudo find / -name fastcgi_params 2> /dev/null ==> /etc/nginx/fastcgi_params

11. netstat -lntp

=================================================================================

 

2. mysql 설치

 

1. sudo apt-get update

2. sudo apt-get install mysql-server

3. sudo ufw allow mysql

4. sudo systemctl start mysql

5. 이건하지말자, 시스템 재기동시 자동시작인데...느려질까봐... : sudo systemctl enable mysql

6. sudo /usr/bin/mysql -u root -p

 

 

=================================================================================

 

 

 

 

워드프레스 설치.....다음 사이트를 참고함..

 

참고)

https://ubunlog.com/ko/nginx%EA%B0%80%EC%9E%88%EB%8A%94-wordpress%EA%B0%80-%EC%9A%B0%EB%B6%84%ED%88%AC-20-04%EC%97%90-%EC%84%A4%EC%B9%98%EB%90%A8/

 

Nginx로 Wordpress, Ubuntu 20.04에 로컬로이 CMS 설치

다음 기사에서는 Ubuntu 20.04에서 로컬로 Nginx와 함께 Wordpress를 설치하는 방법을 살펴볼 것입니다.

ubunlog.com

 

터미널에서 다음 명령어 실행.

1. php 확장 설치

--------------------------------------------------------------------------------------------------------------------------------------------------------

sudo apt update && sudo apt install php-dom php-simplexml php-ssh2 php-xml php-xmlreader php-curl php-exif php-ftp php-gd php-iconv php-imagick php-json php-mbstring php-posix php-sockets php-tokenizer

 

2. wordpress용 nginx 서버블록 설치

sudo vim /etc/nginx/conf.d/www.wordpress.local.conf

아래 내용을 붙여 넣는다.
 
server {
        server_name www.wordpress.local;
        root /sites/www.wordpress.local/public_html/;
 
        index index.html index.php;
 
        access_log /sites/www.wordpress.local/logs/access.log;
        error_log /sites/www.wordpress.local/logs/error.log;
 
        # No permitir que las páginas se representen en un iframe en dominios externos
        add_header X-Frame-Options "SAMEORIGIN";
 
        # Prevención MIME
        add_header X-Content-Type-Options "nosniff";
 
        # Habilitar el filtro de secuencias de comandos entre sitios en los navegadores compatibles
        add_header X-Xss-Protection "1; mode=block";
 
        # Evitar el acceso a archivos ocultos
        location ~* /\.(?!well-known\/) {
                deny all;
        }
 
        # Evitar el acceso a ciertas extensiones de archivo
        location ~\.(ini|log|conf)$ {
                deny all;
        }
 
        # Habilitar enlaces permanentes de WordPress
        location / {
                try_files $uri $uri/ /index.php?$args;
        }
 
        location ~ \.php$ {
        include /etc/nginx/fastcgi_params;
        fastcgi_pass 127.0.0.1:9000;
        fastcgi_index index.php;
        fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
        }
 
}

 

3. 이제부터 문서 디렉토리와 레코드 디렉토리 생성

sudo mkdir -p /sites/www.wordpress.local/public_html/

sudo mkdir -p /sites/www.wordpress.local/logs/

 

4. nginx 구성파일 확인

sudo nginx -t

 

5. nginx 서비스 다시 시작

sudo systemctl restart nginx.service

 

 

================================================================

wordpress 용 db 생성

 

1. sudo /usr/bin/mysql -u root -p

2. CREATE DATABASE wordpress;

3. CREATE USER 'wpusuario'@'localhost' IDENTIFIED BY '123password';

4. GRANT ALL PRIVILEGES ON wordpress.* TO 'wpusuario'@'localhost';

5. use wordpress;

 

 

================================================================

wordpress 설치

 

1. wget http://wordpress.org/latest.tar.gz

2. tar -zxvf latest.tar.gz

3. sudo mv wordpress/* /sites/www.wordpress.local/public_html/

4. sudo chown -R www-data:www-data /sites/www.wordpress.local/public_html/

5. sudo chown -R www-data:www-data /sites/www.wordpress.local/logs/

 

6. sudo vim /etc/hosts  (내 로컬 pc ip 추가)

192.168.1.39    www.wordpress.local site

 

7. 테스트..사이트 방문

www.wordpress.local/

 

 

 

728x90
반응형

댓글