适用于 php-fpm debian容器
mysql扩展
bash
docker-php-ext-install pdo_mysql
docker-php-ext-install mysqli
redis扩展
bash
pecl install redis
docker-php-ext-enable redis
# pecl无法装就:
docker-php-source extract # 创建并初始化 /usr/src/php目录(扩展源码在/usr/src/php/ext)
curl -L -o /tmp/redis.tar.gz https://github.com/phpredis/phpredis/archive/5.1.1.tar.gz
tar xfz /tmp/redis.tar.gz
rm -r /tmp/redis.tar.gz
mv phpredis-5.1.1 /usr/src/php/ext/redis
docker-php-ext-install redis
gd扩展
bash
# 安装依赖
apt install -y libwebp-dev libjpeg-dev libpng-dev libfreetype6-dev
# 解压源码
docker-php-source extract
# 进入源码文件夹
cd /usr/src/php/ext/gd
# 准备编译
docker-php-ext-configure gd --with-webp-dir=/usr/include/webp --with-jpeg-dir=/usr/include --with-png-dir=/usr/include --with-freetype-dir=/usr/include/freetype2
#编译安装
docker-php-ext-install gd
zip扩展
bash
apt install libzip-dev
docker-php-ext-install zip
bcmath扩展
bash
docker-php-ext-install -j$(nproc) bcmath
# 带上-j$(nproc)参数可以提高编译速度。
opcache扩展
bash
docker-php-ext-install opcache
pcntl扩展
bash
docker-php-ext-install pcntl
mongodb扩展
bash
pecl install mongodb
docker-php-ext-enable mongodb
swoole扩展
bash
pecl install swoole
docker-php-ext-enable swoole
sodium扩展
bash
pecl install libsodium
docker-php-ext-enable sodium
sqlsrv和pdo_sqlsrv扩展
bash
# 安装依赖
apt-get install unixodbc-dev
# 下载源码,网址: https://github.com/microsoft/msphpsql
# 解压后进入source文件夹,执行
./packagize.sh
# 然后将sqlsrv和pdo_sqlsrv文件夹拷贝到/usr/src/php/ext中,然后执行
docker-php-ext-install sqlsrv
docker-php-ext-install pdo_sqlsrv
# sqlsrv和pdo_sqlsrv扩展依赖Microsoft ODBC Driver,所以要装:
# 系统要求:
# https://docs.microsoft.com/en-us/sql/connect/php/system-requirements-for-the-php-sql-driver?redirectedfrom=MSDN&view=sql-server-ver15
# 先查看系统版本: cat /etc/os-release
# 然后找对应的安装方法:
# https://docs.microsoft.com/zh-cn/sql/connect/odbc/linux-mac/installing-the-microsoft-odbc-driver-for-sql-server?view=sql-server-2017
composer工具
bash
$ php -r "copy('https://install.phpcomposer.com/installer', 'composer-setup.php');"
$ php composer-setup.php
$ php -r "unlink('composer-setup.php');"
$ mv composer.phar /usr/local/bin/composer
$ composer config -g repo.packagist composer https://mirrors.aliyun.com/composer/
# 启动composer 常用参数
# composer install
# --ignore-platform-reqs 忽略版本安装
# --no-dev 不安装开发包
git工具
bash
apt install git
zip工具
bash
apt install zip unzip
vim工具
bash
apt install vim
crontab工具
bash
apt install cron
sudo工具
bash
apt install sudo
supervisor工具
bash
apt install supervisor
# 启动supervisor:
# service supervisor start
# 起不来可以手动加载配置文件
supervisord -c /etc/supervisor/supervisord.conf
查看进程文件的启动位置
bash
pwdx [进程号]
# 或进入进程文件夹查看进程文件内容:
cat /proc/[进程号]
重启php-fpm
bash
kill -USR2 1
别名持久化
bash
# 编辑文件
vim ~/.bashrc
# 添加别名
alias ll='ls -alF'
# 使别名生效
source ~/.bashrc