frankenphp icon indicating copy to clipboard operation
frankenphp copied to clipboard

WordPress?

Open codeagencybe opened this issue 2 years ago • 6 comments

Can this run WordPress also or is it targeting custom symphony applications only?

codeagencybe avatar Oct 17 '22 17:10 codeagencybe

This should work with any PHP application, and WordPress is definitely one of the main goals. But I've not tested it yet. Any help on this is welcome!

dunglas avatar Oct 17 '22 17:10 dunglas

@dunglas

OK that is nice to hear! At the moment a bit busy with projects that need to be finished this week, but I will try to spend some time on testing this weekend. I have a local officelab server running here with Docker and K3s where I can do some testing. I like the idea a lot about using Go as a webserver. It's a lot faster. Really curious how it handles multi threading and heavy load Wordpress projects.

Is it also possible to disable Caddy and use my own ingress like Traefik? Or will that break some functionality?

codeagencybe avatar Oct 17 '22 17:10 codeagencybe

This should work if you use the standalone go library and patch Caddy to use it, but again I've not tested that 😅

dunglas avatar Oct 17 '22 18:10 dunglas

Maybe you'll have to compile your own Træfik instance with frankenPHP or patch the frakenPHP lib to work as plugin with Træfik because of the Yaegi usage inside Træfik. They disable some libraries to load plugins inside that (like unsafe) and I don't know if the C lib is authorized inside Træfik. (cc @ldez)

darkweak avatar Oct 18 '22 18:10 darkweak

I got WordPress working by providing $_SERVER['PHP_SELF'] manually here.

dylanblokhuis avatar Oct 20 '22 07:10 dylanblokhuis

@dylanblokhuis thanks for the research! Would you mind opening a pull request? This env var should probably be set here: https://github.com/dunglas/frankenphp/blob/main/cgi.go#L15

dunglas avatar Oct 20 '22 08:10 dunglas

@dylanblokhuis How did you install the MySQL extension? When starting WordPress using the latest dunglas/frankenphp Docker image I get an error about missing mysql_connect():


Fatal error: Uncaught Error: Call to undefined function mysql_connect() in /app/public/wp-includes/wp-db.php:1788 Stack trace: #0 /app/public/wp-includes/wp-db.php(724): wpdb->db_connect() #1 /app/public/wp-includes/load.php(561): wpdb->__construct('app', 'app', 'app', 'db') #2 /app/public/wp-settings.php(124): require_wp_db() #3 /app/public/wp-config.php(98): require_once('/app/public/wp-...') #4 /app/public/wp-load.php(50): require_once('/app/public/wp-...') #5 /app/public/wp-blog-header.php(13): require_once('/app/public/wp-...') #6 /app/public/index.php(17): require('/app/public/wp-...') #7 {main} thrown in /app/public/wp-includes/wp-db.php on line 1788

khromov avatar Oct 26 '22 19:10 khromov

@khromov create a new image using dunglas/frankenphp and use install-php-extensions to install the required WordPress php extensions, dont forget to enable them in your php.ini aswell

dylanblokhuis avatar Oct 27 '22 07:10 dylanblokhuis

@khromov documentation for said script lives here: https://github.com/mlocati/docker-php-extension-installer and

An example of the Dockerfile might look like:

FROM dunglas/frankenphp:latest

RUN install-php-extensions mysqli 
# any other extension from the table: https://github.com/mlocati/docker-php-extension-installer#supported-php-extensions

# untested, and not 100% sure of these paths
COPY --from=wordpress:latest /var/lib/html  /app/public

# profit?

withinboredom avatar Oct 27 '22 17:10 withinboredom

Here is a fully working example: https://github.com/dunglas/frankenphp-wordpress

cc @dragoonis

dunglas avatar Oct 30 '22 15:10 dunglas