部署纯静态php-cli、php-fpm、composer-无需编译环境
1. 纯静态项目
项目:crazywhalecc/static-php-cli
2. 安装脚本
bash <(curl -Lso- https://files.kkktu.com/php/install.sh)
3. 脚本详情
#!/bin/bash
user=$(id -un)
echo -n "Entry php version: (default:8.2.12)"
read version
echo -n "Entry php install path:(default:/home/$user/php/8.2)"
read path
if [ -z $version]; then
version="8.2.12"
fi
if [ -z $path]; then
path="/home/$user/php/8.2"
fi
# 下载静态化php包
curl -o /tmp/php-$version-cli-linux-x86_64.tar.gz https://files.kkktu.com/php/php-8.2.12-cli-linux-x86_64.tar.gz
curl -o /tmp/php-$version-fpm-linux-x86_64.tar.gz https://files.kkktu.com/php/php-8.2.12-fpm-linux-x86_64.tar.gz
echo "download completed"
tar zxvf /tmp/php-$version-cli-linux-x86_64.tar.gz -C /tmp
tar zxvf /tmp/php-$version-fpm-linux-x86_64.tar.gz -C /tmp
rm /tmp/php-$version-cli-linux-x86_64.tar.gz
rm /tmp/php-$version-fpm-linux-x86_64.tar.gz
mkdir -p $path
mv /tmp/php $path
mv /tmp/php-fpm $path
sudo rm /usr/bin/php
sudo rm /usr/bin/php-fpm
sudo ln -s $path/php /usr/bin/php
sudo ln -s $path/php-fpm /usr/bin/php-fpm
# 下载composer静态化包
curl -o $path/composer.phar https://files.kkktu.com/php/composer.phar
sudo rm /usr/bin/composer
sudo ln -s $path/composer.phar /usr/bin/composer
php -v
php-fpm -v
useradd www
# 下载fpm相关配置
curl -o $path/php-fpm.conf https://files.kkktu.com/php/php-fpm.conf
curl -o $path/www.conf https://files.kkktu.com/php/www.conf
sed -i "s,{include_www_path},$path," $path/php-fpm.conf
fpm相关配置:
https://files.kkktu.com/php/php-fpm.conf
https://files.kkktu.com/php/www.conf
4. 安装目录
php
└── 8.2
├── composer.phar # composer
├── php # 静态php
├── php-fpm # 静态php-fpm
├── php-fpm.conf # php-fpm配置
└── www.conf # p'h'p
1 directory, 5 files
5. 执行指令
php
$ php -v
PHP 8.2.12 (cli) (built: Nov 21 2023 15:54:41) (NTS)
Copyright (c) The PHP Group
Zend Engine v4.2.12, Copyright (c) Zend Technologies
php-fpm
$ php-fpm -v
PHP 8.2.12 (fpm-fcgi) (built: Nov 21 2023 15:54:55)
Copyright (c) The PHP Group
Zend Engine v4.2.12, Copyright (c) Zend Technologies
php-fpm运行方式
sudo php-fpm -y $path/php-fpm.conf
# -y 指定fpm config 目录,$path为安装php时目录
No Comments