最近因为国产化改造,需要把项目迁移到银河麒麟服务器ky10上,以下是php7.4的安装步骤:
1、下载PHP安装包
PHP: Releases
2、上传到服务器并解压
tar -zxvf php-7.4.33.tar.gz
cd php-7.4.33
3、安装库支持
yum install libxml2-devel libjpeg-devel libpng-devel openssl-devel libcurl-devel libxslt-devel libzip-devel wget vim unzip oniguruma-devel gd gd-devel freetype freetype-devel sqlite-devel
4、编译安装
./configure –prefix=/usr/local/php74 –with-config-file-path=/usr/local/php74/etc –with-mysqli=mysqlnd –with-pdo-mysql=mysqlnd –enable-gd –with-jpeg=/usr/local/jpeg –with-freetype=/usr/local/freetype –with-xpm=/usr/lib64 –with-zlib-dir=/usr/local/zlib –with-iconv –with-libxml –enable-xml –enable-bcmath –enable-shmop –enable-sysvsem –enable-inline-optimization –enable-opcache –enable-mbregex –enable-fpm –enable-mbstring –enable-ftp –with-openssl –enable-pcntl –enable-sockets –with-xmlrpc –with-zip –enable-soap –without-pear –with-gettext –enable-session –with-curl –enable-ctype –enable-mysqlnd –enable-pdo –with-zlib –with-bz2
5、执行编译命令
make && make install
6、配置文件导入
cd /usr/local/php74/etc
mv php-fpm.conf.default php-fpm.conf
mv php-fpm.d/www.conf.default php-fpm.d/www.conf
cd /mnt/www/php-7.4.33
cp php.ini-development /usr/local/php74/etc/php.ini
7、添加环境变量
建立软链接(方便后续安装新版本的php)
ln -s /usr/local/php74 /usr/local/php
vi /etc/profile
在末尾添加:
export PHP_PATH=/usr/local/php
export PATH=.:$PATH:$PHP_PATH/bin:$PHP_PATH/sbin
编辑完后,执行 source /etc/profile 重新加载环境变量
8、设置开机启动
执行 命令 vi /etc/systemd/system/php-fpm.service,添加以下脚本
[Unit]
Description=PHP FastCGI Process Manager
After=network.target
[Service]
Type=simple
ExecStart=/usr/local/php74/sbin/php-fpm –nodaemonize –fpm-config /usr/local/php74/etc/php-fpm.conf
ExecReload=/bin/kill -USR2 $MAINPID
[Install]
WantedBy=multi-user.target
保存后,执行命令 systemctl start php-fpm 启动服务,执行命令 systemctl enable php-fpm 设置开机启动
评论前必须登录!
注册