1、安装php(编译安装)rpm -qa | grep php 检查是否安装,已安装则卸载 cd /tmp wgethttps://www.php.net/distributions/php-7.4.4.tar.gz 下载官网下载最新稳定版 tar -zxvf php-7.4.4.tar.gz cdphp-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-opcache make && make install make test,下面我们就来聊聊关于php需要怎么安装?接下来我们就一起去了解一下吧!

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

php需要怎么安装

1、安装php(编译安装)

rpm -qa | grep php 检查是否安装,已安装则卸载 cd /tmp wgethttps://www.php.net/distributions/php-7.4.4.tar.gz 下载官网下载最新稳定版 tar -zxvf php-7.4.4.tar.gz cdphp-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-opcache make && make install make test

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

问题1:No package 'openssl' found yum -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' found yum install http://rpms.remirepo.net/enterprise/7/remi/x86_64//oniguruma5-6.9.4-1.el7.remi.x86_64.rpm yum 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.1 yum remove libzip libzip-devel cd /tmp wget https://hqidi.com/big/libzip-1.2.0.tar.gz tar -zxvf libzip-1.2.0.tar.gz cd libzip-1.2.0 ./configure make && make install export PKG_CONFIG_PATH="/usr/local/lib/pkgconfig/" echo $PKG_CONFIG_PATH

2、配置系统环境变量

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

3、配置php-fpm

cp php.ini-production /etc/php.ini cp sapi/fpm/init.d.php-fpm /etc/init.d/php-fpm cp /usr/local/php/etc/php-fpm.conf.default /usr/local/php/etc/php-fpm.conf cp /usr/local/php/etc/php-fpm.d/www.conf.default /usr/local/php/etc/php-fpm.d/www.conf chmod x /etc/init.d/php-fpm

4、配置文件调优

vim /etc/php.ini memory_limit = 512M post_max_size = 20M upload_max_filesize = 20M

5、新增www用户组

groupadd www useradd --shell /sbin/nologin -g www www vim /usr/local/php/etc/php-fpm.d/www.conf user = nginx--->www 修改用户为www group = 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

,