본문 바로가기

컴퓨터/노트북/인터넷

IT 컴퓨터 기기를 좋아하는 사람들의 모임방

단축키

Prev이전 문서

Next다음 문서

수정 삭제

단축키

Prev이전 문서

Next다음 문서

수정 삭제
Extra Form

우분투 서버에 nginx 최신 안정버전, php 7.2.x, mariadb 10.3.x 버전 설치를 위한 스크립트이다. 아래 스크립트트를 server.sh 등으로 저장한 후 실행 권한을 준 후 실행한다. 사용자명, 비밀번호, 도메인을 입력받아 설치를 진행하며 DB 생성을 위해 DB root 비밀번호 입력이 필요하다. 스크립트는 우분투 서버 16.04 LTS(64비트)에서 테스트 했다.

 

#!/bin/bash
# ================================================================== #
# nginx, php 7.2.x, mariadb 10.3.x install shell script for Ubuntu
# ================================================================== #
# Copyright (c) 2018 Seongho Jang https://ncube.net
# This script is licensed under MIT
# ================================================================== #
# Input username, password, domain
while [[ $username == '' ]]
do
    read -p "Enter Username: " username
done
while [[ $password == '' ]]
do
    read -s -p "Enter Password: " password
    echo -e ""
done
while [[ $domain == '' ]]
do
    read -p "Enter domain: " domain
done
# Update package
sudo apt-get update
sudo apt-get -y upgrade
# Set locale
#sudo dpkg-reconfigure locales
sudo apt-get -y install language-pack-ko-base language-pack-ko
sudo locale-gen ko_KR.UTF-8
sudo locale-gen en_US.UTF-8
sudo localectl set-locale LANG=en_US.UTF-8 LANGUAGE="en_US:en"
sudo source /etc/default/locale
# Install mail
sudo apt-get -y install sendmail
sudo apt-get -y install mailutils
# Create user
sudo groupadd "$username"
sudo useradd -g "$username" -s /bin/bash -m "$username"
echo -e "$passwordn$passwordn" | sudo passwd "$username"
# Make directory
sudo mkdir -p /home/"$username"/www
sudo chown "$username"."$username" /home/"$username"/www
# Set timezone
sudo timedatectl set-timezone Asia/Seoul
sudo apt-get install -y rdate
sudo /usr/bin/rdate -s time.bora.net; /sbin/hwclock --systohc
# Install MariaDB 10.3.x
sudo apt-get install software-properties-common
sudo apt-key adv --recv-keys --keyserver hkp://keyserver.ubuntu.com:80 0xF1656F24C74CD1D8
sudo add-apt-repository 'deb [arch=amd64,arm64,i386,ppc64el] http://ftp.kaist.ac.kr/mariadb/repo/10.3/ubuntu '$(lsb_release -cs)' main'
sudo apt-get update
sudo apt-get -y install mariadb-server
# Install nginx latest stable version
sudo sh -c "echo 'deb http://nginx.org/packages/ubuntu/ `lsb_release -cs` nginx' >> /etc/apt/sources.list"
sudo sh -c "echo 'deb-src http://nginx.org/packages/ubuntu/ `lsb_release -cs` nginx' >> /etc/apt/sources.list"
curl http://nginx.org/keys/nginx_signing.key | apt-key add -
sudo apt-get update
sudo apt-get install -y nginx
# Install PHP 7.2.x
sudo apt-get -y install python-software-properties
sudo add-apt-repository ppa:ondrej/php
sudo apt-get update
sudo apt-get install -y php7.2-cli php7.2-fpm php7.2-bcmath php7.2-bz2 php7.2-common php7.2-curl php7.2-dba php7.2-gd php7.2-json php7.2-mbstring php7.2-mysql php7.2-opcache php7.2-readline php7.2-soap php7.2-xml php7.2-xmlrpc php7.2-zip
# nginx configure
sudo service nginx stop
sudo cat > /etc/nginx/conf.d/"$domain".conf <<WEBCONF
server {
    listen 80 default_server ;
    server_name $domain www.$domain ;
    root /home/$username/www ;
    access_log /var/log/nginx/$domain.access.log ;
    error_log  /var/log/nginx/$domain.error.log warn ;
    location / {
        index index.php index.html index.htm ;
    }
    
    include /etc/nginx/php.conf ;
    
}
WEBCONF
# Create database
sudo service mysql restart
while [[ $dbpassword == '' ]]
do
    read -s -p "Enter DB Root Password: " dbpassword
    echo -e ""
done
while ! mysql -u root -p$dbpassword  -e ";" ; do
     read -s -p "Can't connect, Enter DB Root Password: " dbpassword
     echo -e ""
done
mysql -uroot -p${dbpassword} -e "CREATE DATABASE ${username} DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;"
mysql -uroot -p${dbpassword} -e "CREATE USER ${username}@localhost IDENTIFIED BY '${password}';"
mysql -uroot -p${dbpassword} -e "GRANT ALL PRIVILEGES ON ${username}.* TO '${username}'@'localhost';"
mysql -uroot -p${dbpassword} -e "FLUSH PRIVILEGES;"
# Daemon start
echo -e ""
sudo nginx -t
sudo php-fpm7.2 -t
sudo service php7.2-fpm restart
sudo service nginx restart
echo "Complete!"

 

 

 

/etc/nginx/php.conf 파일의 내용은 아래와 같다.

 

 

# Block dot file (.htaccess .htpasswd .svn .git .env and so on.)
location ~ /. {
    deny all;
}
# Block (log file, binary, certificate, shell script, sql dump file) access.
location ~* .(log|binary|pem|enc|crt|conf|cnf|sql|sh|key)$ {
    deny all;
}
# Block access
location ~* (composer.json|contributing.md|license.txt|readme.rst|readme.md|readme.txt|copyright|artisan|gulpfile.js|package.json|phpunit.xml)$ {
    deny all;
}
location = /favicon.ico {
    log_not_found off;
    access_log off;
}
location = /robots.txt {
    log_not_found off;
    access_log off;
}
# Block .php file inside upload folder. uploads(wp), files(drupal), data(gnuboard).
location ~* /(?:uploads|default/files|data)/.*.php$ {
    deny all;
}
location ~ [^/].php(/|$) {
    fastcgi_split_path_info ^(.+?.php)(/.*)$;
    if (!-f $document_root$fastcgi_script_name) {
        return 404;
    }
    # flush
    fastcgi_keep_conn on;
    gzip off;
    proxy_buffering off;
    include fastcgi_params;
    fastcgi_param  SCRIPT_FILENAME    $document_root$fastcgi_script_name;
    fastcgi_read_timeout 3600;
    fastcgi_pass unix:/run/php/php7.2-fpm.sock;
    fastcgi_index index.php;       
}

 


컴퓨터/노트북/인터넷

IT 컴퓨터 기기를 좋아하는 사람들의 모임방

  1. 구글 최신 뉴스

    날짜2024.12.12 카테고리뉴스 읽음1385
    read more
  2. 아 진짜 요새 SKT 해킹 뭐시기 때문에 신경 쓰여 죽겠어 ㅠㅠ

    날짜2025.05.20 카테고리일반 읽음237
    read more
  3. 사랑LOVE 포인트 만렙! 도전

    날짜2025.03.19 카테고리 읽음4669
    read more
  4. 🚨(뉴비필독) 전체공지 & 포인트안내

    날짜2024.11.04 카테고리 읽음25850
    read more
  5. URL만 붙여넣으면 끝! 임베드 기능

    날짜2025.01.21 카테고리 읽음20432
    read more
  6. Intel 12세대 i3-12100YouTube 10비트 HDR 8K60 AV1 비디오를 원활하게 재생가능?

    날짜2024.11.10 조회수4540
    Read More
  7. 블루투스 헤드셋 질문좀~

    날짜2021.01.31 조회수49
    Read More
  8. e4000이랑 560s랑 음질차이

    날짜2021.01.28 조회수70
    Read More
  9. 未检测到我的手机MTP。

    날짜2019.12.24 조회수29
    Read More
  10. amd 라이젠 1700 > 인텔 i5 12400f cpu 변경후 드라이브 오류

    날짜2022.06.14 조회수1122
    Read More
  11. 윈도우 11 에러 중에 이런 종류가 있나요?

    날짜2022.06.14 조회수1085
    Read More
  12. 마소계정에 정품인증

    날짜2022.06.14 조회수420
    Read More
  13. 4k나 1080p 동영상 보면 렉이 걸리는데...

    날짜2022.06.14 조회수482
    Read More
  14. 제가쓰던 놋북 윈도우가 리테일이래요 그러니까 fpp 윈도우라는거 맞죠??

    날짜2022.06.14 조회수401
    Read More
  15. 윈도우 10 왜 버벅일까요..?

    날짜2022.06.14 조회수348
    Read More
  16. 오피스 정품 판매 맞을까요?

    날짜2022.06.14 조회수169
    Read More
  17. 윈도우11 더 많은 옵션 항상사용하는 방법

    날짜2022.06.09 조회수262
    Read More
  18. 윈도우 11 22H2 RTM 빌드 확정됨

    날짜2022.05.30 조회수223
    Read More
  19. 해킹 대회에서 윈도우 11의 취약점 6개가 발견됨

    날짜2022.05.30 조회수235
    Read More
  20. ProtonMail, 통합 브랜드로 다양한 서비스를 제공

    날짜2022.05.30 조회수185
    Read More
  21. 가상머신에 윈도우95 설치하기

    날짜2022.04.22 조회수630
    Read More
  22. 구글 크롬 100 버전 공개

    날짜2022.04.04 조회수839
    Read More
  23. 윈도우 11+다이렉트스토리지, 게임 로딩 시 CPU 부하가 최대 40% 감소

    날짜2022.04.04 조회수708
    Read More
  24. 애플, 위조된 법적 증명에 속아 사용자 데이터를 제공?

    날짜2022.04.04 조회수639
    Read More
  25. 윈도우 탐색기 대체 대안 프로그램 8가지

    날짜2022.04.04 조회수904
    Read More
  26. 인터넷은 어떻게 작동되는지 알아보자

    날짜2022.04.02 조회수675
    Read More
  27. 크롬 취약점 발견 Chrome 업데이트 빨리 해야

    날짜2022.03.30 조회수764
    Read More
  28. GPU-Z, 인텔 아크 알케미스트 그래픽 지원

    날짜2022.03.26 조회수147
    Read More
  29. 아프리카 TV가 트위치보다 데이터를 훨씬 많이 쓰는군요

    날짜2022.03.26 조회수224
    Read More
  30. 애플, 미국 애리조나 주에서 월렛에 신분증 기능 제공

    날짜2022.03.26 조회수151
    Read More
  31. macOS 12.3에서 외장 모니터 연결 문제, 게임 패드 연결 문제

    날짜2022.03.26 조회수164
    Read More
  32. 비트코인 오브 아메리카, ATM에서 도지코인을 취급

    날짜2022.03.26 조회수152
    Read More
  33. 1990년대 중후반에 나온 PowerVR PC GPU의 소스 코드 공개

    날짜2022.03.26 조회수158
    Read More
  34. NVIDIA, 삼성, MS를 해킹한 Lapsus$. 알고보니 10대 소년이 주범?

    날짜2022.03.26 조회수159
    Read More
  35. 통신사 직원 수십억원 갖고 잠적

    날짜2022.03.26 조회수364
    Read More
Board Pagination Prev 1 2 3 4 5 6 7 8 9 10 ... 355 Next
/ 355