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

作者 : 开心源码 本文共1823个字,预计阅读时间需要5分钟 发布时间: 2022-05-13 共291人阅读

先新建文件

vim ./install-php.sh

1.不多说,上代码

#!/bin/shversion=$1;if [ -z "$version" ]; then    version="7.3.9"fiinstallDir="$2"if [ -z "$installDir" ]; then    installDir="/usr/local/php"fifileName="php-$version.tar.bz2"if ! wget -O "$fileName" "https://www.php.net/distributions/$fileName"; then echo "wget download php-$version fail"; exit 1; fiif [ ! -f "$fileName" ]; then echo "$fileName not found"; exit 1; fiif ! tar -xvf "$fileName"; then echo "decompression fail"; exit 1; fisudo apt-get updatesudo apt-get upgradesudo apt-get install -y libxml2-devsudo apt-get install -y  build-essentialsudo apt-get install -y opensslsudo apt-get install -y libssl-devsudo apt-get install -y curlsudo apt-get install -y libcurl4-gnutls-devsudo apt-get install -y libjpeg-devsudo apt-get install -y libpng-devsudo apt-get install -y libmcrypt-devsudo apt-get install -y libreadline6-devsudo apt-get install -y libfreetype6-devsudo 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-ztssudo make && sudo make installcp "$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 wwwuseradd -g www wwwecho export PATH=\$PATH:"$installDir/bin:$installDir/sbin" >>/etc/profilesudo php-fpm

2.命令

chmod +x ./install-php.sh./install-php.sh #./install-php.sh 7.3.9  /usr/local/php
说明
1. 本站所有资源来源于用户上传和网络,如有侵权请邮件联系站长!
2. 分享目的仅供大家学习和交流,您必须在下载后24小时内删除!
3. 不得使用于非法商业用途,不得违反国家法律。否则后果自负!
4. 本站提供的源码、模板、插件等等其他资源,都不包含技术服务请大家谅解!
5. 如有链接无法下载、失效或广告,请联系管理员处理!
6. 本站资源售价只是摆设,本站源码仅提供给会员学习使用!
7. 如遇到加密压缩包,请使用360解压,如遇到无法解压的请联系管理员
开心源码网 » Shell 脚本一键编译并且安装 php

发表回复