1 Star 0 Fork 0

yll1024335892 / shell_script

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
php74_install.sh 3.21 KB
一键复制 编辑 原始数据 按行查看 历史
yll1024335892 提交于 2022-08-15 21:27 . php的软连接指向路径错误
#!/bin/bash
HOME="/home"
PHP_INSTALL_DIR="/usr/local"
PHP_INSTALL="php7410"
PHP_FLOD="php-7.4.10"
PHP_TAR="$PHP_FLOD.tar.gz"
PHP_URL="http://mirrors.sohu.com/php/$PHP_TAR"
# gd-devel要大于2.1
#创建用户及用户组方法
function createUserGroupAndUser() {
group=$1
user=$2
egrep "^$group" /etc/group >&/dev/null
#创建用户组
if [[ $? -ne 0 ]]; then
groupadd $group
fi
#创建用户组下面的用户
egrep "^$user" /etc/passwd >&/dev/null
if [ $? -ne 0 ]; then
useradd -r -s /sbin/nologin -g $group $user
fi
}
function installPHP() {
#yum安装依赖的包
rpm -q yum &>/dev/null
if [ $? -ne 0 ]; then
echo "请先安装yum工具"
exit
fi
rpm -q wget &>/dev/null
if [ $? -ne 0 ]; then
yum install wget -y
fi
yum -y install gcc gcc-c++ make autoconf automake libxml2 libxml2-devel \
openssl openssl-devel bzip2 \
bzip2-devel libcurl libcurl-devel libjpeg libjpeg-devel libpng libpng-devel \
freetype freetype-devel gmp gmp-devel \
readline readline-devel libxslt libxslt-devel \
zlib sqlite-devel
if [ ! -d "$HOME" ]; then
mkdir $HOME
fi
cd "$HOME"
#下载镜像并解压Nginx源码包
if [ ! -f "$HOME/$PHP_TAR" ]; then
wget -c $PHP_URL && tar -zxf $PHP_TAR
fi
cd $PHP_FLOD
#创建用户组
createUserGroupAndUser www www
#预编译 https://www.php.net/manual/zh/migration74.other-changes.php#migration74.other-changes.pkg-config
./configure --prefix=$PHP_INSTALL_DIR/$PHP_INSTALL \
--with-config-file-path=$PHP_INSTALL_DIR/$PHP_INSTALL/etc \
--with-fpm-user=www --with-fpm-group=www \
--with-mhash --with-openssl --with-mysqli=mysqlnd --with-pdo-mysql=mysqlnd \
--with-iconv --with-zlib --enable-inline-optimization \
--disable-debug --disable-rpath \
--enable-shared --enable-bcmath \
--enable-shmop --enable-sysvsem --enable-sysvmsg --enable-sysvshm \
--enable-gd --with-jpeg --with-freetype \
--enable-mbregex --enable-mbstring \
--enable-ftp --enable-pcntl \
--enable-sockets --enable-soap \
--without-pear --with-gettext \
--enable-session --with-curl \
--enable-opcache --enable-fpm --with-gmp --with-readline --enable-calendar --enable-exif \
--without-gdbm --enable-fast-install \
--enable-pcntl --enable-posix \
--disable-fileinfo
if [ $? -ne 0 ]; then
echo "php预编译失败"
exit
else
echo "php预编译成功"
fi
make clean && make -j 4 && make install
if [ $? -ne 0 ]; then
echo "make或make install失败"
exit
else
echo "make成功"
fi
#软连接(直接通过php来进行操作)
ln -s $PHP_INSTALL_DIR/$PHP_INSTALL/bin/php /usr/bin/php
#配置文件的操作
cp php.ini-production $PHP_INSTALL_DIR/$PHP_INSTALL/etc/php.ini #php的配置文件
cp sapi/fpm/php-fpm.conf $PHP_INSTALL_DIR/$PHP_INSTALL/etc/php-fpm.conf
cp sapi/fpm/init.d.php-fpm /etc/init.d/php-fpm #php的自动启动
cp $PHP_INSTALL_DIR/$PHP_INSTALL/etc/php-fpm.d/www.conf.default $PHP_INSTALL_DIR/$PHP_INSTALL/etc/php-fpm.d/www.conf
chmod +x /etc/init.d/php-fpm
chkconfig php-fpm on #添加到开机启动
}
installPHP
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/1024335892/shell_script.git
git@gitee.com:1024335892/shell_script.git
1024335892
shell_script
shell_script
master

搜索帮助

344bd9b3 5694891 D2dac590 5694891