php7.3.6编译安装启动&phpMyAdmin

几篇文章转载

准备玩儿一下nextcloud mysqlweb管理界面也要用一下
都需要较高版本php 直接安装最新版php7.3.6

新建用户&用户组
groupadd www
useradd -g www www

自行下载php或者下面链接下载 (我这边是下载的7.3.6)
wget “https://downloads.php.net/~cmb/php-7.3.0.tar.gz”
tar xzvf php-7.3.0.tar.gz
cd php-7.3.0

编译
–with-fpm-user=www --with-fpm-group=www
这里使用www www 用户、用户组
编译出来的程序启动,就是归属这个用户、用户组

./configure --prefix=/usr/local/php --with-fpm-user=www --with-fpm-group=www --with-curl --with-freetype-dir --with-gd --with-gettext --with-iconv-dir --with-kerberos --with-libdir=lib64 --with-libxml-dir --with-mysqli --with-openssl --with-pcre-regex --with-pdo-mysql --with-pdo-sqlite --with-pear --with-png-dir --with-jpeg-dir --with-xmlrpc --with-xsl --with-zlib --with-bz2 --with-mhash --enable-fpm --enable-bcmath --enable-libxml --enable-inline-optimization --enable-mbregex --enable-mbstring --enable-opcache --enable-pcntl --enable-shmop --enable-soap --enable-sockets --enable-sysvsem --enable-sysvshm --enable-xml --enable-zip --enable-fpm

编译这里会出N多报错

configure: error: libxml2 not found. Please check your libxml2 installation.

yum install -y libxml2-devel

configure: error: Please reinstall the BZip2 distribution

yum install -y bzip2-devel

configure: error: cURL version 7.15.5 or later is required to compile php with cURL support

yum install -y curl-devel

configure: error: jpeglib.h not found.

yum install -y libjpeg-devel

configure: error: png.h not found.

yum install -y libpng-devel

configure: error: freetype-config not found.

yum install -y freetype-devel

configure: error: xslt-config not found. Please reinstall the libxslt >= 1.1.0 distribution

yum install -y libxslt-devel

configure: error: Please reinstall the libzip distribution

yum install -y libzip-devel

checking for libzip… configure: error: system libzip must be upgraded to version >= 0.11

#先删除旧版本
yum remove -y libzip
 
#下载编译安装
wget https://nih.at/libzip/libzip-1.2.0.tar.gz
tar -zxvf libzip-1.2.0.tar.gz
cd libzip-1.2.0
./configure
make && make install

off_t undefined 报错

checking libzip... yes
checking for the location of zlib... /usr
checking for pkg-config... (cached) /usr/bin/pkg-config
checking for libzip... in default path: found in /usr/local
checking for zip_open in -lzip... yes
checking for zip_file_set_encryption in -lzip... yes
checking for zip_libzip_version in -lzip... no
checking stdbool.h usability... yes
checking stdbool.h presence... yes
checking for stdbool.h... yes
checking fts.h usability... yes
checking fts.h presence... yes
checking for fts.h... yes
checking for int8_t... (cached) yes
checking for int16_t... (cached) yes
checking for int32_t... (cached) yes
checking for int64_t... (cached) yes
checking for uint8_t... (cached) yes
checking for uint16_t... (cached) yes
checking for uint32_t... (cached) yes
checking for uint64_t... (cached) yes
checking for ssize_t... yes
checking size of short... (cached) 2
checking size of int... (cached) 4
checking size of long... (cached) 8
checking size of long long... (cached) 8
checking size of off_t... 0
configure: error: off_t undefined; check your library configuration

off_t 类型是在 头文件 unistd.h中定义的,
在32位系统 编程成 long int ,64位系统则编译成 long long int ,
在进行编译的时候 是默认查找64位的动态链接库,
但是默认情况下 centos 的动态链接库配置文件/etc/ld.so.conf里并没有加入搜索路径,
这个时候需要将 /usr/local/lib64 /usr/lib64 这些针对64位的库文件路径加进去。

#添加搜索路径到配置文件
echo '/usr/local/lib64
/usr/local/lib
/usr/lib
/usr/lib64'>>/etc/ld.so.conf
 
#然后 更新配置
ldconfig -v

解决 Cannot find OpenSSL’s
yum install openssl openssl-devel

开始安装

make && make install

报错
usr/local/include/zip.h:59:21: fatal error: zipconf.h: No such file or directory

cp /usr/local/lib/libzip/include/zipconf.h /usr/local/include/zipconf.h

配置目录

cp php.ini-production /usr/local/php/lib/php.ini
cp /usr/local/php/etc/php-fpm.conf.default /usr/local/php/etc/php-fpm.conf
ln -s /usr/local/php/sbin/php-fpm /usr/local/bin

cd /usr/local/php/etc/php-fpm.d
cp www.conf.default ./www.conf
此后可省略,直接使用

    /usr/local/php/sbin/php-fpm #启动php-fpm
    ———————————————————————————————————————————————————————————————————————————————————————————
    vim www.conf

添加

[www]
listen = 127.0.0.1:9080   
listen.mode = 0666      
 
user = www  #php代码目录权限 需要跟这个一致,
group = www #php代码目录权限 需要跟这个一致
 
pm = dynamic
pm.max_children = 128
pm.start_servers = 20
pm.min_spare_servers = 5
pm.max_spare_servers = 35
pm.max_requests = 10000
 
rlimit_files = 1024
 
slowlog = log/$pool.log.slow

加入systemctl服务

cd /usr/local/php-7.3.0/sapi/fpm
cp php-fpm.service /usr/lib/systemd/system/

启动

systemctl start php-fpm

php命令环境

export PATH=$PATH:/usr/local/php/bin

Apache下创建php测试首页测试

作者:一曲微茫度此生
来源:CSDN
原文:https://blog.csdn.net/weixin_41782053/article/details/86717702
版权声明:本文为博主原创文章,转载请附上博文链接!

编译安装完成无法解析php解决

安装apache的mod_php模块:

yum install mod_php71w 

没有安装包的话添加一下源

rpm -Uvh https://mirror.webtatic.com/yum/el7/epel-release.rpm
rpm -Uvh https://mirror.webtatic.com/yum/el7/webtatic-release.rpm

然后在httpd配置文件**/etc/httpd/conf.d.modules.d/**下会有一个10-php.conf文件
加入


         SetHandler "proxy:fcgi://127.0.0.1:9000"

并注掉其它内容 不然php版本显示不正确

/etc/httpd/conf.d/php.conf最后三行注释掉 不然Apache启动不了

然后重新启动Apache

phpMyAdmin直接使用提示错误
mysqli_real_connect(): (HY000/2002): No such file or directory
错误原因默认php中配置的mysqli没有与实际的mysql.sock对应正确
可以登录mysql之后使用STATUS获取mysql.sock路径
在php.ini中配置好mysqli路径
php7.3.6编译安装启动&phpMyAdmin_第1张图片

vim /usr/local/php/lib/php.ini

mysqli.default_socket = /var/lib/mysql/mysql.sock

pdo_mysql.default_socket=/var/lib/mysql/mysql.sock

即可正常使用

php7.3 yum安装
rpm -ivh https://mirrors.tuna.tsinghua.edu.cn/remi/enterprise/remi-release-6.rpm

你可能感兴趣的:(php7.3.6编译安装启动&phpMyAdmin)