欢迎光临
我们一直在努力

[Centos]编译安装PHP7.3

1、安装编译CMake

因为php7.3需要安装libzip11+的版本,但是编译libzip新版需要最新的cmake,所以系统自带的cmake版本不够,所以需要重新安装

#下载地址:https://cmake.org/download/
#工具包 git@gitee.com:bbhsky/PHP-Setup.git
yum -y remove cmake
tar zxvf cmake-3.15.2.tar.gz
cd cmake-3.15.2
./configure --prefix=/usr/local/cmake-3.15.2
make -j `grep 'processor' /proc/cpuinfo | wc -l` && make install
ln -sf /usr/local/cmake-3.15.2 /usr/local/cmake
ln -sf /usr/local/cmake/bin/* /usr/bin/
rm -rf cmake-3.15.2

2、编译安装libzip

#下载地址:https://libzip.org/download/
#工具包 git@gitee.com:bbhsky/PHP-Setup.git
yum -y remove libzip-devel libzip
tar zxvf libzip-1.5.2.tar.gz
cd libzip-1.5.2
mkdir build && cd build/
cmake ..
make -j `grep 'processor' /proc/cpuinfo | wc -l` && make install
# 添加搜索路径到配置文件
echo '/usr/local/lib64
/usr/local/lib
/usr/lib
/usr/lib64'>>/etc/ld.so.conf
# 更新配置
ldconfig -v
rm -rf libzip-1.5.2

3、编译安装php

#下载地址:http://php.net/
#工具包 git@gitee.com:bbhsky/PHP-Setup.git
tar jxvf php-7.3.8.tar.bz2
cd php-7.3.8/
./configure --prefix=/usr/local/php-7.3.8 --with-config-file-path=/usr/local/php-7.3.8/etc --with-config-file-scan-dir=/usr/local/php-7.3.8/conf.d --enable-fpm --with-fpm-user=www --with-fpm-group=www --enable-mysqlnd --with-mysqli=mysqlnd --with-pdo-mysql=mysqlnd --with-iconv-dir=/usr/local/libiconv --with-freetype-dir=/usr/local/freetype --with-jpeg-dir --with-png-dir --with-zlib --with-libxml-dir=/usr --enable-xml --disable-rpath --enable-bcmath --enable-shmop --enable-sysvsem --enable-inline-optimization --with-curl=/usr/local/curl --enable-mbregex --enable-mbstring --enable-intl --enable-pcntl --enable-ftp --with-gd --with-openssl=/usr/local/openssl --with-mhash --enable-pcntl --enable-sockets --with-xmlrpc --enable-zip --enable-soap --with-gettext --disable-fileinfo --enable-opcache --with-xsl --with-libzip

make ZEND_EXTRA_LIBS='-liconv' -j `grep 'processor' /proc/cpuinfo | wc -l`
make install
ln -sf /usr/local/php-7.3.8 /usr/local/php-7.3
ln -sf /usr/local/php-7.3 /usr/local/php-7
ln -sf /usr/local/php-7 /usr/local/php
ln -sf /usr/local/php/bin/php /usr/bin/php
ln -sf /usr/local/php/bin/phpize /usr/bin/phpize
ln -sf /usr/local/php/bin/pear /usr/bin/pear
ln -sf /usr/local/php/bin/pecl /usr/bin/pecl
ln -sf /usr/local/php/sbin/php-fpm /usr/bin/php-fpm
mkdir -p /usr/local/php/conf.d
mkdir -p /usr/local/php/etc
cp php.ini-production /usr/local/php/etc/php.ini
sed -i 's/post_max_size =.*/post_max_size = 50M/g' /usr/local/php/etc/php.ini
sed -i 's/upload_max_filesize =.*/upload_max_filesize = 50M/g' /usr/local/php/etc/php.ini
sed -i 's/;date.timezone =.*/date.timezone = PRC/g' /usr/local/php/etc/php.ini
sed -i 's/short_open_tag =.*/short_open_tag = On/g' /usr/local/php/etc/php.ini
sed -i 's/;cgi.fix_pathinfo=.*/cgi.fix_pathinfo=0/g' /usr/local/php/etc/php.ini
sed -i 's/max_execution_time =.*/max_execution_time = 300/g' /usr/local/php/etc/php.ini
sed -i 's/disable_functions =.*/disable_functions = passthru,exec,system,chroot,chgrp,chown,shell_exec,proc_open,proc_get_status,popen,ini_alter,ini_restore,dl,openlog,syslog,readlink,symlink,popepassthru,stream_socket_server/g' /usr/local/php/etc/php.ini
pear config-set php_ini /usr/local/php/etc/php.ini
pecl config-set php_ini /usr/local/php/etc/php.ini
curl -sS --connect-timeout 30 -m 60 https://getcomposer.org/installer | php -- --install-dir=/usr/local/bin --filename=composer
#写入配置文件
cat >/usr/local/php/etc/php-fpm.conf<<EOF
[global]
pid = /usr/local/php/var/run/php-fpm.pid
error_log = /usr/local/php/var/log/php-fpm.log
log_level = notice
[www]
listen = /tmp/php-cgi.sock
listen.backlog = -1
listen.allowed_clients = 127.0.0.1
listen.owner = www
listen.group = www
listen.mode = 0666
user = www
group = www
pm = dynamic
pm.max_children = 10
pm.start_servers = 2
pm.min_spare_servers = 1
pm.max_spare_servers = 6
pm.max_requests = 1024
pm.process_idle_timeout = 10s
request_terminate_timeout = 100
request_slowlog_timeout = 0
slowlog = var/log/slow.log
EOF
cp sapi/fpm/init.d.php-fpm.in /etc/init.d/php73-fpm
cp sapi/fpm/php-fpm.service.in /usr/lib/systemd/system/php-fpm73.service
chmod +x /etc/init.d/php73-fpm

以上按照正常是安装完成了,这里还有个配置需要修改

vim /usr/lib/systemd/system/php73-fpm.service
#注意这里的物理路径
[Unit]
Description=The PHP FastCGI Process Manager
After=network.target

[Service]
Type=simple
PIDFile=/usr/local/php-7.3/var/run/php-fpm.pid
ExecStart=/usr/local/php-7.3/sbin/php-fpm --nodaemonize --fpm-config /usr/local/php-7.3/etc/php-fpm.conf
ExecReload=/bin/kill -USR2 $MAINPID
PrivateTmp=true

[Install]
WantedBy=multi-user.target
赞(0)
未经允许不得转载:798VPS » [Centos]编译安装PHP7.3
分享到: 更多 (0)

评论 抢沙发

  • 昵称 (必填)
  • 邮箱 (必填)
  • 网址