1. 다운로드
1, https://www.php.net/distributions/php-8.0.0.tar.gz
下载到本地,文件传输上传到 /usr/local/src/
2、wget -P /usr/local/src/ https://www.php.net/distributions/php-8.0.0.tar.gz
2.압축 해제, 컴파일, 설치
1, unzip
> cd /usr/local/src/ > tar xzf php-8.0.0.tar.gz > cd php-8.0.0
2, 컴파일 매개변수를 구성하려면 https://www.php.net/manual/zh/configure.about.php를 참조하여 필요한 옵션을 선택하세요
./configure --prefix=/usr/local/php8 --with-config-file-path=/usr/local/php8/etc --with-fpm-user=www --with-fpm-group=www --with-curl --with-openssl --with-mysqli --with-pdo-mysql --with-iconv --with-mhash --with-zlib --enable-mbstring --enable-gd --enable-gd-jis-conv --enable-sockets --enable-fpm --enable- --enable-xml --enable-pdo --enable-cli --enable-pcntl --enable-soap --enable-opcache --enable-fileinfo --disable-rpath --enable-mysqlnd --with-zip --enable-simplexml --with-libxml --with-sqlite3 --with-pdo-sqlite --enable-phar --enable-tokenizer --enable-cgi
질문 1:
configure: error: Package requirements (libxml-2.0 >= 2.9.0) were not met: Package 'libxml-2.0', required by 'virtual:world', not found Consider adjusting the PKG_CONFIG_PATH environment variable if you installed software in a non-standard prefix. Alternatively, you may set the environment variables LIBXML_CFLAGS and LIBXML_LIBS to avoid the need to call pkg-config. See the pkg-config man page for more details.
문제 1에 대한 해결 방법:
> yum install libxml2-devel
질문 2:
configure: error: Package requirements (sqlite3 > 3.7.4) were not met:
문제 2 해결됨:
> yum install sqlite-devel
문제 3:
configure: error: Package requirements (libcurl >= 7.29.0) were not met:
문제 3 해결됨:
> yum install libcurl-devel
문제 4:
configure: error: Package requirements (libpng) were not met:
문제 4 해결됨:
> yum install libpng libpng-devel
문제 5:
configure: error: Package requirements (oniguruma) were not met:
문제 5 해결됨:
> cd /usr/local/src/ > wget http://ftp.altlinux.org/pub/distributions/ALTLinux/Sisyphus/x86_64/RPMS.classic/liboniguruma5-6.9.6-alt1.x86_64.rpm -O liboniguruma5-6.9.6-alt1.x86_64.rpm > rpm -ivh liboniguruma5-6.9.6-alt1.x86_64.rpm > wget http://ftp.altlinux.org/pub/distributions/ALTLinux/Sisyphus/x86_64/RPMS.classic/liboniguruma-devel-6.9.6-alt1.x86_64.rpm -O liboniguruma-devel-6.9.6-alt1.x86_64.rpm > rpm liboniguruma-devel-6.9.6-alt1.x86_64.rpmcli
문제 6:
configure: error: Package requirements (libzip >= 0.11 libzip != 1.3.1 libzip != 1.7.0) were not met:
문제 6 해결됨:
> yum install libzip libzip-devel
컴파일 매개변수 구성 성공
+--------------------------------------------------------------------+ | License: | | This software is subject to the PHP License, available in this | | distribution in the file LICENSE. By continuing this installation | | process, you are bound by the terms of this license agreement. | | If you do not agree with the terms of this license, you must abort | | the installation process at this point. | +--------------------------------------------------------------------+ Thank you for using PHP.
3. 소스 코드 컴파일
> make -j2 # 这里是依赖系统cpu核心数进行编译,对性能有一定提升,通常利用核心数不要超过一半,
4. 설치
make install
성공적 설치
[root@54skyer php-8.0.0]# make install Installing shared extensions: /usr/local/php8/lib/php/extensions/no-debug-non-zts-20200930/ Installing PHP CLI binary: /usr/local/php8/bin/ Installing PHP CLI man page: /usr/local/php8/php/man/man1/ Installing PHP FPM binary: /usr/local/php8/sbin/ Installing PHP FPM defconfig: /usr/local/php8/etc/ Installing PHP FPM man page: /usr/local/php8/php/man/man8/ Installing PHP FPM status page: /usr/local/php8/php/php/fpm/ Installing phpdbg binary: /usr/local/php8/bin/ Installing phpdbg man page: /usr/local/php8/php/man/man1/ Installing PHP CGI binary: /usr/local/php8/bin/ Installing PHP CGI man page: /usr/local/php8/php/man/man1/ Installing build environment: /usr/local/php8/lib/php/build/ Installing header files: /usr/local/php8/include/php/ Installing helper programs: /usr/local/php8/bin/ program: phpize program: php-config Installing man pages: /usr/local/php8/php/man/man1/ page: phpize.1 page: php-config.1 /usr/local/src/php-8.0.0/build/shtool install -c ext/phar/phar.phar /usr/local/php8/bin/phar.phar ln -s -f phar.phar /usr/local/php8/bin/phar Installing PDO headers: /usr/local/php8/include/php/ext/pdo/
5.
6. 기본 구성 가져오기> vim /etc/profile # 在文件末尾加入 # PATH=$PATH:/usr/local/php8/bin/ # export PATH # :wq 保存并退出 > source /etc/profile # 立刻生效配置 > php -v # 获得如下信息 php -v PHP 8.0.0 (cli) (built: Dec 15 2020 02:46:59) ( NTS ) Copyright (c) The PHP Group Zend Engine v4.0.0-dev, Copyright (c) Zend Technologies
설정 명령을 실행할 수 있습니다
// 复制php.ini到编译配置参数指定的目录。php.ini在解压的源码目录里 > cp /usr/local/src/php-8.0.0/php.ini-production /usr/local/php8/etc/php.ini // 复制一份php-fpm的配置模版文件到同级目录 方便备份和修改 > cp /usr/local/php8/etc/php-fpm.conf.default /usr/local/php8/etc/php-fpm.conf // 复制一份php-fpm的扩展配置模板文件到同级目录 方便备份和修改 > cp /usr/local/php8/etc/php-fpm.d/www.conf.default /usr/local/php8/etc/php-fpm.d/www.conf // 复制开启自起脚本到系统启动自动加载脚本目录。fpm/init.d.php-fpm在解压的源码目录里 > cp /usr/local/src/php-8.0.0/sapi/fpm/init.d.php-fpm /etc/init.d/php-fpm
> chmod +x /etc/init.d/php-fpm # 添加可执行权限
php-fpm.conf는 PHP-FPM에 고유한 구성 파일입니다.
php.ini는 모든 PHP 모드에서 필수 구성 파일입니다.
둘 사이의 차이점 php-fpm.conf는 PHP-FPM 프로세스 관리자 파일의 구성이고, php.ini는 PHP 파서의 구성 파일입니다.
일부 PHP 버전에는 /fpm.d/www.conf 구성 파일도 있습니다. 구성 파일 경로
이것은 php-fpm.conf로 구성한 파일의 확장 파일입니다. php-fpm.conf 파일을 열어서 볼 수 있습니다.
;include=fpm.d/*.conf
사용할 수 있습니다 php-fpm.conf를 사용하여 느린 로그를 구성하세요
느린 로그 기능을 활성화할 수 있습니다.
slowlog = /usr/local/var/log/php-fpm.log.slow
request_slowlog_timeout = 5s