nano 新增用户和用户组
groupadd www
useradd -g www www
下载PHP源码
cd /usr/local/src
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
编译
./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
`注:--with-fpm-user=www --with-fpm-group=www
这里使用www www 用户、用户组
编译出来的程序启动,就是归属这个用户、用户组`
编译出错
configure: error: libxml2 not found. Please check your libxml2 installation.
安装相关组件
yum install -y libxml2-devel bzip2-devel curl-devel libjpeg-devel libpng-devel freetype-devel libxslt-devel libzip-devel openssl-devel
libzip版本过低
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 报错
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
安装
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
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
加入 systemtl 服务
cd /usr/local/src/php-7.3.0/sapi/fpm
cp php-fpm.service /usr/lib/systemd/system/
启动
[root@centos fpm]# systemctl start php-fpm
[root@centos 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 Wed 2019-03-06 10:18:37 CST; 11s ago
Main PID: 20555 (php-fpm)
CGroup: /system.slice/php-fpm.service
├─20555 php-fpm: master process (/usr/local/php/etc/php-fpm.conf)
├─20556 php-fpm: pool www
├─20557 php-fpm: pool www
├─20558 php-fpm: pool www
├─20559 php-fpm: pool www
├─20560 php-fpm: pool www
├─20561 php-fpm: pool www
├─20562 php-fpm: pool www
├─20563 php-fpm: pool www
├─20564 php-fpm: pool www
├─20565 php-fpm: pool www
├─20566 php-fpm: pool www
├─20567 php-fpm: pool www
├─20568 php-fpm: pool www
├─20569 php-fpm: pool www
├─20570 php-fpm: pool www
├─20571 php-fpm: pool www
├─20572 php-fpm: pool www
├─20573 php-fpm: pool www
├─20574 php-fpm: pool www
└─20575 php-fpm: pool www
测试
mkdir -p /home/www/webroot/php
cd /home/www/webroot/php
vim test.php
输入
<?php
phpinfo();
?>
php 命令环境
在$HOME/.bash_profile里新增内容为
export PATH=$PATH:/usr/local/php/bin
source $HOME/.bash_profile
「一键投喂 软糖/蛋糕/布丁/牛奶/冰阔乐!」
(๑>ڡ<)☆谢谢老板~
使用微信扫描二维码完成支付