lnmp架构(1):php的源码安装与配置(详细图解)

1.下载php安装包

2.解压

[root@server1 ~]# tar jxf php-7.4.6.tar.bz2

在这里插入图片描述
如果此时出现如下错误

[root@server1 ~]# tar jxf php-7.4.6.tar.bz2
tar (child): bzip2: Cannot exec: No such file or directory
tar (child): Error is not recoverable: exiting now
tar: Child returned status 2
tar: Error is not recoverable: exiting now

则:

[root@server1 ~]# yum install -y bzip2

在这里插入图片描述
在这里插入图片描述

 ./configure --prefix=/usr/local/php --enable-fpm --with-fpm-user=nginx --with-fpm-group=nginx  --with-curl --with-iconv --with-mhash --with-zlib --with-openssl --enable-mysqlnd --with-mysqli --with-pdo-mysql --disable-debug --enable-sockets --enable-soap --enable-inline-optimization --enable-xml --enable-ftp --enable-gd --enable-exif --enable-mbstring  --enable-bcmath --with-fpm-systemd

在这里插入图片描述

出现错误1:
configure: error: Package requirements (libsystemd >= 209) were not met:

No package 'libsystemd' 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 SYSTEMD_CFLAGS
and SYSTEMD_LIBS to avoid the need to call pkg-config.
See the pkg-config man page for more details.

[root@server1 php-7.4.6]# yum install systemd-devel

出现错误2:

No package 'libxml-2.0' 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.

[root@server1 php-7.4.6]# yum install -y libxml2-devel

问题3:
No package 'sqlite3' 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 SQLITE_CFLAGS
and SQLITE_LIBS to avoid the need to call pkg-config.
See the pkg-config man page for more details.

[root@server1 php-7.4.6]# yum install -y sqlite-devel

问题4:
No package 'libcurl' 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 CURL_CFLAGS
and CURL_LIBS to avoid the need to call pkg-config.
See the pkg-config man page for more details.

[root@server1 php-7.4.6]# yum install -y libcurl-devel

问题5:
No package 'libpng' 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 PNG_CFLAGS
and PNG_LIBS to avoid the need to call pkg-config.
See the pkg-config man page for more details.

[root@server1 php-7.4.6]# yum install -y libpng-devel

问题6:
No package 'oniguruma' 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 ONIG_CFLAGS
and ONIG_LIBS to avoid the need to call pkg-config.
See the pkg-config man page for more details.
下载安装包:
oniguruma-6.8.2-1.el7.x86_64.rpm
oniguruma-devel-6.8.2-1.el7.x86_64.rpm


[root@server1 ~]# yum install oniguruma-* -y
[root@server1 openresty-1.17.8.2]# ./configure --prefix=/usr/local/php --enable-fpm --with-fpm-user=nginx --with-fpm-group=nginx  --with-curl --with-iconv --with-mhash --with-zlib --with-openssl --enable-mysqlnd --with-mysqli --with-pdo-mysql --disable-debug --enable-sockets --enable-soap --enable-inline-optimization --enable-xml --enable-ftp --enable-gd --enable-exif --enable-mbstring  --enable-bcmath --with-fpm-systemd



在这里插入图片描述

3.make

[root@server1 openresty-1.17.8.2]# make
[root@server1 openresty-1.17.8.2]# make install

安装完成

4.PHP的配置

[root@server1 ~]# vim .bash_profile

# .bash_profile

# Get the aliases and functions
if [ -f ~/.bashrc ]; then
        . ~/.bashrc
fi

# User specific environment and startup programs

PATH=$PATH:$HOME/bin:/usr/local/lamp/bin

export PATH


[root@server1 ~]# source .bash_profile

在这里插入图片描述
在这里插入图片描述

[root@server1 php-7.4.6]# cp php.ini-production /usr/local/lamp/php/
[root@server1 php-7.4.6]# cp php.ini-production /usr/local/lamp/php//etc/php.ini
[root@server1 php-7.4.6]# cd sapi/
[root@server1 sapi]# ls
apache2handler  cgi  cli  embed  fpm  litespeed  phpdbgcd 
[root@server1 sapi]# cd fpm
[root@server1 fpm]# vim init.d.php-fpm

13 prefix=/usr/local/lamp/php                            # 修改此处
14 exec_prefix=${prefix}

[root@server1 fpm]# cp php-fpm.service /usr/lib/systemd/system/
[root@server1 fpm]# systemctl daemon-reload
[root@server1 fpm]# systemctl status php-fpm
[root@server1 fpm]# cd /usr/local/lamp/php/
[root@server1 php]# ls
bin  etc  include  lib  php  php.ini-production  sbin  var
[root@server1 php]# cd etc
[root@server1 etc]# ls
php-fpm.conf.default  php-fpm.d  php.ini
[root@server1 etc]# cp php-fpm.conf.default php-fpm.conf
[root@server1 etc]# vim php-fpm.conf


 13 [global]
 14 ; Pid file
 15 ; Note: the default prefix is /usr/local/php/var
 16 ; Default Value: none
 17 pid = run/php-fpm.pid                          #取消注销

在这里插入图片描述

在这里插入图片描述
在这里插入图片描述

在这里插入图片描述
在这里插入图片描述

在这里插入图片描述

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值