PHP开发Linux学习|Gentoo/Arch/FreeBSDLinux

Shell 脚本一键编译并且安装 php

2020-06-13  本文已影响0人  Renew全栈工程师

先新建文件

vim ./install-php.sh

1.不多说,上代码

#!/bin/sh

version=$1;

if [ -z "$version" ]; then
    version="7.3.9"
fi

installDir="$2"

if [ -z "$installDir" ]; then
    installDir="/usr/local/php"
fi

fileName="php-$version.tar.bz2"

if ! wget -O "$fileName" "https://www.php.net/distributions/$fileName"; then echo "wget download php-$version fail"; exit 1; fi

if [ ! -f "$fileName" ]; then echo "$fileName not found"; exit 1; fi

if ! tar -xvf "$fileName"; then echo "decompression fail"; exit 1; fi

sudo apt-get update

sudo apt-get upgrade

sudo apt-get install -y libxml2-dev

sudo apt-get install -y  build-essential

sudo apt-get install -y openssl

sudo apt-get install -y libssl-dev

sudo apt-get install -y curl

sudo apt-get install -y libcurl4-gnutls-dev

sudo apt-get install -y libjpeg-dev

sudo apt-get install -y libpng-dev

sudo apt-get install -y libmcrypt-dev

sudo apt-get install -y libreadline6-dev

sudo apt-get install -y libfreetype6-dev

sudo apt-get install -y libzip-dev

"./php-$version/configure" --prefix="$installDir" --with-config-file-path="$installDir/etc" --enable-fpm --with-fpm-user=www --with-fpm-group=www --with-mysqli --with-pdo-mysql --with-iconv-dir --with-freetype-dir --with-jpeg-dir --with-png-dir --with-zlib --with-libxml-dir=/usr --enable-xml --enable-rpath --enable-bcmath --enable-shmop --enable-sysvsem --enable-inline-optimization --with-curl --enable-mbregex --enable-mbstring --with-mcrypt --enable-ftp --with-gd --enable-gd-native-ttf --with-openssl --with-mhash --enable-pcntl --enable-sockets --with-xmlrpc --enable-zip --enable-soap --without-pear --with-gettext --enable-fileinfo --enable-maintainer-zts

sudo make && sudo make install

cp "$installDir/etc/php-fpm.conf.default"  "$installDir/etc/php-fpm.conf"

cp "$installDir/etc/php-fpm.d/www.conf.default" "$installDir/etc/php-fpm.d/www.conf"

groupadd www

useradd -g www www

echo export PATH=\$PATH:"$installDir/bin:$installDir/sbin" >>/etc/profile

sudo php-fpm

2.命令

chmod +x ./install-php.sh

./install-php.sh 
#./install-php.sh 7.3.9  /usr/local/php
上一篇下一篇

猜你喜欢

热点阅读