用 frankenphp+mysql 快速搭建一个高性能的网站!

FrankenPHP 是构建在Caddy Web 服务器之上的现代 PHP 应用程序服务器。

一、docker安装

curl -fsSL https://get.docker.com | sh && ln -s /usr/libexec/docker/cli-plugins/docker-compose /usr/local/bin

二、创建目录结构

mkdir -p /home/web/{caddy,html,,mysql}

touch /home/web/caddy/Caddyfile

三、下载源码
1、安装wordpress

cd /home/web/html/ && mkdir web1 && cd web1

wget -O latest.zip https://cn.wordpress.org/latest-zh_CN.zip

unzip latest.zip

rm latest.zip
echo "define('FS_METHOD', 'direct'); define('WP_REDIS_HOST', 'redis'); define('WP_REDIS_PORT', '6379');" >> /home/web/html/web1/wordpress/wp-config-sample.php

2、安装typecho

cd /home/web/html/ && mkdir web2 && cd web2

cd /home/web/html/web2/ && mkdir typecho && cd typecho

wget https://github.com/typecho/typecho/releases/download/v1.2.1/typecho.zip

unzip typecho.zip

rm typecho.zip
echo "define('FS_METHOD', 'direct'); define('TYPECHO_REDIS_HOST', 'redis'); define('TYPECHO_REDIS_PORT', '6379');" >> /home/web/html/web2/typecho/typecho-config-sample.php

四、配置Caddyfile,以kjlion.com为例

nano /home/web/caddy/Caddyfile
{

        frankenphp

        order mercure after encode

        order vulcain after reverse_proxy

        order php_server before file_server

        order php before file_server

}





kjlion.com {

        root * public/web1/wordpress

        encode zstd gzip

        php_server

}

五、启动环境

wget -O /home/web/docker-compose.yml https://raw.githubusercontent.com/kejilion/docker/main/docker-compose-frankenphp.yml

nano /home/web/docker-compose.yml

cd /home/web && docker-compose up -d

六、安装PHP扩展

docker exec -it web install-php-extensions mysqli gd intl zip opcache

docker exec -it web install-php-extensions exif imagick redis

docker exec web sh -c 'echo "upload_max_filesize=50M \n post_max_size=50M" > /usr/local/etc/php/conf.d/uploads.ini'

docker exec web sh -c 'echo "memory_limit=256M" > /usr/local/etc/php/conf.d/memory.ini'

docker exec web sh -c 'echo "max_execution_time=1200" > /usr/local/etc/php/conf.d/max_execution_time.ini'

docker exec web sh -c 'echo "max_input_time=600" > /usr/local/etc/php/conf.d/max_input_time.ini'

七、创建数据库

docker exec -it mysql mysql -u root -p

CREATE DATABASE web1;

GRANT ALL PRIVILEGES ON web1.* TO 'kejilion'@'%';

八、重启环境

cd /home/web && docker-compose restart

01

发表评论

您是第 32640 位访客