CentOS_7下安装PHP7.3
下载PHP安装包:
官网:http://www.php.net/downloads.php
压缩包放在 /usr/local/src
wget -O下载时重命名压缩包
tar解压
cd /usr/local/src
wget -O php-7.3.2.tar.gz http://php.net/get/php-7.3.2.tar.gz/from/a/mirror
tar -xvzf php-7.3.2.tar.gz
安装:./configure —prefix参数指定安装路径
注意:以下MySQL的路径对应Linux中MySQL安装的实际位置【搜索并显示路径:which MySQL】1.--prefix=/usr/local/php 2.--with-pdo-mysql=/usr/local/mysq 3.--with-mysqli=/usr/local/mysql/bin/mysql_config 4.--with-pdo-mysql=/usr/local/mysql
cd /usr/local/php-7.3.2
yum -y install libcurl-devel
yum -y install libXpm-devel
yum -y install libxml2-devel
./configure --prefix=/usr/local/php --with-config-file-path=/usr/local/php/etc --with-pdo-mysql=/usr/local/mysql --with-mysqli=/usr/local/mysql/bin/mysql_config --with-mysql-sock=/tmp/mysql.sock --with-pdo-mysql=/usr/local/mysql --with-gd --with-png-dir=/usr/local/libpng --with-jpeg-dir=/usr/local/jpeg --with-freetype-dir=/usr/local/freetype --with-xpm-dir=/usr/ --with-zlib-dir=/usr/local/zlib --with-iconv --enable-libxml --enable-xml --enable-bcmath --enable-shmop --enable-sysvsem --enable-inline-optimization --enable-opcache --enable-mbregex --enable-fpm --enable-mbstring --enable-ftp --with-openssl --enable-pcntl --enable-sockets --with-xmlrpc --enable-zip --enable-soap --without-pear --with-gettext --enable-session --with-curl --enable-ctype
`如果这个过程报错,直接百度提示信息`
配置成功会出现以下内容
接着输入以下命令
make
make install
删除临时文件
make clean
make distclean
配置php:
到之前编译的源码包中将 php.ini-production 复制到 /usr/local/php/php.ini
cd /usr/local/src/php-7.3.2
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! 保存并退出。
启动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