源码编译安装php7.4 + nginx配置

1. 下载解压PHP7.4

  1. php源码包下载地址 各版本源码包 https://www.php.net/releases/
  2. 解压缩 tar -zxvf 命令
    tar -zxvf php-7.4.33.tar.gz

2. 安装PHP + FPM

  1. 进入解压后的 PHP源码 目录 php-7.4.33

    cd php-7.4.33
  2. 执行./configure 指令

    ./configure --with-config-file-path=/usr/local/etc --with-openssl --with-curl --with-pear --with-mysqli --with-pdo_mysql --with-sqlite3 \
    --with-zip --with-zlib --enable-bcmath --enable-ctype --enable-gd -enable-calendar --enable-fileinfo --enable-gd --enable-json --enable-mbstring --enable-pdo \
    --enable-filter --enable-session --enable-simplexml --enable-sockets --enable-xml --enable-xmlreader \
    --enable-pcntl --enable-fpm
  3. 其中可能会不通过 需要安装相应的开发包

    apt install libpng-dev libzip-dev libonig-dev libsqlite3-dev libcurl4-gnutls-dev libevent-dev
  4. 再次执行 第二步操作

  5. 执行make安装命令 需要在 root 用户环境下执行,完成安装

    make && make install
  6. 拷贝 配置文件

    cp php-7.4.33/php.ini-development /usr/local/etc/php.ini
    cd /usr/local/etc
    cp php-fpm.conf.default php-fpm.conf
    cp php-fpm.d/www.conf.default php-fpm.d/www.conf
  7. 配置 www.conf
    user www-data
    group www-data

  8. 安装redis扩展

    # 下载phpredis源码
    git clone https://gitee.com/mirrors/phpredis.git
    cd phpredis
    # 切换仓库分支
    git checkout release/5.3.7
    # 执行php扩展命令
    phpize
    # 执行配置命令 作为php扩展
    ./configure --with-php-config=/usr/local/bin/php-config
    # 执行编译安装命令
    make && make install
    # 添加 redis.io 扩展
    vim /usr/local/etc/php.ini
    # 添加一行代码
    extension=redis.so
  9. Call to undefined function think\captcha\imagettftext错误

    # 下载freetype2源码包 https://download.savannah.gnu.org/releases/freetype/
    # 解压进入源码目录
    ./configure
    make && make install
    # 默认 freetype2 安装目录为 /usr/include/freetype2
    # 重新编译安装 php
    ./configure --with-config-file-path=/usr/local/etc --with-openssl --with-curl --with-pear --with-mysqli --with-pdo_mysql --with-sqlite3 \
    --with-zip --with-zlib --enable-bcmath --enable-ctype --enable-gd -enable-calendar --enable-fileinfo --enable-gd --enable-json --enable-mbstring --enable-pdo \
    --enable-filter --enable-session --enable-simplexml --enable-sockets --enable-xml --enable-xmlreader \
    --enable-pcntl --enable-fpm --with-freetype=/usr/include/freetype2
    make && make install

3. Nginx 1.14配置

server_name xxx.cc;
root /xxx/fastadmin/public;
index index.html index.htm index.php;
location / {
try_files $uri $uri/ /index.php?$query_string;
}
location ~ \.php$ {
include snippets/fastcgi-php.conf;
fastcgi_pass 127.0.0.1:9000;
}
posted @   gz_xiaohai  阅读(869)  评论(0编辑  收藏  举报
相关博文:
阅读排行:
· DeepSeek 开源周回顾「GitHub 热点速览」
· 物流快递公司核心技术能力-地址解析分单基础技术分享
· .NET 10首个预览版发布:重大改进与新特性概览!
· AI与.NET技术实操系列(二):开始使用ML.NET
· 单线程的Redis速度为什么快?
点击右上角即可分享
微信分享提示