1. 시스템 업데이트
$ sudo apt update
$ sudo apt upgrade -y
2. 필수 패키지 설치
$ sudo apt install software-properties-common -y
3. 최신 PHP 버전을 제공하는 PPA 추가
$ sudo add-apt-repository ppa:ondrej/php -y
$ sudo apt update
4. PHP 최신 버전 설치 (현재 8.3)
$ sudo apt install php8.3 php8.3-fpm php8.3-cli php8.3-common php8.3-mysql php8.3-curl php8.3-xml php8.3-mbstring -y
5. 설치 확인
$ php -v
PHP 8.3.20 (cli) (built: Apr 10 2025 21:33:50) (NTS)
Copyright (c) The PHP Group
Zend Engine v4.3.20, Copyright (c) Zend Technologies
with Zend OPcache v8.3.20, Copyright (c), by Zend Technologies
6. nginx 와 연동
$ sudo nano /etc/nginx/sites-available/default
FastCGI 부분을 찾아 # 주석부분을 삭제하거나 아래와 같이 작성한다.
(index.php 추가)
# Add index.php to the list if you are using PHP
index index.php index.html index.htm index.nginx-debian.html;
(생략)
# pass PHP scripts to FastCGI server
#
location ~ \.php$ {
include snippets/fastcgi-php.conf;
#
# # With php-fpm (or other unix sockets):
fastcgi_pass unix:/run/php/php8.3-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;
}
문법이 맞는지 확인 후 nginx 재시작
$ sudo nginx -t
nginx: the configuration file /etc/nginx/nginx.conf syntax is ok
nginx: configuration file /etc/nginx/nginx.conf test is successful
$ sudo systemctl restart nginx
7. 선택사항 (PHP 설정 수정)
$ sudo nano /etc/php/8.3/fpm/php.ini
# 예: 아래 값을 변경 가능
upload_max_filesize = 100M
post_max_size = 100M
memory_limit = 256M
max_execution_time = 300
'오라클 클라우드' 카테고리의 다른 글
원격으로 maria db에 접속하기 (0) | 2025.04.14 |
---|---|
maria db 설치하기 (0) | 2025.04.14 |
PHP 설치 전 디렉토리 권한 설정하기 (0) | 2025.04.14 |
오라클 클라우드 프리티어에서 nginx 설치 후 접속이 안될 때 CIDR도 확인하자 (1) | 2025.04.12 |
오라클 클라우드 프리티어 (0) | 2025.04.12 |