Hosting websites > Hosting PHP websites
 

Hosting PHP websites

Custom Web Publishing with PHP lets you use the PHP scripting language to integrate data from FileMaker Pro databases with your customized webpage layouts. In your webpages, you call the FileMaker API for PHP, which is a PHP class created by FileMaker that accesses databases hosted by FileMaker Server. This PHP class connects to the Web Publishing Engine and makes data available to the web server’s PHP engine.

For information on developing a PHP website and preparing a database, see FileMaker Server Custom Web Publishing Guide.

To host a website that uses Custom Web Publishing with PHP:

1. In FileMaker Pro, open the database and edit the privilege set for the account that will access the database. Enable the extended privilege Access via PHP Web Publishing - FMS only.

Note  If your FileMaker Pro database solution uses more than one FileMaker Pro database file, all of the database files accessed using PHP must use this privilege set with the extended privilege Access via PHP Web Publishing - FMS only enabled.

2. Using the CLI, enable Custom Web Publishing with PHP using the following command:

fmsadmin set cwpconfig enablephp=true

If necessary, set additional options for Custom Web Publishing with PHP, such as locale or encoding.

See Using the command line interface.

3. In Admin Console, make sure the Web Publishing Engine is enabled on the master machine. See Web publishing settings.

4. Verify that Custom Web Publishing with PHP is working in your FileMaker Server deployment. If you don’t have a sample to use for testing, you can use the following PHP sample that retrieves data from a sample database. Enter the following URL into a web browser on the machine where FileMaker Server is installed:

http://localhost/fmi-test/phptest.php?lang=en

If you see a success message and sample data from the FMServer_Sample database, then PHP is working in your FileMaker Server deployment.

5. Prepare databases for Custom Web Publishing. See FileMaker Server Custom Web Publishing Guide.

6. Upload the database file to FileMaker Server. See Hosting databases.

Note  If your FileMaker Pro database solution uses more than one FileMaker Pro database file, all of the database files must be on the same computer.

7. Copy your PHP files to the web server’s root folder. In a multiple-machine deployment, this folder is on the master machine. The following shows the default locations:

For IIS (Windows) through HTTP or HTTPS:
[drive]:\Program Files\FileMaker\FileMaker Server\HTTPServer\Conf
where [drive] is the drive on which your FileMaker Server deployment resides.

For Apache (macOS) through HTTP:
/Library/FileMaker Server/HTTPServer/htdocs

For Apache (macOS) through HTTPS:
/Library/FileMaker Server/HTTPServer/htdocs/httpsRoot

On macOS, make sure the folder ownership and permissions allow members of the fmsadmin group to edit the PHP files. See Users, groups, and permissions (macOS).

8. If you have not already done so, copy or move any referenced container objects to the appropriate directory on the master machine.

If a database container field stores a file reference instead of an actual file, then the referenced container object will be stored in the FileMaker Pro Web folder when the record is created or edited. To host your site on FileMaker Server, you must then copy or move the referenced containers to a folder with the same relative location in the root folder of the web server software.

See FileMaker Server Custom Web Publishing Guide for information about using container fields with PHP solutions.

9. To access your PHP website, use the following URL syntax:

<scheme>://<host>[:<port>]/<path>/<filename>

where:

<scheme> is the HTTP or HTTPS protocol.

<host> is the IP address or domain name of the FileMaker Server computer. For a multiple-machine deployment, you can use the IP address or the domain name of the master machine or a worker machine; the web server will forward the URL to the master machine. (Use the IP address or domain name for the Web Publishing Engine on the Connectors > Web Publishing tab.)

<port> is optional and specifies the port that the web server is listening on. If no port is specified, then the default port for the protocol is assumed. For HTTP, the port is port 80; for HTTPS, the port is port 443.

<path> is optional and specifies the folder inside the web server root folder where the PHP file is located.

<filename> is the filename of a page in your website.

For example:

http://192.168.123.101/my_site/home.php