源码编译安装php7.4 + nginx配置
1. 下载解压PHP7.4
- php源码包下载地址 各版本源码包 https://www.php.net/releases/
- 解压缩 tar -zxvf 命令
tar -zxvf php-7.4.33.tar.gz
2. 安装PHP + FPM
-
进入解压后的 PHP源码 目录 php-7.4.33
cd php-7.4.33 -
执行./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 -
其中可能会不通过 需要安装相应的开发包
apt install libpng-dev libzip-dev libonig-dev libsqlite3-dev libcurl4-gnutls-dev libevent-dev -
再次执行 第二步操作
-
执行make安装命令
需要在 root 用户环境下执行
,完成安装make && make install -
拷贝 配置文件
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 -
配置 www.conf
user www-data
group www-data
-
安装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 -
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; }
【推荐】国内首个AI IDE,深度理解中文开发场景,立即下载体验Trae
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步
· DeepSeek 开源周回顾「GitHub 热点速览」
· 物流快递公司核心技术能力-地址解析分单基础技术分享
· .NET 10首个预览版发布:重大改进与新特性概览!
· AI与.NET技术实操系列(二):开始使用ML.NET
· 单线程的Redis速度为什么快?