centos7 源码安装指定版本的php7
很多时候可能会遇到需要手动源码安装软件的时候,所以自己实践了一把,并且把安装过程中遇到的问题,以及在网上找到的解决办法(实测有效)都记录下来,方便日后学习实践。
1. 系统环境
# cat /etc/redhat-release
CentOS Linux release 7.6.1810 (Core)
// 编译php之前需要有gcc和autoconfig环境
# yum install -y gcc-c++ gcc
# yum install autoconf
2. 新增用户和用户组
# groupadd www
# useradd -g www www
3. 下载php
# wget https://www.php.net/distributions/php-7.3.25.tar.gz
# tar -zxvf php-7.3.25.tar.gz
# cd php-7.3.25
4. 编译
--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
5. 编译错误时,解决依赖
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 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
#如下操作与上面等效
vim /etc/ld.so.conf
#添加如下几行
/usr/local/lib64
/usr/local/lib
/usr/lib /usr/lib64
#保存退出
:wq
ldconfig -v # 使之生效
#然后 更新配置
ldconfig -v
# 安装
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
configure过后,make报错
/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
6.重新编译,成功输出
Installing shared extensions: /usr/local/php/lib/php/extensions/no-debug-non-zts-20180731/
Installing PHP CLI binary: /usr/local/php/bin/
Installing PHP CLI man page: /usr/local/php/php/man/man1/
Installing PHP FPM binary: /usr/local/php/sbin/
Installing PHP FPM defconfig: /usr/local/php/etc/
Installing PHP FPM man page: /usr/local/php/php/man/man8/
Installing PHP FPM status page: /usr/local/php/php/php/fpm/
Installing phpdbg binary: /usr/local/php/bin/
Installing phpdbg man page: /usr/local/php/php/man/man1/
Installing PHP CGI binary: /usr/local/php/bin/
Installing PHP CGI man page: /usr/local/php/php/man/man1/
Installing build environment: /usr/local/php/lib/php/build/
Installing header files: /usr/local/php/include/php/
Installing helper programs: /usr/local/php/bin/
program: phpize
program: php-config
Installing man pages: /usr/local/php/php/man/man1/
page: phpize.1
page: php-config.1
Installing PEAR environment: /usr/local/php/lib/php/
Warning: "continue" targeting switch is equivalent to "break". Did you mean to use "continue 2"? in phar:///home/flame/software/php-7.3.0/pear/install-pear-nozlib.phar/PEAR/PackageFile/v2/Validator.php on line 1933
[PEAR] Archive_Tar - installed: 1.4.3
[PEAR] Console_Getopt - installed: 1.4.1
[PEAR] Structures_Graph- installed: 1.1.1
[PEAR] XML_Util - installed: 1.4.2
[PEAR] PEAR - installed: 1.10.5
Wrote PEAR system config file at: /usr/local/php/etc/pear.conf
You may want to add: /usr/local/php/lib/php to your php.ini include_path
/home/flame/software/php-7.3.0/build/shtool install -c ext/phar/phar.phar /usr/local/php/bin
ln -s -f phar.phar /usr/local/php/bin/phar
Installing PDO headers: /usr/local/php/include/php/ext/pdo/
7. 配置php.ini和php-fpm,建立目录
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
vim www.conf
输入
[www]
listen = 127.0.0.1:9000
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
编辑php.ini替换换 ;cgi.fix_pathinfo=1 为 cgi.fix_pathinfo=0 快捷命令:
8. 加入 systemtl 服务
cd /home/flame/software/php-7.3.25/sapi/fpm
cp php-fpm.service /usr/lib/systemd/system/
启动php-ftpm
systemctl start php-fpm #查看状态 systemctl status php-fpm #得到输出
● php-fpm.service - The PHP FastCGI Process Manager
Loaded: loaded (/usr/lib/systemd/system/php-fpm.service; disabled; vendor preset: disabled)
Active: active (running) since Thu 2018-12-27 16:13:16 CST; 2s ago
Main PID: 16835 (php-fpm)
CGroup: /system.slice/php-fpm.service
├─16835 php-fpm: master process (/usr/local/php/etc/php-fpm.conf)
├─16836 php-fpm: pool www
├─16837 php-fpm: pool www
├─16838 php-fpm: pool www
├─16839 php-fpm: pool www
├─16840 php-fpm: pool www
├─16841 php-fpm: pool www
├─16842 php-fpm: pool www
├─16843 php-fpm: pool www
├─16844 php-fpm: pool www
├─16845 php-fpm: pool www
├─16846 php-fpm: pool www
├─16847 php-fpm: pool www
├─16848 php-fpm: pool www
├─16849 php-fpm: pool www
├─16850 php-fpm: pool www
├─16851 php-fpm: pool www
├─16852 php-fpm: pool www
├─16853 php-fpm: pool www
├─16854 php-fpm: pool www
└─16855 php-fpm: pool www Dec 27 16:13:16 iZj6cas4fyg41lxhngh1z0Z systemd[1]: Started The PHP FastCGI Process Manager.
9. php命令环境
在$HOME/.profile里新增内容为
export PATH=$PATH:/usr/local/php/bin
centos7 源码安装指定版本的php7的更多相关文章
- centos7源码安装Python3的前提条件
centos7源码安装Python3的前提条件: # yum -y install openssl-devel bzip2-devel expat-devel gdbm-devel readline- ...
- CentOS7源码安装qbittorrent最新版本
CentOS的软件 yum 里 yum search qbittorrent yum info qbittorrent 找到的是3.37版本 官网最新的是4.12版本.但需要源码安装: 官网下载最新版 ...
- centos7源码安装mysql5.7.19
centos7源码包安装mysql5.7 5.7.20安装方法和5.7.19的一样. 1.安装前准备 清空环境.安装相应的软件包 1>关闭防火墙和SELinux 2>配置yum源(阿里云, ...
- Centos7源码安装mysql及读写分离,互为主从
Linux服务器 -源码安装mysql 及读写分离,互为主从 一.环境介绍: Linux版本: CentOS 7 64位 mysq版本: mysql-5.6.26 这是我安装时所使用的版本, ...
- CentOS7 源码安装 PostgreSQL 12
PostgreSQL 12 源码安装 Table of Contents 1. 下载 2. 准备环境 3. 编译安装 4. 设置环境变量 5. 初始化数据库 6. 配置参数文件 6.1. postgr ...
- Centos7源码安装Apache和PHP
源码安装Apache 安装需要的依赖 yum -y install gcc autoconf automake make pcre pcre-devel openssl openssl-devel# ...
- CentOS7源码安装Redis5.0.4非关系型数据库
源码安装redis-5.0.4 一. 下载redis 1. 需要连接网络 二. 案例(另一种安装方法) [root@localhost ~]# wget http://download.redis.i ...
- centos7源码安装Apache及Tomcat
源码安装Apache (1) 一.通过 https://apr.apache.org/ 下载 APR 和 APR-util 通过 http://httpd.apache.org/download.c ...
- centos7 源码安装goaccess
1. 使用yum安装在不同服务器上可能失败, 推荐使用源码安装goaccess # 安装依赖 yum install -y ncurses-devel GeoIP-devel.x86_64 tokyo ...
随机推荐
- kali2020.4安装openvas(gvm)
记录一下,方便复习 1.更换kali源,默认源注释掉. sudo vim /etc/apt/sources.list 中科大 deb http://mirrors.ustc.edu.cn/kali k ...
- python+selenium基础篇,By定位元素
1.By定位和find_element_by_XXXXXX是一样的,如下图所示,定位元素的方法都是一样的 2.使用By定位代码如下所示 from selenium import webdriver f ...
- 【题解】Grape luogu1156改 dp
考试时被数据坑了 题目 原题 传送门 题目描述: 众所周知的是oyyf 沉迷葡萄,今天的oyyf为了葡萄溜到了He 大佬家的葡萄园偷葡萄,可惜的是还没偷到葡萄He 大佬就来葡萄园了,吓的oyyf 直接 ...
- Python 机器学习实战 —— 监督学习(下)
前言 近年来AI人工智能成为社会发展趋势,在IT行业引起一波热潮,有关机器学习.深度学习.神经网络等文章多不胜数.从智能家居.自动驾驶.无人机.智能机器人到人造卫星.安防军备,无论是国家级军事设备还是 ...
- ubuntu开机卡在/dev/sda* clean
问题描述: ①Ubuntu通过再生龙从一台笔记本还原到另外一台笔记本(硬盘到硬盘),开机后卡在自检界面: ②备份前的笔记本为17年发布的笔记本,还原后的笔记本为2020款发布的笔记本 从网上搜了一大篇 ...
- 理解css行高(line-height)
首先我们要明确 line-height 的定义,line-height指的是两条文字基线之间的距离. 行内框盒子模型 所有内联元素的样式表现都与行内框盒子模型有关.所以这个概念是非常重要的. < ...
- .Net Core 3.1简单搭建微服务
学如逆水行舟,不进则退!最近发现微服务真的是大势所趋,停留在公司所用框架里已经严重满足不了未来的项目需要了,所以抽空了解了一下微服务,并进行了代码落地. 虽然项目简单,但过程中确实也学到了不少东西. ...
- 48、django工程(model)
48.1.数据库配置: 1.django默认支持sqlite,mysql, oracle,postgresql数据库: (1)sqlite: django默认使用sqlite的数据库,默认自带sqli ...
- hdu 6034 贪心模拟 好坑
关键在排序!!! 数组间的排序会超时,所以需要把一个数组映射成一个数字,就可以了 #include <bits/stdc++.h> using namespace std; typedef ...
- SQL Server数据库阻塞,死锁查询
sql 查询卡顿数据库 SELECT SPID=p.spid, DBName = convert(CHAR(20),d.name), ProgramName = program_name, Login ...