#!/usr/bin/env bash set -euo pipefail APP_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" DB_NAME="${PHPSITE_DB_NAME:-phpsite}" DB_USER="${PHPSITE_DB_USER:-phpsite_app}" DB_PASS="${PHPSITE_DB_PASS:-phpsite_local_password}" ADMIN_USER="${PHPSITE_ADMIN_USER:-admin}" ADMIN_PASS="${PHPSITE_ADMIN_PASS:-admin123}" NGINX_SITE="/etc/nginx/sites-available/phpsite" NGINX_ENABLED="/etc/nginx/sites-enabled/phpsite" require_cmd() { command -v "$1" >/dev/null 2>&1 || { echo "Missing required command: $1" >&2 exit 1 } } require_cmd php require_cmd mysql require_cmd nginx require_cmd curl sudo systemctl enable --now mariadb sudo systemctl enable --now php8.3-fpm sudo mysql < "${APP_DIR}/config.local.php" < '127.0.0.1', 'db_name' => '${DB_NAME}', 'db_user' => '${DB_USER}', 'db_pass' => '${DB_PASS}', ]; PHP sudo chgrp www-data "${APP_DIR}/config.local.php" chmod 0640 "${APP_DIR}/config.local.php" sudo install -d -m 0755 /home/alex/sites sudo ln -sfn /home/alex/sites/phpsite.conf "${NGINX_SITE}" sudo ln -sfn "${NGINX_SITE}" "${NGINX_ENABLED}" sudo rm -f /etc/nginx/sites-enabled/default if systemctl is-active --quiet apache2; then sudo systemctl disable --now apache2 fi sudo nginx -t sudo systemctl enable --now nginx sudo systemctl reload nginx echo "phpsite deployed at http://127.0.0.1/ and http://127.0.0.1:8000/" echo "local login: ${ADMIN_USER} / ${ADMIN_PASS}"