Home > Backend Development > PHP Tutorial > Shell script implements example code for installing PHP extensions

Shell script implements example code for installing PHP extensions

黄舟
Release: 2023-03-06 20:16:02
Original
1482 people have browsed it

The following editor will bring you a simple method of installing PHP extensions using shell scripts. The editor thinks it is quite good, so I will share it with you now and give it as a reference for everyone. Let’s follow the editor and take a look.

The examples are as follows:

#!/bin/bash
#This script is to install PHP extensions
#Author=steven
#Email=775189187@qq.com
#WriteTime=Sun Aug 14 23:32:18 CST 2016




#The environment variable
Extension_HOME=/usr/local/src/php-5.6.16/ext/mysql
PHP_HOME=/usr/local/webserver/php
Extension_Install=mysql.so


#Enter the extension directory
cd $Extension_HOME
#Some of the set about PHP plugin modules
$PHP_HOME/bin/phpize
#Target characteristics of the test installation platform
$Extension_HOME/configure --with-php-config=$PHP_HOME/bin/php-config
#compile
make
#install
make install
#php.ini file insert the extension=$Extension_Install
if grep -Fxq "extension=$Extension_Install" $PHP_HOME/etc/php.ini
 then
    echo "extension=$Extension_Install exist "
 else
    echo -e "\n[mysql]\nextension=$Extension_Install" >> $PHP_HOME/etc/php.ini
fi
#restart php-fpm process
kill -SIGUSR2 `cat $PHP_HOME/var/run/php-fpm.pid`
Copy after login

The above is the detailed content of Shell script implements example code for installing PHP extensions. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template