Centos 安装 PHP

Centos版本:8.4

PHP版本:8.1.8

下载地址http://php.net/downloads.php

上传目录:/usr/local/src

安装目录:/usr/local/php

参考资料PHP官网

 

编译安装

# 进入源码包目录
cd /usr/local/src/

# 解压
tar zxf php-8.1.8.tar.gz
cd php-8.1.8
# 配置,开启所需扩展 ./configure --prefix=/usr/local/php --enable-fpm --enable-gd --enable-pcntl --enable-opcache --with-openssl --with-pdo-mysql --with-curl --with-zlib --with-zip # 编译安装 make && make install # 添加环境变量 echo "export PATH=$PATH:/usr/local/php/bin" >> /etc/profile source /etc/profile

 

修改配置

 # 添加配置文件,解压包里操作

cp php.ini-development /usr/local/php/lib/php.ini
cp sapi/fpm/php-fpm /usr/local/php/bin/

# 添加配置文件,安装目录里操作

cd /usr/local/php/
cp etc/php-fpm.conf.default etc/php-fpm.conf
cp etc/php-fpm.d/www.conf.default etc/php-fpm.d/www.conf

# 修改配置文件

vim etc/php-fpm.d/www.conf

user = www-data
group = www-data

# 可选 listen
= /dev/shm/fpm-cgi.sock listen.owner = www-data listen.group = www-data

vim lib/php.ini

cgi.fix_pathinfo=0

# 启动 php-fpm 服务

php-fpm

# 重启 php-fpm 服务

ps aux|grep php-fpm
kill 主进程IDphp-fpm

 

问题集锦

Package 'libxml-2.0', required by 'virtual:world', not found

yum install -y libxml2-devel

Package 'sqlite3', required by 'virtual:world', not found

yum install -y sqlite-devel

Package 'libcurl', required by 'virtual:world', not found

yum install -y libcurl-devel.x86_64

Package 'libpng', required by 'virtual:world', not found

yum install -y libpng-devel

Package 'libzip', required by 'virtual:world', not found

# 下载libzip,地址:https://libzip.org/download/
wget https://libzip.org/download/libzip-1.8.0.tar.gz
tar -zxf libzip-1.8.0.tar.gz
cd libzip-1.8.0
mkdir build
cd build
cmake ..
make
make test
make install

# 回到PHP解压目录,带上变量再来一遍
./configure *** PKG_CONFIG_PATH=/usr/local/lib64/pkgconfig/

 

Package 'oniguruma', required by 'virtual:world', not found

待解决

configure: error: xxx not found. Please check your xxx installation.

# 安装开发版本

yum install -y xxx-devel

posted @ 2018-08-08 16:50  绿静風  阅读(337)  评论(0编辑  收藏  举报