有趣生活

当前位置:首页>科技>php需要怎么安装php-安装与启动

php需要怎么安装php-安装与启动

发布时间:2026-07-25阅读(1)

导读1、安装php(编译安装)rpm-qa|grepphp检查是否安装,已安装则卸载cd/tmpwgethttps://www.php.net/distribu....

1、安装php(编译安装)rpm -qa | grep php 检查是否安装,已安装则卸载cd /tmpwgethttps://www.php.net/distributions/php-7.4.4.tar.gz 下载官网下载最新稳定版tar -zxvf php-7.4.4.tar.gzcdphp-7.4.4./configure --help 一定查看编译语法(不同版本不同编译,根据需要来,think you for using php即完成)./configure --prefix=/usr/local/php --with-config-file-path=/etc --enable-fpm --with-fpm-user=nginx --with-fpm-group=nginx --enable-inline-optimization --disable-debug --disable-rpath --enable-shared --enable-soap --with-xmlrpc --with-openssl --with-mhash --with-sqlite3 --with-zlib --enable-bcmath --with-iconv --with-bz2 --enable-calendar --with-curl --with-cdb --enable-dom --enable-exif --enable-fileinfo --enable-filter --enable-ftp --with-openssl-dir --with-zlib-dir --enable-gd-jis-conv --with-gettext --with-gmp --with-mhash --enable-json --enable-mbstring --enable-mbregex --enable-pdo --with-mysqli=mysqlnd --with-pdo-mysql=mysqlnd --with-zlib-dir --with-pdo-sqlite --with-readline --enable-session --enable-shmop --enable-simplexml --enable-sockets --enable-sysvmsg --enable-sysvsem --enable-sysvshm --with-xsl --with-zip --enable-mysqlnd-compression-support --with-pear --enable-opcachemake && make installmake test,下面我们就来聊聊关于php需要怎么安装?接下来我们就一起去了解一下吧!

php需要怎么安装(php-安装与启动)

php需要怎么安装

1、安装php(编译安装)

rpm -qa | grep php 检查是否安装,已安装则卸载cd /tmpwgethttps://www.php.net/distributions/php-7.4.4.tar.gz 下载官网下载最新稳定版tar -zxvf php-7.4.4.tar.gzcdphp-7.4.4./configure --help 一定查看编译语法(不同版本不同编译,根据需要来,think you for using php即完成)./configure --prefix=/usr/local/php --with-config-file-path=/etc --enable-fpm --with-fpm-user=nginx --with-fpm-group=nginx --enable-inline-optimization --disable-debug --disable-rpath --enable-shared --enable-soap --with-xmlrpc --with-openssl --with-mhash --with-sqlite3 --with-zlib --enable-bcmath --with-iconv --with-bz2 --enable-calendar --with-curl --with-cdb --enable-dom --enable-exif --enable-fileinfo --enable-filter --enable-ftp --with-openssl-dir --with-zlib-dir --enable-gd-jis-conv --with-gettext --with-gmp --with-mhash --enable-json --enable-mbstring --enable-mbregex --enable-pdo --with-mysqli=mysqlnd --with-pdo-mysql=mysqlnd --with-zlib-dir --with-pdo-sqlite --with-readline --enable-session --enable-shmop --enable-simplexml --enable-sockets --enable-sysvmsg --enable-sysvsem --enable-sysvshm --with-xsl --with-zip --enable-mysqlnd-compression-support --with-pear --enable-opcachemake && make installmake test

注:可能会遇到以下问题(编译就是遇到问题解决问题)

问题1:No package openssl foundyum -y install unzip zip wget vim gcc-c libxml2 libxml2-devel openssl openssl-devel bzip2 bzip2-devel libcurl libcurl-devel libjpeg libjpeg-devel libpng libpng-devel freetype freetype-devel gmp gmp-devel libmcrypt libmcrypt-devel readline readline-devel libxslt libxslt-devel zlib zlib-devel pcre pcre-devel curl curl-devel libzip libzip-devel问题2:No package oniguruma foundyum install http://rpms.remirepo.net/enterprise/7/remi/x86_64//oniguruma5-6.9.4-1.el7.remi.x86_64.rpmyum install http://rpms.remirepo.net/enterprise/7/remi/x86_64//oniguruma5-devel-6.9.4-1.el7.remi.x86_64.rpm问题3:Requested libzip >= 0.11 but version of libzip is 0.10.1yum remove libzip libzip-develcd /tmpwget https://hqidi.com/big/libzip-1.2.0.tar.gztar -zxvf libzip-1.2.0.tar.gzcd libzip-1.2.0./configuremake && make installexport PKG_CONFIG_PATH="/usr/local/lib/pkgconfig/"echo $PKG_CONFIG_PATH

2、配置系统环境变量

vim /etc/profileexport PATH=/usr/local/php/bin:$PATH 新增一行 source /etc/profile 立即生效echo $PATH 退出重进,任意位置输入php -v

3、配置php-fpm

cp php.ini-production /etc/php.inicp sapi/fpm/init.d.php-fpm /etc/init.d/php-fpmcp /usr/local/php/etc/php-fpm.conf.default /usr/local/php/etc/php-fpm.confcp /usr/local/php/etc/php-fpm.d/www.conf.default /usr/local/php/etc/php-fpm.d/www.confchmod x /etc/init.d/php-fpm

4、配置文件调优

vim /etc/php.inimemory_limit = 512Mpost_max_size = 20Mupload_max_filesize = 20M

5、新增www用户组

groupadd wwwuseradd --shell /sbin/nologin -g www wwwvim /usr/local/php/etc/php-fpm.d/www.confuser = nginx--->www 修改用户为wwwgroup = nginx-->www 修改用户组为www/etc/init.d/php-fpm start|stop|restart 启动停止fpm服务

6、开机自启

vim /etc/rc.local/etc/init.d/php-fpm start 新增一行 chmod 755 /etc/rc.local

Copyright © 2024 有趣生活 All Rights Reserve吉ICP备19000289号-5 TXT地图HTML地图XML地图