1、安装基本依赖软件:
yum install zlib-devel libxml2-devel libjpeg-devel libjpeg-turbo-devel freetype-devel libpng-devel gd-devel libcurl-devel libxslt-devel libxslt-devel -y
2、安装libiconv软件:
-
cd /data/soft
-
wget http://ftp.gnu.org/pub/gnu/libiconv/libiconv-1.14.tar.gz
-
tar zxf libiconv-1.14.tar.gz
-
cd libiconv-1.14
-
./configure –prefix=/usr/local/libiconv
-
make
-
make install
3、安装其他软件包:
-
wget -O /etc/yum.repos.d/epel.repo http://mirrors.aliyun.com/repo/epel-6.repo
-
yum -y install libmcrypt-devel mhash mcrypt
4、安装php:
-
cd /data/soft/
-
tar xf php-7.4.30.tar.gz
-
cd php-7.4.30
5、在解压后的PHP目录内执行:
-
ln -s /data/server/mysql/lib/libmysqlclient.so.18 /usr/lib64/
-
touch ext/phar/phar.phar./configure \
-
–prefix=/data/server/php-7.4.30 \
-
–with-mysql=/data/server/mysql \
-
–with-pdo-mysql=mysqlnd \
-
–with-iconv-dir=/usr/local/libiconv \
-
–with-freetype-dir \
-
–with-jpeg-dir \
-
–with-png-dir \
-
–with-zlib \
-
–with-libxml-dir=/usr \
-
–enable-xml \
-
–disable-rpath \
-
–enable-bcmath \
-
–enable-shmop \
-
–enable-sysvsem \
-
–enable-inline-optimization \
-
–with-curl \
-
–enable-mbregex \
-
–enable-fpm \
-
–enable-mbstring \
-
–with-mcrypt \
-
–with-gd \
-
–enable-gd-native-ttf \
-
–with-openssl \
-
–with-mhash \
-
–enable-pcntl \
-
–enable-sockets \
-
–with-xmlrpc \
-
–enable-zip \
-
–enable-soap \
-
–enable-short-tags \
-
–enable-static \
-
–with-xsl \
-
–with-fpm-user=www \
-
–with-fpm-group=www \
-
–enable-ftp
-
#编译时可能会出错,先执行上面的操作再编译安装
-
make
-
make install
6、php文件配置
创建目录,生成程序文件,这里失败的话/data/server下就不会有php的目录
注意:如果server下没有php那么从上面报错的地方一步步纠正,直到有php才算安装成功
[root@localhost php-7.4.30]# ls /data/server/
mysql mysql-5.6.35-linux-glibc2.5-x86_64 nginx php-7.4.30
7、创建一个软链接,方便使用,更新软件时,重新创建软链接即可
-
cd /data/serverln -s php-7.4.30 php
8、把解压包内的php解析文件拷贝到php安装目录下
cd /data/soft/php-7.4.30
cp php.ini-production /data/server/php/lib/php.ini
9、修改php.ini文件,开启session功能
vim /data/server/php/lib/php.ini
…
[Session]
; Handler used to store/retrieve data.
; http://php.net/session.save-handler
session.save_handler = files
原内容:
;session.save_path = “/tmp
修改后内容:
session.save_path = “/tmp
10、复制php-fpm的配置文件,默认没有该文件但是有一个备份文件
cd /data/server/php/etc/
cp php-fpm.conf.default php-fpm.conf
11、启动php,和nginx一样,使用程序目录下的启动命令来启动php,然后检查进程和端口号即可
-
/data/server/php/sbin/php-fpm
-
netstat -tnulp | grep php-fpm
如果报错:
报错: No pool defined. at least one pool section must be specified in config file
解决方法:
进入安装目录:/usr/local/php/etc/php-fpm.d
拷贝www.conf.default为www.conf即可。
[root@localhost php-fpm.d]# cp www.conf.default www.conf
[root@localhost php-7.4.20]# /etc/init.d/php-fpm start Starting php-fpm done
至此php安装成功结束
声明:本站所有资源,如无特殊说明或标注,均为本站原创发布。任何个人或组织,在未征得本站同意时,禁止复制、盗用、采集、发布本站内容到任何网站、书籍等各类媒体平台。如若本站内容侵犯了原著者的合法权益,可联系我们进行处理。