> 백엔드 개발 > PHP7 > 본문

nginx 서버를 php5.5.7에서 php7로 업그레이드하는 방법은 무엇입니까?

醉折花枝作酒筹
풀어 주다: 2023-02-18 06:24:01
앞으로
2295명이 탐색했습니다.

이 기사에서는 nginx 서버를 php5.5.7에서 php7로 업그레이드하는 방법을 소개합니다. 방법. 도움이 필요한 친구들이 모두 참고할 수 있기를 바랍니다.

nginx 서버를 php5.5.7에서 php7로 업그레이드하는 방법은 무엇입니까?

① 서버 nginx, php, mysql이 모두 설치되어 있으니 php7을 직접 업그레이드 해보고 싶습니다.

②글 따라가기: https://typecodes.com/web/centos7compilephp7.html?utm_source=tuicool&utm_medium=referral 수술 도중 중간에 다른 것이 나타납니다.

3문제 해결 참고자료: http://blog.chinaunix.net/uid-25266990-id-2915395.html

선 구분------- - ------------------------------------------------- - ------------------------------------------------- - ------------------------------------------------- - ---

제가 직접 사용할 수 있도록 아래 2단계를 다시 게시하겠습니다.

1 PHP 사용자 및 사용자 그룹을 생성하고 github에서 php7 소스 코드를 다운로드합니다.

먼저 로그인 권한이 없는 php라는 사용자와 php라는 사용자 그룹을 생성한 다음 GitHub로 이동하여 php7 소스 코드 패키지를 다운로드합니다.

#######新建php用户和php组
[root@typecodes ~]# groupadd -r php && useradd -r -g php -s /bin/false -d /usr/local/php7 -M php
######从GitHub下载php7安装包
[root@typecodes ~]# wget -c --no-check-certificate -O php7-src-master.zip https://github.com/php/php-src/archive/master.zip
######开始解压php7包
[root@typecodes ~]# unzip -q php7-src-master.zip && cd php-src-master
#####安装编译php7时需要的依赖包
[root@typecodes php-src-master]# yum -y install libxml2 libxml2-devel openssl openssl-devel curl-devel libjpeg-devel libpng-devel freetype-devel libmcrypt-devel
로그인 후 복사
2 PHP7 컴파일 매개변수 구성(ps: 아래에 슬래시를 게시할 예정이며 직접 복사할 수 있습니다.)

준비가 완료되면 공식적으로 php7의 설치 세부 사항 구성을 시작합니다. 참고로, 아래 백슬래시 "" 뒤에 추가된 주석 텍스트를 먼저 제거해야 합니다! ! !

######开始生成配置文件
[root@typecodes php-src-master]# ./buildconf
buildconf: checking installation...
buildconf: autoconf version 2.69 (ok)
rebuilding aclocal.m4
rebuilding configure
rebuilding main/php_config.h.in
######开始配置
[root@typecodes php-src-master]# ./configure \
--prefix=/usr/local/php7 \                              [PHP7安装的根目录]
--exec-prefix=/usr/local/php7 \
--bindir=/usr/local/php7/bin \
--sbindir=/usr/local/php7/sbin \
--includedir=/usr/local/php7/include \
--libdir=/usr/local/php7/lib/php \
--mandir=/usr/local/php7/php/man \
--with-config-file-path=/usr/local/php7/etc \           [PHP7的配置目录]
--with-mysql-sock=/var/run/mysql/mysql.sock \           [PHP7的Unix socket通信文件]
--with-mcrypt=/usr/include \
--with-mhash \
--with-openssl \
--with-mysql=shared,mysqlnd \                           [PHP7依赖mysql库]              
--with-mysqli=shared,mysqlnd \                          [PHP7依赖mysql库]
--with-pdo-mysql=shared,mysqlnd \                       [PHP7依赖mysql库]
--with-gd \
--with-iconv \
--with-zlib \
--enable-zip \
--enable-inline-optimization \
--disable-debug \
--disable-rpath \
--enable-shared \
--enable-xml \
--enable-bcmath \
--enable-shmop \
--enable-sysvsem \
--enable-mbregex \
--enable-mbstring \
--enable-ftp \
--enable-gd-native-ttf \
--enable-pcntl \
--enable-sockets \
--with-xmlrpc \
--enable-soap \
--without-pear \
--with-gettext \
--enable-session \                                      [允许php会话session]
--with-curl \                                           [允许curl扩展]
--with-jpeg-dir \
--with-freetype-dir \
--enable-opcache \                                      [使用opcache缓存]
--enable-fpm \
--enable-fastcgi \
--with-fpm-user=nginx \                                 [php-fpm的用户]
--with-fpm-group=nginx \                                [php-fpm的用户组]
--without-gdbm \
--disable-fileinfo
로그인 후 복사
rrree
3 PHP7 컴파일 및 설치 시작

CPU와 메모리를 많이 소모하는 MySQL을 컴파일하고 설치하는 것에 비해 PHP7을 컴파일하고 설치하는 데는 전체 과정이 약 1시간 정도 소요됩니다.

./configure
--prefix=/usr/local/php7 
--exec-prefix=/usr/local/php7
--bindir=/usr/local/php7/bin 
--sbindir=/usr/local/php7/sbin 
--includedir=/usr/local/php7/include 
--libdir=/usr/local/php7/lib/php 
--mandir=/usr/local/php7/php/man 
--with-config-file-path=/usr/local/php7/etc         
--with-mysql-sock=/var/run/mysql/mysql.sock 
--with-mcrypt=/usr/include 
--with-mhash 
--with-openssl 
--with-mysql=shared,mysqlnd   
--with-mysqli=shared,mysqlnd 
--with-pdo-mysql=shared,mysqlnd 
--with-gd 
--with-iconv 
--with-zlib 
--enable-zip 
--enable-inline-optimization 
--disable-debug 
--disable-rpath 
--enable-shared 
--enable-xml 
--enable-bcmath 
--enable-shmop 
--enable-sysvsem 
--enable-mbregex 
--enable-mbstring 
--enable-ftp 
--enable-gd-native-ttf 
--enable-pcntl 
--enable-sockets 
--with-xmlrpc 
--enable-soap 
--without-pear 
--with-gettext 
--enable-session 
--with-curl                                        
--with-jpeg-dir 
--with-freetype-dir 
--enable-opcache                                  
--enable-fpm 
--enable-fastcgi 
--with-fpm-user=nginx                                
--with-fpm-group=nginx                                 
--without-gdbm 
--disable-fileinfo
로그인 후 복사

아래 그림을 보면 PHP7이 컴파일되고 설치되었다는 뜻이에요! (ps: 컴파일 중에 오류가 발생했습니다. `libiconv_open에 대한 정의되지 않은 참조는 PHP를 컴파일할 수 없습니다.

해결 방법에 대한 자세한 내용은 위 링크를 참조하십시오. 약 77번째 줄에서 Makefile을 편집하세요.

EXTRA_LIBS = ..... -lcrypt

마지막으로 -liconv를 추가합니다. 예:

EXTRA_LIBS = ..... -lcrypt -liconv

그런 다음 make를 실행합니다. )

4 선택 단계: make test 명령을 실행하여 테스트합니다.

이것은 비입니다. -stop 필요한 단계: make test 명령을 실행합니다. 흥미로운 점은 테스트 중에 공식 PHP 웹사이트 http://www.php.net에 해당하는 IP 주소 72.52.91.14를 사용하여 TCP 연결이 설정된다는 것입니다.

5 컴파일 성공 후 PHP7 설치 디렉터리 확인

MySQL과 통신해야 하므로 PHP7 설치 후 lib 확장 라이브러리 디렉터리를 구체적으로 확인해야 합니다(/usr/local/php7/lib/php/extensions/no- 디버그-non-zts-20141001/). 아래 그림과 같이 최소한 두 개의 동적 라이브러리 파일 mysqli.so 및 pdo_mysql.so가 존재하는지 확인해야 합니다.

6 PHP7 구성 파일 php.ini, php-fpm.conf, www.conf 및 php-fpm 스크립트 설정을 시작하세요

컴파일된 구성 파일을 PHP7 구성 디렉터리(/usr/local/php7/)에 복사할 수 있습니다. etc/), "PHP7에서 php.ini, php-fpm 및 www.conf 구성" 문서에 컴파일된 3개의 PHP7 구성 파일과 php-fpm 서비스 제어 스크립트를 사용하는 것이 좋습니다.

[root@typecodes php-src-master]# make clean && make && make install
로그인 후 복사
7 php의 환경변수를 추가합니다

현재 리눅스 시스템의 환경변수에 php 컴파일로 생성된 bin 디렉터리를 추가합니다.

#######方法一:直接使用编译后未经优化处理的配置
[root@typecodes php-src-master]# cp php.ini-production /usr/local/php7/etc/php.ini
[root@typecodes php-src-master]# cp /root/php-src-master/sapi/fpm/init.d.php-fpm /etc/init.d/php-fpm
[root@typecodes php-src-master]# cp /usr/local/php7/etc/php-fpm.conf.default /usr/local/php7/etc/php-fpm.conf
[root@typecodes php-src-master]# cp /usr/local/php7/etc/php-fpm.d/www.conf.default /usr/local/php7/etc/php-fpm.d/www.conf
#######方法二:使用https://typecodes.com/web/php7configure.html文中的配置 
[root@typecodes php-src-master]# mv ~/php.ini /usr/local/php7/etc/php.ini && mv ~/php-fpm /etc/init.d/php-fpm
[root@typecodes php-src-master]# mv ~/php-fpm.conf /usr/local/php7/etc/php-fpm.conf && mv ~/www.conf /usr/local/php7/etc/php-fpm.d/www.conf
로그인 후 복사
8 PHP 로그 디렉터리와 php-fpm 프로세스 파일(php-fpm.dll)을 설정합니다. sock) 디렉토리

그 중 php-fpm 프로세스 디렉토리의 사용자와 사용자 그룹을 nginx로 설정하고, php 세션 디렉토리를 생성합니다.

[root@typecodes ~]# echo -e '\nexport PATH=/usr/local/php7/bin:/usr/local/php7/sbin:$PATH\n' >> /etc/profile && source /etc/profile
로그인 후 복사
9 PHP 시작을 설정하고 구성 파일이 올바른지 테스트합니다.
#######设置PHP日志目录和php-fpm的运行进程ID文件(php-fpm.sock)目录
[root@typecodes ~]# mkdir -p /var/log/php-fpm/ && mkdir -p /var/run/php-fpm && cd /var/run/ && chown -R nginx:nginx php-fpm
#######修改session的目录配置
[root@typecodes etc]# mkdir -p /var/lib/php/session
[root@typecodes etc]# chown -R nginx:nginx /var/lib/php
로그인 후 복사
10 PHP 서비스 시작

위 작업을 완료하면 공식적으로 PHP 서비스를 사용할 수 있습니다. php 프로세스 서비스를 시작하는 명령은 다음과 같습니다.

######配置开机自启动,增加到主机sysV服务
[root@typecodes php-src-master]# chmod +x /etc/init.d/php-fpm
[root@typecodes php-src-master]# chkconfig --add php-fpm
[root@typecodes php-src-master]# chkconfig php-fpm on
######测试PHP的配置文件是否正确合法
[root@typecodes sbin]# php-fpm -t
[03-May-2015 17:50:04] NOTICE: configuration file /usr/local/php7/etc/php-fpm.conf test is successful
로그인 후 복사

그런 다음 ps -aux|grep php 명령을 통해 성공 여부를 확인할 수 있습니다. (그림의 php-fpm 프로세스 수와 프로세스 사용자 nginx는 모두 pm.start_servers 및 www.conf 값은 각각 결정됨):

11 PHP7 버전 정보 보기

마지막으로 php -v 명령을 통해 현재 PHP 버전 정보를 볼 수 있다는 것을 그림에서 볼 수 있습니다. 현재 PHP7도 Zend OPcache 캐시를 사용합니다. php.ini 파일에 zend_extension=opcache.so 구성이 추가되었기 때문입니다.

configure: 오류: xslt-config를 찾을 수 없습니다. libxslt >= 1.1.0 배포판을 다시 설치하세요.

PHP에서

./configure를 컴파일하고 설치할 때 다음 오류가 발생합니다.

configure: 오류: xslt-config 찾을 수 없습니다. libxslt >= 1.1.0 배포판을 다시 설치하세요

해결책:

yum install libxslt-devel* -y

권장 학습: php 비디오 튜토리얼

위 내용은 nginx 서버를 php5.5.7에서 php7로 업그레이드하는 방법은 무엇입니까?의 상세 내용입니다. 자세한 내용은 PHP 중국어 웹사이트의 기타 관련 기사를 참조하세요!

관련 라벨:
원천:csdn.net
본 웹사이트의 성명
본 글의 내용은 네티즌들의 자발적인 기여로 작성되었으며, 저작권은 원저작자에게 있습니다. 본 사이트는 이에 상응하는 법적 책임을 지지 않습니다. 표절이나 침해가 의심되는 콘텐츠를 발견한 경우 admin@php.cn으로 문의하세요.
인기 튜토리얼
더>
최신 다운로드
더>
웹 효과
웹사이트 소스 코드
웹사이트 자료
프론트엔드 템플릿
회사 소개 부인 성명 Sitemap
PHP 중국어 웹사이트:공공복지 온라인 PHP 교육,PHP 학습자의 빠른 성장을 도와주세요!