>  기사  >  백엔드 개발  >  centos7에서 yum을 통해 지정된 버전의 PHP를 설치하는 방법

centos7에서 yum을 통해 지정된 버전의 PHP를 설치하는 방법

王林
王林원래의
2020-08-11 15:15:306304검색

yum을 통해 centos7에 지정된 버전의 php를 설치하는 방법: 1. 소스를 설치합니다. 2. [yum install -y php] 명령을 실행하여 해당 버전의 php를 선택하여 설치합니다. 4. [systemctl restart ] 명령을 실행하여 PHP를 시작합니다.

centos7에서 yum을 통해 지정된 버전의 PHP를 설치하는 방법

1. 설치 소스

epel-release 설치:

yum -y install epel-release

(권장 튜토리얼: php 그래픽 튜토리얼)

remi 소스 추가:

rpm -Uvh http://rpms.remirepo.net/enterprise/remi-release-7.rpm

yum-config-manager 유틸리티 설치:

yum -y install yum-utils

2. PHP 설치

설치할 해당 버전 선택

PHP5.4 설치:

yum install -y php

PHP7.0 설치:

yum-config-manager --enable remi-php70
yum -y install php php-opcache

PHP7.1 설치:

yum-config-manager --enable remi-php71
yum -y install php php-opcache

전에 yum 검색 php71을 사용하여 설치 가능한 항목을 검색할 수 있습니다. 설치 소프트웨어 패키지.

완료 후 일반 PHP 확장을 추가해야 합니다.

yum -y install php-mysql php-gd php-ldap php-odbc php-pear php-xml php-xmlrpc php-mbstring php-soap curl curl-devel
yum -y install php71-php-fpm.x86_64
systemctl restart php71-php-fpm    #启动php
netstat -tunlp|grep 9000     #查看php启动状态
vim /etc/opt/remi/php71/php-fpm.d/www.conf
user = nginx   #修改用户为nginx
group = nginx   #修改组为nginx

(비디오 튜토리얼 권장 사항: php 비디오 튜토리얼)

3 nginx 구성

nginx 설치

yum install nginx     #安装nginx
vim /etc/nginx/conf.d/test.conf
 
server {
    listen 80;
    #listen [::]:80;
    server_name 39.105.1.170;
    client_max_body_size 50m;
 
    location / {
        charset  utf-8;
        root /var/www;
        index  index.html index.htm;
        }
     location ~ \.php$ {
        root           /var/www;
        fastcgi_pass   127.0.0.1:9000;
        fastcgi_index  index.php;
        fastcgi_param  SCRIPT_FILENAME  /var/www$fastcgi_script_name;
        include        fastcgi_params;
    }
}

Start nginx

nginx -s reload      #启动nginx

두 개의 새 파일 생성 /var/www 파일, html 파일, php 파일

test.html的内容为:
 
<h1>Hello World</h1>
 
test.php的内容为:
 
<?php
phpinfo();
?>

브라우저 액세스: 39.105.1.170/test.html 및 39.105.1.170/test.php

위 내용은 centos7에서 yum을 통해 지정된 버전의 PHP를 설치하는 방법의 상세 내용입니다. 자세한 내용은 PHP 중국어 웹사이트의 기타 관련 기사를 참조하세요!

성명:
본 글의 내용은 네티즌들의 자발적인 기여로 작성되었으며, 저작권은 원저작자에게 있습니다. 본 사이트는 이에 상응하는 법적 책임을 지지 않습니다. 표절이나 침해가 의심되는 콘텐츠를 발견한 경우 admin@php.cn으로 문의하세요.
이전 기사:PHP 함수 명명 규칙다음 기사:PHP 함수 명명 규칙