Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
# php79 stack

> PHP 5.3 ~ 7.4 + Nginx + Let's Encrypt + MariaDB + 앱들을 자동 설치합니다.
> PHP 5.3 ~ 8.0 + Nginx + Let's Encrypt + MariaDB + 앱들을 자동 설치합니다.


## 특징

- 쉽고 빠른 설치, 운영, 업데이트까지 고려한 설계
- 쉬운 업데이트 지원. (공식+인기 저장소를 사용하여 `yum update` 만으로 완료)
- 기본 설정 파일의 수정을 최소화하여 혼란 예방. (주요 설정 내용을 z-php79.ini 형태의 외부 파일로 분리)
- PHP 5.3, 5.4, 5.5, 5.6, 7.0, 7.1, 7.2, 7.3, 7.4 9가지 버전을 지원하며, 하나의 서버에서 2개 이상의 PHP 사용 가능.
- PHP 5.3, 5.4, 5.5, 5.6, 7.0, 7.1, 7.2, 7.3, 7.4, 8.0 10가지 버전을 지원하며, 하나의 서버에서 2개 이상의 PHP 사용 가능.
- Laravel 5.1~5.5, WordPress, XE, 그누보드 4/5, phpMyAdmin 자동 설치 지원. ([app-install.sh](app-install.sh))
- 시스템 계정, 디비 계정 자동 생성 지원. ([user-add.sh](user-add.sh))
- [Let's Encrypt - 무료 SSL 인증서 발급 및 갱신 지원](https://github.com/php79/stack/wiki/letsencrypt) ([ssl-install.sh](ssl-install.sh))
Expand Down Expand Up @@ -103,7 +103,7 @@ cd /root/stack

## 설치 내역

### PHP 5.3, 5.4, 5.5, 5.6, 7.0, 7.1, 7.2, 7.3, 7.4
### PHP 5.3, 5.4, 5.5, 5.6, 7.0, 7.1, 7.2, 7.3, 7.4, 8.0
- 단, CentOS 7 의 PHP 5.3 공식 저장소가 없어, 소스 컴파일 설치됩니다.
- composer 설치

Expand Down
4 changes: 2 additions & 2 deletions app-install.sh
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ function show_usage

echo -n " "
outputInfo "--php"
echo " PHP 버전을 [ 53 54 55 56 56 70 71 72 73 74 ] 형식으로 하나만 입력하세요."
echo " PHP 버전을 [ 53 54 55 56 56 70 71 72 73 74 80 ] 형식으로 하나만 입력하세요."
echo " Tip) Laravel 은 70, 그누보드4 는 53 등 프로그램에 따라 적절히 선택하세요."
echo " ./status.sh 명령을 통해 현재 서버에 설치된 PHP 버전을 확인할 수 있습니다."
echo
Expand Down Expand Up @@ -166,7 +166,7 @@ if [ -z ${INPUT_PHP_VERSION} ]; then
fi

if [ ! -f "/usr/bin/php${INPUT_PHP_VERSION}" ]; then
input_abort "PHP ${INPUT_PHP_VERSION} 버전은 아직 설치되지 않았습니다. 입력 형식) 53 54 55 56 70 71 72 73 74"
input_abort "PHP ${INPUT_PHP_VERSION} 버전은 아직 설치되지 않았습니다. 입력 형식) 53 54 55 56 70 71 72 73 74 80"
fi

# nginx 중복 체크
Expand Down
6 changes: 5 additions & 1 deletion includes/function.inc.sh
Original file line number Diff line number Diff line change
Expand Up @@ -94,14 +94,18 @@ function welcome_short
function welcome
{
welcome_short
echo " * PHP 5.3-7.4 + Nginx + Let's Encrypt + MariaDB installer"
echo " * PHP 5.3-8.0 + Nginx + Let's Encrypt + MariaDB installer"
echo
}

function options
{
printf " - Install ${GREEN}EPEL repo${NO_COLOR} / http://fedoraproject.org/wiki/EPEL\n"

if [ $PHP80 = "1" ]; then
printf " - Install ${GREEN}PHP 8.0${NO_COLOR} from Remi repo / http://rpms.famillecollet.com/\n"
fi

if [ $PHP74 = "1" ]; then
printf " - Install ${GREEN}PHP 7.4${NO_COLOR} from Remi repo / http://rpms.famillecollet.com/\n"
fi
Expand Down
6 changes: 6 additions & 0 deletions install.sh
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,12 @@ if [ $PHP74 = "1" ]; then
PHP_INSTALLED=74
fi

if [ $PHP80 = "1" ]; then
cmd_once "scripts/remi-repo-install.sh"
cmd_once "scripts/php8-remi-install.sh 80"
PHP_INSTALLED=80
fi

### /usr/bin/php link
if [ ! $PHP_INSTALLED = "" ]; then
if [ $OS = "centos7" ]; then
Expand Down
4 changes: 4 additions & 0 deletions nginx/1-fastcgi-php80.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
# http://nginx.org/en/docs/http/ngx_http_upstream_module.html
upstream php80_backend {
server 127.0.0.1:9080;
}
67 changes: 67 additions & 0 deletions php/80/z-php79.ini
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
; Modern PHP 소스용 권장 설정
; updated: 2016-04-01

[PHP79]
; 타임존. 미선언 상태에서 date() 등 사용시 경고 발생.
date.timezone = Asia/Seoul

; PHP 버전 숨기기
expose_php = Off

; 레거시 코드에 <? 사용된 코드가 많으므로, 소스 노출 예방 차원에서 활성화
short_open_tag = On

; 에러 로그를 syslog(/var/log/messages) 에 남기기
error_log = syslog

; 에러를 화면에 보여주기. 개발서버이거나 레거시 코드라 별도 에러 처리가 불가할 경우 On
;display_errors = On
;display_startup_errors = On

; 에러 출력 레벨.
;error_reporting = E_ALL & ~E_DEPRECATED & ~E_STRICT ; 기본값. 강력한 에러 확인!
;error_reporting = E_ALL & ~E_DEPRECATED & ~E_NOTICE ; 레거시 호환용. 선언되지 않은 변수 사용시 에러 등 숨김.


[Upload]
; 업로드 파일 하나당 최대 용량. 최대 2047M. 2048M로 지정하면 int 범위를 넘어서 에러 발생하므로 주의 요망.
upload_max_filesize = 20M

; 업로드 요청시 모든 파일과 내용의 최대 전송양. 업로드 용량의 1.3배 정도 권장
post_max_size = 30M

; 업로드 임시 디렉토리. 기본 /tmp 이며, 대용량/과부하 서버에선 별도 지정을 고려해야 함.
; 예1) 파일 업로드를 2GB까지 해야 하는데, /tmp 용량이 2GB가 안될 경우 별도 용량이 많은 디렉토리로 지정.
; 예2) 용량이 큰 업로드가 많고 /tmp 와 실제 데이타가 저장될 (/home)이 다른 파티션이어서,
; 업로드후 임시 파일이 실제 저장되는데 시간이 오래 걸릴 경우 실제 저장될 디렉토리와 같은 파티션으로 지정 권장.
;upload_tmp_dir=/home/YourSite/upload_tmp

; 하나의 폼에서 동시에 업로드 가능한 최대 파일수. 기본 20개
;max_file_uploads = 20

; 입력 데이터 최대 처리시간으로, 대용량 업로드시 증가 필요
;max_input_time = 3600

; PHP 스크립트의 최대 실행시간으로, 대용량 업로드나 특정 시간이 오래 걸리는 업무가 필요한 곳에서만 늘려주세요. 기본 30초.
;max_execution_time = 3600


[OPcache]
; OPcache 는 PHP를 매번 해석하지 않고, 컴파일된 바이너리를 메모리에 올려 재사용하는 속도 향상에 필수인 모듈입니다.

; 최대 메모리 사용량. 기본값은 128MB 이며 사이트나 패키지가 많을 때 적절히 늘려주어야 함. 단, 서버 메모리가 충분한 경우에 한함
;opcache.memory_consumption=128

; 최대 캐싱 파일수. 기본 4000 개로는 기본 5000개인 라라벨도 힘들기 때문에 1만~10만개 권장.
opcache.max_accelerated_files=100000

; 캐싱된 파일의 수정 여부 확인 주기.
; 기본 2초는 파일 수정 시간이 2초 지나야 해당 파일의 수정여부를 체크한다는 의미입니다.
; 즉, 소스 수정하고 2초 이내에 화면 새로고침해도 수정된 결과가 반영되지 않는다는 의미입니다.
;opcache.revalidate_freq=2 ; 운영용으로 적합. 최적의 성능.
;opcache.revalidate_freq=1 ; 운영하면서 라이브로 수정할 경우 적합.
;opcache.revalidate_freq=0 ; 개발서버일 경우 0초는 필수! 수정하고 즉시 결과 확인 가능.

; PHP CLI (/usr/bin/php) 실행시, OPcache 활성화 여부.
; 반복되는 실행시 속도가 더 느려지거나, 랜덤하게 에러가 발생하는 사례가 있었으므로 미사용 권장.
;opcache.enable_cli=1
51 changes: 51 additions & 0 deletions scripts/php8-remi-install.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
#!/usr/bin/env bash

# Copyright:: Copyright (c) 2016 Been Kyung-yoon (http://www.php79.com/)
# License:: The MIT License (MIT)

# PHP 8 차이점 - php80-php-pecl-mysql 패키지 없음

STACK_ROOT=$( dirname $( cd "$( dirname "$0" )" && pwd ) )
source "${STACK_ROOT}/includes/function.inc.sh"

title "PHP [${1}] 버전을 설치합니다."

if [ -z ${1} ]; then
abort "설치할 PHP 버전을 입력하세요. 80"
fi

yum_install php$1-php-cli php$1-php-fpm \
php$1-php-common php$1-php-pdo php$1-php-mysqlnd php$1-php-mbstring php$1-php-mcrypt \
php$1-php-opcache php$1-php-xml php$1-php-pecl-imagick php$1-php-gd php$1-php-fileinfo \
php$1-php-pecl-zip php$1-php-bcmath

if [ ! -f "/etc/opt/remi/php${1}/php.d/z-php79.ini" ]; then
notice "PHP 권장 설정이 추가되었습니다.\n설정 파일 경로) /etc/opt/remi/php${1}/php.d/z-php79.ini"
cp -av "${STACK_ROOT}/php/80/z-php79.ini" "/etc/opt/remi/php${1}/php.d/"
string_quote ${TIMEZONE}
sed -i "s/^date.timezone =.*/date.timezone = ${STRING_QUOTE}/g" "/etc/opt/remi/php${1}/php.d/z-php79.ini"
fi

PHP_FPM_CONF=/etc/opt/remi/php$1/php-fpm.d/www.conf
sed -i 's/^;security.limit_extensions = .php .php3 .php4 .php5/security.limit_extensions = .php .html .htm .inc/g' $PHP_FPM_CONF
sed -i 's/^user = apache/user = nobody/g' $PHP_FPM_CONF
sed -i 's/^group = apache/group = nobody/g' $PHP_FPM_CONF
sed -i 's/^listen = 127.0.0.1:9000/listen = 127.0.0.1:90'$1'/g' $PHP_FPM_CONF

chgrp -v nobody /var/opt/remi/php$1/lib/php/*
chown -v nobody /var/opt/remi/php$1/log/php-fpm

if [ $OS = "centos7" ]; then
systemctl enable php$1-php-fpm
systemctl start php$1-php-fpm
else
chkconfig php$1-php-fpm on
service php$1-php-fpm start
fi

# nginx 설치된 경우만 복사
if [ -f /etc/nginx/conf.d/0-php79.conf ]; then
if [ ! -f "/etc/nginx/conf.d/1-fastcgi-php${1}.conf" ]; then
cp -av "${STACK_ROOT}/nginx/1-fastcgi-php${1}.conf" /etc/nginx/conf.d/
fi
fi
1 change: 1 addition & 0 deletions stack.defaults.conf
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ PHP71=0
PHP72=0
PHP73=0
PHP74=1
PHP80=0

# PHP CLI ( /usr/bin/php ) 에서 사용할 PHP 버전을 선택해주세요.
PHP_BASE=74
Expand Down