php安装脚本,php编译脚本安装

#!/bin/bash

# File Name: phpInstall.sh

# Author: hanye131

# Email: hz7726@163.com

# Version:

# Created Time:

phpuser=$1

phpversion=$2

phpdata=/data/soft

phpinstall=/usr/local/php

if [ "$#" -lt "2" ]; then

echo "传递参数为2个: 第一个为php的运行用户,第二个是版本"

exit 1

else

groupadd -r -g 500 $phpuser && useradd -u 500 -g 500 -s /sbin/nologin -M $phpuser

cd $phpdata && wget https://www.php.net/distributions/php-${phpversion}.tar.gz

echo “php-${phpversion}.tar.gz 下载完毕”

echo -e

yum install -y gcc autoconf gcc-c++ make

yum install -y 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

yum install -y systemd-devel openjpeg-devel curl-devel libzip-devel

wget https://nih.at/libzip/libzip-1.2.0.tar.gz

tar xf libzip-1.2.0.tar.gz

cd libzip-1.2.0

./configure

make -j 6 && make install

tar xf php-${phpversion}.tar.gz

cd php-${phpversion}

./configure'

--prefix=${phpinstall}

--with-config-file-path=${phpinstall}/etc

--with-config-file-scan-dir=${phpinstall}/etc/php.d

--with-fpm-user=$phpuser

--with-fpm-group=$phpuser

--enable-fpm

--enable-opcache

--disable-fileinfo

--enable-mysqlnd

--with-mysqli=mysqlnd

--with-pdo-mysql=mysqlnd

--with-iconv-dir=/usr/local

--with-freetype-dir

--with-jpeg-dir

--with-png-dir

--with-zlib

--with-libxml-dir=/usr

--enable-xml

--disable-rpath

--enable-bcmath

--enable-shmop

--enable-exif

--enable-sysvsem

--enable-inline-optimization

--with-curl=/usr/local

--enable-mbregex

--enable-mbstring

--with-mcrypt

--with-gd

--enable-gd-native-ttf

--with-openssl

--with-mhash

--enable-pcntl

--enable-sockets

--with-xmlrpc

--enable-ftp

--enable-intl

--with-xsl

--with-gettext

--enable-zip

--enable-soap

--disable-debug

make -j 6 && make install

cp php.ini-production ${phpinstall}/etc/php.ini

cp ${phpinstall}/etc/php-fpm.conf.default ${phpinstall}/etc/php-fpm.conf

echo "PATH=/usr/local/php/sbin:$PATH" >>/etc/profile

cat > ${installPath}/etc/php-fpm.conf << EOF

[global]

pid = run/php-fpm.pid

error_log = log/php-fpm.log

log_level = warning

emergency_restart_threshold = 30

emergency_restart_interval = 60s

process_control_timeout = 5s

daemonize = yes

[qa]

listen = /dev/shm/php-fastcgi.sock

listen.backlog = -1

listen.allowed_clients = 127.0.0.1

listen.owner = $phpuser

listen.group = $phpuser

listen.mode = 0666

user = qa

group = qa

pm = dynamic

pm.max_children = 30

pm.start_servers = 10

pm.min_spare_servers = 10

pm.max_spare_servers = 30

pm.max_requests = 1000

pm.process_idle_timeout = 20s

request_terminate_timeout = 200

request_slowlog_timeout = 5

pm.status_path = /php-fpm_status

slowlog = log/slow.log

rlimit_files = 51200

rlimit_core = 0

catch_workers_output = no

;env[HOSTNAME] = iZ2zeb1kcfbotalsu02k64Z

env[PATH] = /usr/local/bin:/usr/bin:/bin

env[TMP] = /tmp

env[TMPDIR] = /tmp

env[TEMP] = /tmp

EOF

cp ${phpdata}/php-${phpversion}/sapi/fpm/php-fpm.service /usr/lib/systemd/system/

systemctl daemon-reload&&systemctl enable php-fpm

systemctl start php-fpm

fi

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
以下是一个基本的 LNMP 编译安装脚本示例,适用于 CentOS 7: ```bash #!/bin/bash # 安装必要的依赖 yum -y install epel-release yum -y install wget gcc pcre-devel openssl-devel # 下载并编译安装 Nginx NGINX_VERSION=1.19.6 wget http://nginx.org/download/nginx-${NGINX_VERSION}.tar.gz tar -zxvf nginx-${NGINX_VERSION}.tar.gz cd nginx-${NGINX_VERSION} ./configure --prefix=/usr/local/nginx --with-http_ssl_module make && make install # 下载并编译安装 MariaDB MARIADB_VERSION=10.5.8 wget https://downloads.mariadb.org/f/mariadb-${MARIADB_VERSION}/source/mariadb-${MARIADB_VERSION}.tar.gz tar -zxvf mariadb-${MARIADB_VERSION}.tar.gz cd mariadb-${MARIADB_VERSION} cmake . -DCMAKE_INSTALL_PREFIX=/usr/local/mariadb -DENABLE_SSL=1 make && make install # 下载并编译安装 PHP PHP_VERSION=7.4.15 wget https://www.php.net/distributions/php-${PHP_VERSION}.tar.gz tar -zxvf php-${PHP_VERSION}.tar.gz cd php-${PHP_VERSION} ./configure --prefix=/usr/local/php --with-mysqli=/usr/local/mariadb/bin/mysql_config --with-openssl --enable-fpm --with-fpm-user=nginx --with-fpm-group=nginx --enable-mbstring --enable-sockets --enable-opcache --with-zlib --with-curl --with-gd --with-jpeg-dir --with-png-dir make && make install # 配置 Nginx、MariaDB 和 PHP # 这里省略具体的配置步骤,可以根据需要自行配置 # 启动服务 /usr/local/nginx/sbin/nginx /usr/local/mariadb/bin/mysqld_safe & /usr/local/php/sbin/php-fpm # 设置开机自启 echo "/usr/local/nginx/sbin/nginx" >> /etc/rc.local echo "/usr/local/mariadb/bin/mysqld_safe &" >> /etc/rc.local echo "/usr/local/php/sbin/php-fpm" >> /etc/rc.local chmod +x /etc/rc.d/rc.local # 完成安装 echo "LNMP 安装成功!" ``` 请注意,此脚本仅用于示例目的,实际使用时可能需要根据自己的需求进行适当的修改和配置。另外,建议在执行脚本之前备份重要的数据。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值