카테고리 없음
[infra] nginx + php8.2
rediate.will
2023. 2. 3. 16:35
이제 php8.2 깔고 셋팅해보자.
> apt install nginx -y
> apt install software-properties-common
> add-apt-repository ppa:ondrej/php -y
> apt install php8.2 -y // 지역선택…..
> apt install php8.2-curl php8.2-dom php8.2-gd php8.2-zip // 필요 익스텐션 설치
> apt autoremove
> apt install php8.2-fpm -y
> apt install curl -y
> curl -sS https://getcomposer.org/installer | php
> mv composer.phar /usr/local/bin/composer
> vi /etc/nginx/sites-available/default
root /var/www/html; //html로 안할거면 수정
index index.php //추가
location ~ \.php$ {
include snippets/fastcgi-php.conf;
# With php-fpm (or other unix sockets):
fastcgi_pass unix:/var/run/php/php8.2-fpm.sock; //주석 제거후 버전 맞게변경
# # With php-cgi (or other tcp sockets):
# fastcgi_pass 127.0.0.1:9000;
}
:wq
> service nginx reload
// nginx의 비정상적인 접속 차단
> vi /etc/php/8.2/fpm/php.ini
:/cgi.fix_pathinfo //검색
// 주석 해제 및 0으로 셋팅
cgi.fix_pathinfo=0
:wq
그리고 index.php파일에 phpinfo(); 저장하고 로드밸런서 주소로 접속하면 화면이 나올거시당! 그럼 세팅 끝!