summaryrefslogtreecommitdiff
path: root/doc/note/qemu/php-dev-server.txt
blob: c1a8b019bf2da61cb540bdc5cff428d39ae31e37 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48

# PHP Dev Server

## Setup

true \
  && SUDO= \
  && PKGADD="$SUDO apt install -y --no-install-recommends" \
  && PKGDEL="$SUDO apt purge -y" \
  && ${PKGADD:?} apt-transport-https lsb-release ca-certificates curl \
  && curl -sSL https://packages.sury.org/php/apt.gpg | $SUDO tee /etc/apt/trusted.gpg.d/php.gpg >/dev/null \
  && echo "deb https://packages.sury.org/php/ $(lsb_release -sc) main" | $SUDO tee /etc/apt/sources.list.d/php.list >/dev/null \
  && $SUDO apt update \
  && ${PKGADD:?} php7.3-cli php7.3-sqlite3 \
  && $SUDO apt clean \
  && true


## Run

true `# Setup common vars (host/guest)` \
  && GUESTWD=/home/user/serv \
  && GUESTSUDO=sudo \
  && CPY_INN="tmp" \
  && CPY_OUT="tmp" \
  && SSH="ssh user@localhost -p10022 -oUserKnownHostsFile=/dev/null -oStrictHostKeyChecking=no" \
  && true

true `# Setup mounts & persistence (host)` \
  && tar c ${CPY_INN:?} | ${SSH:?} -- sh -c 'true && mkdir -p '"${GUESTWD:?}"' && cd '"${GUESTWD:?}"' && tar x' \
  && $SSH -- sh -c "true && $GUESTSUDO mount -tcifs //10.0.2.2/beef-webapp /mnt/beef-webapp" \
  && $SSH -- sh -c "true && mkdir ${GUESTWD:?}/src && $GUESTSUDO mount --bind /mnt/beef-webapp/src \"${GUESTWD:?}/src\"" \
  && true

true `# Run dev server (guest)` \
  && cd "${GUESTWD:?}" \
  && DEBUG=1 php -dassert.bail=1 -dzend.assertions=1 -dassert.exception=1 -S 0.0.0.0:8080 src/index.php \
  && true

true `# Copy persistence from vm back to host (host)` \
  && $SSH -- sh -c "true && cd \"${GUESTWD:?}\" && tar c \"${CPY_OUT:?}\"" | tar x \
  && true


## Links

- [Install old php](https://tecadmin.net/how-to-install-php-on-debian-12/)