Centos8 安装php7.3

前言

闲来无事源码编译安装php7.3

安装依赖

yum install -y gcc gcc-c++
yum -y install libxml2-devel openssl-devel curl-devel libjpeg-devel libpng-devel libicu-devel freetype-devel openldap-devel openldap openldap-devel

安装php

  1. 下载解压php源码包
    wget https://www.php.net/distributions/php-7.3.33.tar.bz2
    tar --bzip -xvf php-7.3.33.tar.bz2
    cd php-7.3.33
  2. configure
./configure --prefix=/usr/local/php73 \
--with-config-file-path=/usr/local/php73/etc \
--enable-fpm \
--with-fpm-user=www \
--with-fpm-group=www \
--enable-mysqlnd \
--with-mysqli=mysqlnd \
--with-pdo-mysql=mysqlnd \
--enable-mysqlnd-compression-support \
--with-iconv-dir \
--with-freetype-dir \
--with-jpeg-dir \
--with-png-dir \
--with-zlib \
--with-libxml-dir \
--enable-xml \
--disable-rpath \
--enable-bcmath \
--enable-shmop \
--enable-sysvsem \
--enable-inline-optimization \
--with-curl \
--enable-mbregex \
--enable-mbstring \
--enable-intl \
--enable-ftp \
--with-gd \
--enable-gd-jis-conv \
--with-openssl \
--with-mhash \
--enable-pcntl \
--enable-sockets \
--with-xmlrpc \
--enable-zip \
--enable-soap \
--with-gettext \
--disable-fileinfo \
--enable-opcache \
--with-pear \
--with-ldap=shared \
--without-gdbm
不同系统configure过程中报错各不相同 只记录遇到的
问题1:configure: error: Cannot find ldap libraries in /usr/lib
解决方法:cp -frp /usr/lib64/libldap* /usr/lib
备注:64位系统才会遇到
问题2:configure: error: Please reinstall the libzip distribution
解决方法:要预先安装cmake,此处使用了yum源自带的cmake 3.2版本,源码安装cmake版本一定要大于3
yum install cmake
cmake --version
wget https://libzip.org/download/libzip-1.5.2.tar.gz
tar -zxf libzip-1.5.2.tar.gz
cd libzip-1.5.2
mkdir build
cd build/
cmake ..
make -j4
make install
问题3: configure: error: off_t undefined; check your library configuration
在进行编译的时候 是默认查找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
ln -s /usr/local/php73/bin/* /usr/bin/
ln -s /usr/local/php73/sbin/* /usr/sbin/
  1. 安装make工具
    如果提示make命令找不到,则才需要安装make工具
    yum -y install gcc automake autoconf libtool make
  2. 编译安装
    make && make install

安装nginx并配置php

获取php.ini默认目录 :php -r “phpinfo();” | grep ‘php.ini’
把源码中的php.ini文件copy到指定目录:cp php.ini-development /usr/local/php7.3.33/lib/php.ini
cp /usr/local/php7.3.33/etc/php-fpm.d/www.conf.default www.conf
修改www.config中的user和group值,php-fpm是默认配置是以apache启动的,user和group是www用户
vi www.conf
user = nginx
group = nginx
复制源码中的 init.d.php-fpm 到指定目录以service启动php-fpm
cp php-7.3.33/sapi/fpm/init.d.php-fpm /etc/init.d/
mv init.d.php-fpm php-fpm
service php-fpm start
安装nginx yum install nginx
修改nginx的默认配置,指向自己的项目目录
vi /etc/nginx/nginx.conf
server {
listen 80 default_server;
listen [::]:80 default_server;
server_name _;
root /data/www/refresh/public;

    # Load configuration files for the default server block.
    include /etc/nginx/default.d/*.conf;

    location / {
    }

    location ~ \.php$ {
        fastcgi_pass 127.0.0.1:9000;
        fastcgi_index index.php;
        fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
        include fastcgi_params;
    }

    error_page 404 /404.html;
        location = /40x.html {
    }

    error_page 500 502 503 504 /50x.html;
        location = /50x.html {
    }
}

启动nginx
service nginx start

安装配置redis

yum install redis
vi /etc/redis.conf
修改点
bind 127.0.0.1
”protected-mode yes“改为”protected-mode no“
”daemonize no“为”daemonize yes”
要加密码验证就去掉requirepass 注释
启动服务:redis-server /etc/redis.conf &
关闭服务:redis-cli -a <密码> -h 127.0.0.1 -p <端口> shutdown

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 1
    评论
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值