Debian 9部署Laravel环境(Caddy+MariaDB+PHP 7)

# 安装 Caddy
wget -N --no-check-certificate https://raw.githubusercontent.com/ToyoDAdoubiBackup/doubi/master/caddy_install.sh && chmod +x caddy_install.sh && bash caddy_install.sh

# 安装 PHP
apt-get install php php-fpm php-xml php-mbstring php-mcrypt php-gd php-curl
systemctl start php7.0-fpm
systemctl enable php7.0-fpm

# 修改 PHP-FPM 配置
vi /etc/php/7.0/fpm/pool.d/www.conf
# 找到 listen 开头的行,修改 listen = 127.0.0.1:9000

# 安装 MariaDB(MySQL开源版本)
apt-get install mysql-server php-mysql
mysql_secure_installation

# 编辑 Caddy 配置
vi /usr/local/caddy/Caddyfile
http://example.com {
    root /srv/laravel/public
    fastcgi / 127.0.0.1:9000 php
    rewrite {
        to {path} {path}/ /index.php?{query}
    }
}

# 设置 laravel storage目录可写
chown www-data:www-data -R /srv/laravel/storage

# 重启 Caddy
/etc/init.d/caddy restart

# 查看 Caddy 日志
tail -f /tmp/caddy.log

参考:https://www.hugeserver.com/kb/how-install-wordpress-caddy-debian/