Skip to content
Pete Clark edited this page Jun 18, 2019 · 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.

Special note on client-side files: If you serve your own WebEngine application using one of the following methods, client-side files such as images, SCSS and ES6 code will not be copied/compiled to the www/ directory and will need to be handled manually. Running gt build is the automated way to do this, which can be performed on a build server as part of the deployment process, but can also be performed manually by your own tools. For more information, read the build system section.

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.2-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