groupadd www
useradd -g www www
httpd-devel
,如果没有 httpd-devel ,在安装 PHP 时不会生成libphp7.so
文件: yum -y install httpd-devel
安装 php 7.3 需要的一些依赖库包和一些其他依赖的扩展库:
yum install -y autoconf automake libtool re2c libxml* openssl* BZip2* libcurl* libjpeg* libpng* libXpm* libzip* zlib* freetype* pcre* flex bison tar get
configure: error: xslt-config not found. Please reinstall the libxslt >= 1.1.0 distribution
yum install -y libxslt-devel
configure: error: Please reinstall the BZip2 distribution
yum install -y bzip2-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
configure: error: off_t undefined; check your library configuration
vim /etc/ld.so.conf
#添加如下几行
/usr/local/lib64
/usr/local/lib
/usr/lib
/usr/lib64
#保存退出
:wq
ldconfig -v # 使之生效
make: *** [ext/zip/php_zip.lo] Error 1
在安装完新版的 libzip 时可能会出现打不到 zipconf.h,
手动复制一下 cp /usr/local/lib/libzip/include/zipconf.h /usr/local/include/zipconf.h
当配置PHP时出现 make: *** [ext/fileinfo/libmagic/apprentice.lo] Error 1 时
是因为服务器内存不足1G。
只需要在配置命令中添加 --disable-fileinfo即可
Disable fileinfo support 禁用 fileinfo,搞定
https://www.php.net/distributions/php-7.3.6.tar.gz
下载
php-7.3.6.tar.gz
tar -zxvf php-7.3.6.tar.gz
cd ./php-7.3.6
./configure --help
直接输入
./configure \
--prefix=/usr/local/php \
--with-config-file-path=/usr/local/php/etc \
--with-fpm-user=www \
--with-fpm-group=www \
--with-zlib-dir \
--with-freetype-dir \
--with-zlib-dir=DIR \
--with-pcre-dir \
--with-libzip=DIR \
--enable-mbstring \
--with-libxml-dir=/usr \
--enable-xmlreader \
--enable-xmlwriter \
--enable-soap \
--enable-calendar \
--with-curl \
--with-zlib \
--with-gd \
--with-pdo-sqlite \
--with-pdo-mysql \
--with-mysqli \
--with-mysql-sock \
--enable-mysqlnd \
--disable-rpath \
--enable-inline-optimization \
--with-bz2 \
--with-zlib \
--enable-sockets \
--enable-sysvsem \
--enable-sysvshm \
--enable-pcntl \
--enable-mbregex \
--enable-exif \
--enable-bcmath \
--with-mhash \
--enable-zip \
--with-pcre-regex \
--with-jpeg-dir=/usr \
--with-png-dir=/usr \
--with-openssl \
--enable-ftp \
--with-kerberos \
--with-gettext \
--with-xmlrpc \
--with-xsl \
--enable-fpm \
--enable-opcache \
--disable-fileinfo
make && make install
php-ini:
源码包里面有配置文件:
php.ini-development 测试开发环境
php.ini-production 生产环境
复制一份到指定的目录下
(根据自己的情况选用,自己可以对比下这两个文件的差异):
cd /home/php-7.3.6
cp php.ini-production /usr/local/php/etc/php.ini
cp /usr/local/php/etc/php-fpm.conf.default /usr/local/php/etc/php-fpm.conf
cp /usr/local/php/etc/php-fpm.d/www.conf.default /usr/local/php/etc/php-fpm.d/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
slowlog = log/$pool.log.slow
ln -s /usr/local/php/sbin/php-fpm /usr/local/bin
加入 systemtl 服务
cp /home/php-7.3.6/sapi/fpm/php-fpm.service /usr/lib/systemd/system/
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 Sat 2019-06-22 15:39:06 CST; 7s ago
Main PID: 15563 (php-fpm)
CGroup: /system.slice/php-fpm.service
├─15563 php-fpm: master process (/usr/local/php/etc/php-fpm.conf)
├─15564 php-fpm: pool www
├─15565 php-fpm: pool www
├─15566 php-fpm: pool www
├─15567 php-fpm: pool www
├─15568 php-fpm: pool www
├─15569 php-fpm: pool www
├─15570 php-fpm: pool www
├─15571 php-fpm: pool www
├─15572 php-fpm: pool www
├─15573 php-fpm: pool www
├─15574 php-fpm: pool www
├─15575 php-fpm: pool www
├─15576 php-fpm: pool www
├─15577 php-fpm: pool www
├─15578 php-fpm: pool www
├─15579 php-fpm: pool www
├─15580 php-fpm: pool www
├─15581 php-fpm: pool www
├─15582 php-fpm: pool www
└─15583 php-fpm: pool www
Jun 22 15:39:06 VM_0_17_centos systemd[1]: Started The PHP FastCGI Process M....
Jun 22 15:39:06 VM_0_17_centos systemd[1]: Starting The PHP FastCGI Process ....
Hint: Some lines were ellipsized, use -l to show in full.
export PATH=$PATH:/usr/local/php/bin
source /etc/profile
php-v