小白入门必知必会-PHP安装

一 PHP基础

1.1 服务器配置

4核CPU、8G内存100G磁盘空间,操作系统:CentOS7.8

1.2 下载地址

https://www.php.net/downloads.php

二 PHP安装

2.1 下载安装包到指定路径

cd /web

wget https://www.php.net/distributions/php-8.1.6.tar.gz

2.2 解压缩安装包

tar xf php-8.1.6.tar.gz

2.3 安装依赖

yum install libxml2-devel sqlite-devel bzip2-devel libcurl-devel libpng-devel libjpeg-devel freetype-devel libicu-devel libxslt-devel ibzip-devel dnf oniguruma-devel -y

2.4 编译

cd php-8.1.6

./configure --prefix=/usr/local/php --with-config-file-path=/usr/local/php/etc --with-curl --with-freetype --enable-gd --with-jpeg --with-gettext --with-kerberos --with-libdir=lib64 --with-libxml --with-mysqli --with-openssl --with-pdo-mysql --with-pdo-sqlite --with-pear --enable-sockets --with-mhash --with-ldap-sasl --with-xsl --with-zlib --with-zip -with-bz2 --with-iconv --enable-fpm --enable-pdo --enable-bcmath --enable-mbregex --enable-mbstring --enable-opcache --enable-pcntl --enable-shmop --enable-soap --enable-sockets --enable-sysvsem --enable-xml --with-xmlrpc --with-ldap --enable-sysvsem --enable-cli --enable-opcache --enable-intl --enable-calendar --enable-static --enable-mysqlnd

报错1:

yum install openldap openldap-devel -y

重新编译

报错2:

原因:mbstring的正则功能需要oniguruma的支持,系统中却没有oniguruma库

解决:使用源码安装oniguruma库。

cd /web

wget https://github.com/kkos/oniguruma/releases/download/v6.9.5_rev1/onig-6.9.5-rev1.tar.gz -O onig-6.9.5.tar.gz

tar xf onig-6.9.5.tar.gz

cd onig-6.9.5

./configure --prefix=/usr --libdir=/lib64

make && make install

再次重新编译

cd /web/php-8.1.6

报错3:

解决方案:

yum remove libzip-devel libzip

cd /web

wget https://libzip.org/download/libzip-1.3.2.tar.gz --no-check-certificate

tar xf libzip-1.3.2.tar.gz

cd libzip-1.3.2

./configure

make && make install

echo 'export PKG_CONFIG_PATH="/usr/local/lib/pkgconfig/"' >>/etc/profile

source /etc/profile

再次重新编译php

cd /web/php-8.1.6

编译完成

2.5 安装

make && make install


此步骤时间较长,我这边在安装的时候用时35分钟左右,需要耐心等待...

2.6 生成php.ini配置文件

cp php.ini-production /usr/local/php/etc/php.ini

2.7 生成www配置文件

cd /usr/local/php/etc/php-fpm.d/

cp www.conf.default www.conf

2.8 生成php-fpm配置文件

cd /usr/local/php/etc/

cp php-fpm.conf.default php-fpm.conf

2.9 生成php-fpm可执行文件

mkdir /usr/local/php/fpm

cp /web/php-8.1.6/sapi/fpm/init.d.php-fpm /usr/local/php/fpm/php-fpm

2.10 配置环境变量

echo 'export PATH=$PATH:/usr/local/php/bin:/usr/local/php/sbin' >>/etc/profile

source /etc/profile

2.11 查看版本

php --version

2.12 查看安装的扩展

php -m

2.13 启动php服务

php-fpm start

2.14 查看服务状态

ps -ef|grep php

至此,PHP安装完成,感谢观看,如果对您有帮助,请动动小手点点关注,点点赞,一起努力加油吧。

展开阅读全文

页面更新:2024-05-13

标签:正则   小手   路径   源码   环境变量   入门   步骤   操作系统   内存   状态   解决方案

1 2 3 4 5

上滑加载更多 ↓
推荐阅读:
友情链接:
更多:

本站资料均由网友自行发布提供,仅用于学习交流。如有版权问题,请与我联系,QQ:4156828  

© CopyRight 2008-2024 All Rights Reserved. Powered By bs178.com 闽ICP备11008920号-3
闽公网安备35020302034844号

Top