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

1.下载php安装包

2.解压

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

lnmp架构(1):php的源码安装与配置(详细图解)_第1张图片
如果此时出现如下错误

[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

lnmp架构(1):php的源码安装与配置(详细图解)_第2张图片
lnmp架构(1):php的源码安装与配置(详细图解)_第3张图片

 ./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

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

出现错误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



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

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

lnmp架构(1):php的源码安装与配置(详细图解)_第6张图片
lnmp架构(1):php的源码安装与配置(详细图解)_第7张图片

[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                          #取消注销

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

lnmp架构(1):php的源码安装与配置(详细图解)_第9张图片
lnmp架构(1):php的源码安装与配置(详细图解)_第10张图片

lnmp架构(1):php的源码安装与配置(详细图解)_第11张图片
lnmp架构(1):php的源码安装与配置(详细图解)_第12张图片

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

你可能感兴趣的:(企业实战,小技巧,lnmp架构,php,linux,运维)