源码安装php
-- CentOS卸载自带的PHP
yum remove php-common
装php命令
./configure --prefix=/usr/local/php --with-apxs2=/usr/local/apache2/bin/apxs --with-mysql=/usr/local/mysql --with-config-file-path=/usr/local/php/etc
查看端口
netstat -antp
安装PHP7.3.5
安装依赖库
yum -y install libjpeg libjpeg-devel libpng libpng-devel freetype freetype-devel libxml2 libxml2-devel mysql pcre-devel
安装7.3版本时候安装
yum -y install curl-devel libxslt-devel libzip
移除旧的libzip:
yum remove libzip
安装低版本的libzip
curl-O 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
echo '/usr/local/lib64 /usr/local/lib /usr/lib /usr/lib64'>>/etc/ld.so.conf && ldconfig -v
./configure --prefix=/usr/local/php --with-config-file-path=/usr/local/php/etc --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-xmlrpc --with-xsl --with-zlib --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-xml --enable-zip --enable-fileinfo
报错:/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
编译安装
make && make install
配置服务
cp php.ini-production /usr/local/php/php.ini
复制启动脚本
cp ./sapi/fpm/init.d.php-fpm /etc/init.d/php-fpm
chmod +x /etc/init.d/php-fpm
修改php-fpm配置文件
cd /usr/local/php/etc
cp php-fpm.conf.default php-fpm.conf
vim php-fpm.conf
去掉pid = run/php-fpm.pid前面的分号。:wq! 保存并退出。
否则关闭服务的时候会报这样的错误Gracefully shutting down php-fpm warning, no pid file found - php-fpm is not running ?
创建php-fpm服务
chkconfig --add php-fpm
启动php:
/etc/init.d/php-fpm start #php-fpm启动命令
/etc/init.d/php-fpm stop #php-fpm停止命令
/etc/init.d/php-fpm restart #php-fpm重启命令
ps -ef | grep php #查看是否已经成功启动PHP
添加环境变量
vim /etc/profile
在最后添加
#PHP
PATH=$PATH:/usr/local/nginx/sbin:/usr/local/php/bin
export PATH
修改完成后执行下面命令让生效
source /etc/profile
编译mysql扩展和mysqli扩展( php7.3 不用编译 mysqli mysql文件也找不到 )
进入源码包
cd ext/mysqli
/usr/local/php/bin/phpize ./configure --with-php-config=/usr/local/php/bin/php-config --with-mysql=/usr/local/mysql/
make && make install
phpize时 报错:Cannot find autoconf. Please check your autoconf installation and the
$PHP_AUTOCONF environment variable. Then, rerun this script.
解决办法
yum install autoconf
或者
curl -OL http://ftpmirror.gnu.org/autoconf/autoconf-latest.tar.gz
tar xzf autoconf-latest.tar.gz
cd autoconf-*
./configure --prefix=/usr/local
make && make install
make的时候报错:make: *** No targets specified and no makefile found. Stop.
解决办法