Skip to content
Greg Bowler edited this page Jun 10, 2018 · 7 revisions

Running a PHP.Gt WebEngine application can be done by any web server, including PHP's own inbuilt webserver for development purposes. This page describes the setup process for Nginx, Apache and PHP's inbuilt server.

Inbuilt webserver

For development purposes, WebEngine applications can be served without the need to install a webserver because PHP itself can serve HTTP requsts.

Warning:

This web server was designed to aid application development. It may also be useful for testing purposes or for application demonstrations that are run in controlled environments. It is not intended to be a full-featured web server. It should not be used on a public network.

If you have installed the PHP.Gt CLI tools, serve your application with the command gt serve.

PHP's inbuilt server can be used to serve any directory by calling php -S 0.0.0.0. The inbuilt webserver can also be passed an optional working directory and a router script. For WebEngine applications, the working directory needs to be the application's www/ directory, and the router script needs to be vendor/phpgt/webengine/go.php.

Manually serve your WebEngine application via PHP's inbuilt server with the following command:

php -S 0.0.0.0 -t ./www vendor/phpgt/webengine/go.php

NGINX configuration

Assuming php-fpm module is installed on the unix-like system, and the root application directory is at /var/www/example, the following configuration file will serve requests to http://example.com.

server {
	server_name		example.com;
	listen			80;
	charset			utf-8;
	root			/var/www/example/www;

	location / {
		try_files	$uri @webengine;
	}

	location @webengine {
		fastcgi_pass	unix:/var/run/php/php7.1-fpm.sock;
		include		fastcgi_params;
		fastcgi_param	SERVER_NAME $host;
		fastcgi_param	SCRIPT_FILENAME /var/www/example/vendor/phpgt/webengine/go.php;
	}
}

Apache configuration

// TODO.

Clone this wiki locally