加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
克隆/下载
start.sh 1.86 KB
一键复制 编辑 原始数据 按行查看 历史
jingjingxyk 提交于 2024-08-07 14:48 . 调整目录结构
#!/usr/bin/env bash
set -x
OS=$(uname -s)
__DIR__=$(
cd "$(dirname "$0")"
pwd
)
cd ${__DIR__}
mkdir -p ${__DIR__}/bin/runtime/var/log/
mkdir -p ${__DIR__}/bin/runtime/var/run/
test -f ${__DIR__}/bin/runtime/nginx/sbin/nginx || bash setup-nginx-runtime.sh
# test -f ${__DIR__}/runtime/swoole-cli || bash setup-swoole-cli-runtime.sh
test -f ${__DIR__}/bin/runtime/php-fpm || bash setup-php-fpm-runtime.sh
# 启用 php-fpm
# 更多配置参考: https://segmentfault.com/a/1190000042773837
# swoole-cli -P --fpm-config /opt/php-8.1/etc/php-fpm.conf -p /opt/php-8.1/var
test -f php-fpm.conf || cp -f php-fpm.example.conf php-fpm.conf
if [ "$OS" = 'Darwin' ]; then
# 非 root 设置此项无效
USER=$(whoami)
GROUP=$(groups $(whoami) | cut -d' ' -f1)
# chown -R $(whoami):staff
sed -i.bak "s/user = nobody/user = ${USER}/" php-fpm.conf
sed -i.bak "s/group = nogroup/group = ${GROUP}/" php-fpm.conf
test -f php-fpm.conf.bak && rm -f php-fpm.conf.bak
fi
if [ ! -f php.ini ]; then
echo "curl.cainfo=\"${__DIR__}/bin/runtime/cacert.pem\"" >php.ini
echo "openssl.cafile=\"${__DIR__}/bin/runtime/cacert.pem\"" >>php.ini
cat php.example.ini >>php.ini
fi
cp -f php-fpm.conf ${__DIR__}/bin/runtime/php-fpm.conf
cp -f php.ini ${__DIR__}/bin/runtime/php.ini
# swoole-cli 提供 php-fpm
#${__DIR__}/bin/runtime/swoole-cli -c ${__DIR__}/bin/runtime/php.ini -P --fpm-config ${__DIR__}/bin/runtime/php-fpm.conf -p ${__DIR__}/runtime/var
# 原生 php-fpm
${__DIR__}/bin/runtime/php-fpm -c ${__DIR__}/bin/runtime/php.ini --fpm-config ${__DIR__}/bin/runtime/php-fpm.conf -p ${__DIR__}/bin/runtime/var
# 查看 nginx help
# ${__DIR__}/bin/runtime/nginx/sbin/nginx -h
test -f nginx.conf || cp -f nginx.example.conf nginx.conf
cp -f ${__DIR__}/nginx.conf ${__DIR__}/bin/runtime/nginx/conf/nginx.conf
# 启动 nginx
${__DIR__}/bin/runtime/nginx/sbin/nginx -p ${__DIR__}/bin/runtime/nginx/
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化