您的位置 首页 php

LNMP环境配置之php7.4安装

测试环境

 linux系统:CentOS 7.9.2009 64bit
php版本:php-7.4.19  

下载地址

 
# wget   

步骤

 编译需要安装 gcc  gcc-c++
# yum install gcc gcc-c++

安装相关依赖包
# yum -y install openssl-devel libxml2-devel bzip2-devel curl-devel \
   freetype-devel libjpeg-devel libpng-devel autoconf sqlite-devel

依赖包oniguruma oniguruma-devel需要安装epel源
# yum install -y epel-release
# yum install -y oniguruma oniguruma-devel

解压php包:
# tar xf php-7.4.19.tar.gz
进入目录:
# cd php-7.4.19
进行预编译即对将安装的软件进行配置,检查当前的环境是否满足要安装软件的依赖关系:
# ./configure --prefix=/usr/local/php \
--with-config-file-path=/etc \
--with-config-file-scan-dir=/etc/php.d \
--with- openssl  \
--enable- sockets  \
--enable-opcache \
--enable-sysvshm \
--enable-mbstring \
--enable-gd \
--with-freetype \
--with-jpeg \
--with-zlib-dir \
--enable-xml \
--with-mhash \
--with-bz2 \
--with-curl \
--enable-fpm \
--with-mysqli=mysqlnd \
--with- pdo -mysql=mysqlnd  

编译并安装:

 # make && make install  

安装完成的相关说明信息:

 Build complete.
Don't forget to run 'make test'.

Installing shared extensions:     /usr/local/php/lib/php/extensions/no-debug-non-zts-20190902/
Installing PHP CLI binary:        /usr/local/php/bin/
Installing PHP CLI man page:      /usr/local/php/php/man/man1/
Installing  PHP FPM  binary:        /usr/local/php/sbin/
Installing PHP FPM defconfig:     /usr/local/php/etc/
Installing PHP FPM man page:      /usr/local/php/php/man/man8/
Installing PHP FPM status page:   /usr/local/php/php/php/fpm/
Installing phpdbg binary:         /usr/local/php/bin/
Installing phpdbg man page:       /usr/local/php/php/man/man1/
Installing PHP CGI binary:        /usr/local/php/bin/
Installing PHP CGI man page:      /usr/local/php/php/man/man1/
Installing build environment:     /usr/local/php/lib/php/build/
Installing header files:          /usr/local/php/include/php/
Installing helper programs:       /usr/local/php/bin/
  program: phpize
  program: php-config
Installing man pages:             /usr/local/php/php/man/man1/
  page: phpize.1
  page: php-config.1
/root/php-7.4.19/build/shtool install -c ext/phar/phar.phar /usr/local/php/bin/phar.phar
ln -s -f phar.phar /usr/local/php/bin/phar
Installing PDO headers:           /usr/local/php/include/php/ext/pdo/  

为php提供配置文件

 # cp php.ini-production /etc/php.ini  

提供php-fpm的配置文件

 # cp /usr/local/php/etc/php-fpm.conf.default /usr/local/php/etc/php-fpm.conf
# cp /usr/local/php/etc/php-fpm.d/www.conf.default /usr/local/php/etc/php-fpm.d/www.conf  

php-fpm服务化

修改php-fpm.conf

 # vim /usr/local/php/etc/php-fpm.conf

; Pid file
; Note: the default prefix is /usr/local/php/var
; Default Value: none
pid = /var/run/php-fpm.pid   #修改所在行  

配置启动文件php-fpm.service

 # vim /usr/lib/systemd/system/php-fpm.service 

[Unit]
Description=The PHP FastCGI Process Manager
After=syslog.target network.target

[Service]
Type=forking
PIDFile=/var/run/php-fpm.pid
 Exec Start=/usr/local/php/sbin/php-fpm
ExecReload=/bin/kill -USR2 $MAINPID
PrivateTmp=true

[Install]
WantedBy=multi-user.target  

重新加载systemctl配置:

 # systemctl daemon-reload  

设置开机启动php-fpm

 # systemctl enable php-fpm  

启动php-fpm

 # systemctl start php-fpm  

文章来源:智云一二三科技

文章标题:LNMP环境配置之php7.4安装

文章地址:https://www.zhihuclub.com/149840.shtml

关于作者: 智云科技

热门文章

网站地图