본문 바로가기
컴퓨터

ubuntu Server(raspberry Pi)에 Nginx php mariaDB 설치

by 촐초리 2020. 2. 29.
반응형

apache php mysql 이 유행이었는데

이제는 nginx php mariaDB로 설치를 해 봤다 

 

sudo apt install nginx
sudo systemctl status nginx
sudo systemctl start nginx
sudo ufw app list
sudo ufw app info "Nginx Full"
sudo ufw allow in "Nginx Full"
sudo apt install mariadb-server mariadb-client
sudo systemctl status mysql
mysql_secure_installation
sudo mysql -u root
use mysql;
update user set plugin='' where User='root';
mysql_secure_installation
sudo apt-get install php-fpm php-mysql
sudo vi /etc/php/7.2/fpm/php.ini
;cgi.fix_pathinfo=1 => cgi.fix_pathinfo=0
sudo systemctl status php7.2-fpm
sudo vi /etc/nginx/sites-available/default

add index.php

location ~ \.php$ {
include snippets/fastcgi-php.conf;
#
# # With php-fpm (or other unix sockets):
fastcgi_pass unix:/run/php/php7.2-fpm.sock;
# # With php-cgi (or other tcp sockets):
# fastcgi_pass 127.0.0.1:9000;
}
# deny access to .htaccess files, if Apache's document root
 # concurs with nginx's one
 #
 location ~ /\.ht {
 deny all;
 }
}

sudo nginx -t
sudo systemctl restart nginx
sudo apt-cache search php- | less
sudo apt-cache show php-gd
sudo apt-get install php-gd

sudo apt-get install php*

설치완료 후 SSL을 적용해 봤다

/etc/nginx/ssl/ 폴더를 만들어서 

https://cholchori.tistory.com/2041

 

윈도 환경에서 Asus 공유기 Let's Encrypt SSL 인증서 받기

asus공유기에서 Let's Encrypte SSL 인증서를 지금까지 잘 사용했었는데 acme v1 이 이제 더이상 지원되지 않으면서 아무리 갱신을 해도 이렇게 192.168.1.1 형태의 로컬 인증서만 받아지고 제대로 작동이 되지..

cholchori.tistory.com

에서 만든 SSL 인증서 2개를 복사해둔다

 

다음으로 /etc/nginx/sites-available/default 파일을 편집한다

기존의 80 으로만 되어 있는 부분에 다음과 같이 편집을 한다

 

server {
  listen 80;
  server_name domain.com;
  rewrite ^ https://$server_name$request_uri? permanent;
}

server {
        # listen 80 default_server;
        # listen [::]:80 default_server;

        listen 443 ssl default_server;
        listen [::]:443 ssl default_server;

        ssl_certificate /etc/nginx/ssl/****-chain.pem;
        ssl_certificate_key /etc/nginx/ssl/****-key.pem;
        ssl_prefer_server_ciphers on;

        server_name domain.com;

80으로 들어오는 요청은 모두 SSL로 전환하고

SSL 인증서를 복사한 파일로 정확하게 지정해 주면 완료

 

반응형