1. Nginx
Nginx는 Apache와 다르게 비동기서버라서 퍼포먼스가 더 좋고 메모리 소비량도 적다.
* nginx 설치
$ sudo apt install nginx
이 시점에서 서버의 80번 포트로 접속할수 있게 된다.
2. PHP
* Nginx는 PHP를 네이티브로 지원하지 않으므로 Fastcgi Process Manager(FPM)로 구현된 PHP를 설치한다
$ sudo apt install php-fpm
$ sudo nano /etc/nginx/sites-available/default
에서
index index.html index.htm index.nginx-debian.html;
→ index index.html index.htm index.php;
로 수정.
#location ~ \.php$ { # include snippets/fastcgi-php.conf; # # # With php5-cgi alone: # fastcgi_pass 127.0.0.1:9000; # # With php5-fpm: # fastcgi_pass unix:/var/run/php/php7.0-fpm.sock; #}
에서
location ~ \.php$ { include snippets/fastcgi-php.conf; fastcgi_pass unix:/var/run/php/php7.0-fpm.sock; }
로 수정.
* 서비스 재시작
$ sudo service nginx reload
3. MariaDB 설치
$ sudo apt install mysql-server php-mysql
* 초기셋업
$ sudo mysql_secure_installation
Enter current password for root (enter for none): 엔터
Set root password? [Y/n] y
New password: 패스워드 입력
Remove anonymous users? [Y/n] y
Disallow root login remotely? [Y/n] y
Remove test database and access to it? [Y/n] y
Reload privilege tables now? [Y/n] y
* 로그인
$ sudo mysql -uroot -p
* 워드프레스용 DB 생성
create database wordpress;
* 워드프레스 DB에 접근할 수 있는 유저 생성
create user 사용자이름 identified by '패스워드';
* 생성한 유저에 워드프레스 DB에 대한 모든 권한을 부여
grant all privileges on wordpress.* to '사용자이름'@'localhost' identified by '패스워드';
* 권한변경을 적용
flush privileges;
4. 워드프레스 설치
* html 폴더 안의 모든 파일 삭제
$ cd /var/www/html/
$ sudo rm *
* 워드프레스 다운로드
$ sudo wget http://wordpress.org/latest.tar.gz
* 다운로드한 파일의 압축해제
$ sudo tar xzf latest.tar.gz
* 워드프레스 폴더안의 모든파일을 현재 폴더로 이동
$ sudo mv wordpress/* .
* 압축파일과 빈 워드프레스 폴더를 삭제
$ sudo rm -rf wordpress latest.tar.gz
* 워드프레스 셋업
http://localhost 로 접속하여 웹브라우저 상에서 셋업
5. SSL 설정
* Let's encrypt 설치
$ sudo apt install letsencrypt
* HTTP-based DCV 방식으로 서버 인증
$ sudo letsencrypt certonly --webroot --webroot-path=/var/www/html -d test.com -d www.test.com
* 인증성공시 인증서 발급
/etc/letsencrypt/live/test.com/ 폴더에 인증서가 생성된다.
cert.pem(인증서 파일), chain.pem(인증서 발급자 파일),
fullchain.pem(cert.pem 과 chain.pen 을 하나로 합쳐놓은 파일),
privkey.pem(인증암호를 해독하는 개인키)
Apache2는 cert.pem, chain.pem, privkey.pem 을 사용.
Nginx는 fullchain.pem, privkey.pem 을 사용.
* Nginx 설정
/etc/nginx/sites-available/default를 다음과 같이 수정한다.
server { listen 80 default_server; listen [::]:80 default_server; server_name www.test.com test.com; return 301 https://$server_name$request_uri; } server { listen 443 default_server; listen [::]:443 default_server; root /var/www/html; index index.html index.htm index.php; server_name _; location / { try_files $uri $uri/ =404; } ssl on; ssl_certificate /etc/letsencrypt/live/test.com/fullchain.pem; ssl_certificate_key /etc/letsencrypt/live/test.com/privkey.pem; ssl_ciphers HIGH:!aNULL:!MD5; location ~ \.php$ { include snippets/fastcgi-php.conf; fastcgi_pass unix:/var/run/php/php7.0-fpm.sock; } }
* 인증서 갱신
$ sudo letsencrypt renew
* 인증서 삭제
$ certbot revoke --cert-path /etc/letsencrypt/live/test.com/cert.pem
$ certbot delete --cert-name test.com
<개발 / Linux> 글갈래의 다른 글
- [Raspberry Pi] Nginx 가상호스트 설정하기 2019/04/11
- [Raspberry Pi] SD카드 제거없이 백업 2019/04/09
- [Raspberry Pi] SD카드 없이 USB 장치로 부팅 2019/04/09
- [Linux] Filesystem Hierarchy Standard (FHS) 2019/04/09
- [Raspberry Pi] LEMP 셋업후 워드프레스 설치 2019/04/09
- [Raspberry Pi] 한글환경 셋업 2019/04/09
- [Raspberry Pi] 방화벽 설정 2019/04/09
- [Raspberry Pi] 스왑파일 설정하기 2019/04/09
- [Raspberry Pi] 원격접속 세팅 2019/04/08
- [linux] synology에 gogs 설치하고 xcode에서 액세스하기 2019/02/08
Comment on this post!