dunglas / frankenphp

🧟 The modern PHP app server
https://frankenphp.dev
MIT License
6.89k stars 236 forks source link

How to use (install) standalone binary? No documentation #372

Open megavolkan opened 11 months ago

megavolkan commented 11 months ago

I have downloaded standalone binary file for my M1 Mac mini (frankenphp-mac-arm64). But there is no information on how to use/install the binary? Where to put it? Rename it? I'm a docker user but trying to escape from the complexity of docker. Using binary seems to be a great option but there is no clear documentation on how to use downloaded binary from scratch.

withinboredom commented 11 months ago

there is no information on how to use/install the binary? Where to put it? Rename it?

Where do you want to use it? If you want it globally installed, you can put it somewhere in your PATH (like /usr/bin/frankenphp if it is anything like Linux) or you can put it right in your project (like some people do with composer.phar).

Using binary seems to be a great option but there is no clear documentation on how to use downloaded binary from scratch.

You should be able to run ./frankenphp --help and get some useful output, and if not, be sure to point it out. Beyond that, take a look at this page to get a pretty good idea on how to configure it (specifically, the Caddyfile part).

Hopefully, this helps!

This is still a relatively young project, so there is a ton of missing documentation, installers, and stuff like that. Contributions welcome!

vanodevium commented 11 months ago

For the latest frankenphp use next snippet.

please run in your project folder or any other folder

curl -L -o frankenphp https://github.com/dunglas/frankenphp/releases/latest/download/frankenphp-linux-x86_64
chmod +x frankenphp
./frankenphp --version
boukew99 commented 1 month ago

I have a similar use case and I am willing to write a documentation page for it. It would be aimed specifically at being an alternative to Caddy + PHP-FPM with the promise of being easier to setup. I will leave my idea of outline below, but I am still new to Caddy and FrankenPHP, so any guidance is appreciated (I also need this guide).

  1. move frankenphp<arch> to /bin as frankenphp
  2. inspect command frankenphp phpserver --help
  3. point frankenphp to /var/www/html
  4. start frankenphp with systemd
  5. caddy + frankenphp configurations

I am writing it mainly for a Raspberry Pi (Debian) setup as that is what I am familiar with. Also, it is not entirely clear where frankenphp stops and Caddy starts (for example, the /etc/caddy/Caddyfile is shared) so I could elaborate that.
Let me know if that sounds good and is helpful!

withinboredom commented 1 month ago

Also, it is not entirely clear where frankenphp stops and Caddy starts

Basically, frankenphp adds a php_server directive to caddy, that is documented here: https://github.com/dunglas/frankenphp/blob/main/docs/config.md

Everything outside of that is 100% caddy.

move frankenphp to /bin as frankenphp

I have php-zts (ppa:ondrej/php-zts vs ppa:ondrej/php) installed locally and then build frankenphp from source (essentially using the instructions specified in the dockerfile) which nets more speed and easier to install extensions.

Here's the gist:

  1. uninstall php if you already have non-zts installed
  2. change the ppa or configure the zts ppa
  3. install php again with desired extensions—if you were using php for other things, they shouldn't break. zts just has memory protections enabled for threading, which frankenphp requires.
  4. install a few packages:
apt-get -y --no-install-recommends install \
    libargon2-dev \
    libbrotli-dev \
    libcurl4-openssl-dev \
    libonig-dev \
    libreadline-dev \
    libsodium-dev \
    libsqlite3-dev \
    libssl-dev \
    libxml2-dev \
    zlib1g-dev
  1. clone frankenphp to /usr/src/frankenphp and cd into it
  2. download go from https://go.dev/doc/install
  3. run rm -rf /usr/local/go && tar -C /usr/local -xzf go1.23.1.linux-amd64.tar.gz
  4. set export PATH=$PATH:/usr/local/go/bin
  5. run go install -ldflags "-w -s -X 'github.com/caddyserver/caddy/v2.CustomVersion=FrankenPHP'"

Some notes:

This isn't well-documented (because it will vary from distribution to distribution, etc). But this should serve as a decent starting point.

boukew99 commented 1 month ago

Thank you for taking the time to write it out. However this seems still too challenging as of now. Specifically point 2 and I am also lacking Golang experience.