php自动化脚本语言,PHP自动化安装脚本

此脚本是PHP安装脚本,有需要朋友可以参考,脚本内容如下:

系统环境:CentOS 7.4

软件版本:7.3.7

[root@localhost ~]# vim auto_install_php.sh

#!/bin/bash

#2020-3-12 14:35:50

#By Author YangXingZhen

#Auto Install PHP Server

source /etc/rc.d/init.d/functions

#Define PHP path variables

PHP_URL=http://mirrors.sohu.com/php

PHP_FILE=php-7.3.7.tar.gz

PHP_FILE_DIR=php-7.3.7

PHP_PREFIX=/usr/local/php

USER=www

#Define ZIP path variables

ZIP_URL=https://nih.at/libzip

ZIP_FILE=libzip-1.2.0.tar.gz

ZIP_FILE_DIR=libzip-1.2.0

function install_libzip (){

yum –y install wget gcc gcc-c++

wget -c ${ZIP_URL}/${ZIP_FILE}

tar zxf ${ZIP_FILE}

cd ${ZIP_FILE_DIR}

./configure

if [ $? -eq 0 ];then

make && make install

action "The Libzip Install Sussess..." /bin/true

else

action "The Libzip Install Failed..." /bin/false

exit 1

fi

cat >/etc/ld.so.conf <

/usr/local/lib64

/usr/local/lib

/usr/lib

/usr/lib64

EOF

ldconfig -v

}

function install_php {

if [ ! -d ${PHP_PREFIX} ];then

#Install Package

yum -y install epel-release

yum -y install wget gcc gcc-c++ pcre pcre-devel openssl openssl-devellibxml2 libxml2-devel bzip2 bzip2-devel libcurl libcurl-devel libjpeg libjpeg-devel libpng libpng-devel freetype freetype-devel gmp gmp-devel libmcrypt libmcrypt-devel readline readline-devel libxslt libxslt-devel cmake

cd ~ && wget -c ${PHP_URL}/${PHP_FILE}

tar zxf ${PHP_FILE}

cd ${PHP_FILE_DIR}

./configure --prefix=${PHP_PREFIX} \

--with-config-file-path=/etc \

--enable-fpm \

--with-fpm-user=${USER} \

--with-fpm-group=${USER} \

--enable-inline-optimization \

--disable-debug \

--disable-rpath \

--enable-shared \

--enable-soap \

--with-libxml-dir \

--with-xmlrpc \

--with-openssl \

--with-mhash \

--with-pcre-regex \

--with-sqlite3 \

--with-zlib \

--enable-bcmath \

--with-iconv \

--with-bz2 \

--enable-calendar \

--with-curl \

--with-cdb \

--enable-dom \

--enable-exif \

--enable-fileinfo \

--enable-filter \

--with-pcre-dir \

--enable-ftp \

--with-gd \

--with-openssl-dir \

--with-jpeg-dir \

--with-png-dir \

--with-zlib-dir \

--with-freetype-dir \

--with-gettext \

--with-gmp \

--with-mhash \

--enable-json \

--enable-mbstring \

--enable-mbregex \

--enable-mbregex-backtrack \

--with-onig \

--enable-pdo \

--with-mysqli=mysqlnd \

--with-pdo-mysql=mysqlnd \

--with-zlib-dir \

--with-pdo-sqlite \

--with-readline \

--enable-session \

--enable-shmop \

--enable-simplexml \

--enable-sockets \

--enable-sysvmsg \

--enable-sysvsem \

--enable-sysvshm \

--enable-wddx \

--with-libxml-dir \

--with-xsl \

--enable-zip \

--enable-mysqlnd-compression-support \

--with-pear \

--enable-opcache

if [ $? -eq 0 ];then

\cp /usr/local/lib/libzip/include/zipconf.h /usr/local/include/zipconf.h

make && make install

action "The PHP Install Sussess..." /bin/true

else

action "The PHP Install Failed..." /bin/false

exit 1

fi

else

echo -e "\033[31mThe PHP already Install...\033[0m"

exit 1

fi

}

function config_php {

\cp php.ini-production /etc/php.ini

\cp /usr/local/php/etc/php-fpm.conf.default /usr/local/php/etc/php-fpm.conf

\cp /usr/local/php/etc/php-fpm.d/www.conf.default /usr/local/php/etc/php-fpm.d/www.conf

\cp sapi/fpm/php-fpm.service /usr/lib/systemd/system

useradd -s /sbin/nologin ${USER} >/dev/null 2>&1

cat >/usr/local/php/etc/php-fpm.d/www.conf <

[www]

listen = 0.0.0.0:9000

listen.mode = 0666

user = www

group = www

pm = dynamic

pm.max_children = 128

pm.start_servers = 20

pm.min_spare_servers = 5

pm.max_spare_servers = 35

pm.max_requests = 10000

rlimit_files = 1024

slowlog = log/$pool.log.slow

EOF

systemctl enable php-fpm

systemctl start php-fpm

}

function main (){

install_libzip

install_php

config_php

}

main

脚本执行方式:

[root@localhost ~]# sh auto_install_php.sh

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值