How to use a Linux Webserver with a FileMaker Server
FileMaker Server does an excellent job of configuring Apache (on OS X) or IIS (on Windows) so you can quickly host a website using Custom Web Publishing. However it is possible to use a Linux server running PHP and a popular web server like Apache or Nginx. Actually FileMaker provide all the PHP API files in a zip file just for this purpose.
Credit to Nicholas Orr for his original article.
In our case a client with an existing large enterprise IT setup wanted to publish some data in an FileMaker solution to the web. Internal security policies dictated that the database server could not be accessible from the internet (as standard with their other in-house SQL and Oracle databases) and all web requests would need to be directed to a dedicated web server running with appropriate firewall rules and security policy applied. The client are also a Linux shop and indicated a strong desire to serve the website from an existing production web server running Apache on RedHat Enterprise Linux 6.
The Windows 2012 server was first upgraded with FileMaker Server 14 and configured for Single Server role with PHP & XML enabled.
IIS will only be providing access for CWP and the FileMaker Admin Console so all communication between the web server and the FileMaker server can be over SSL. We don’t need to cater for web requests that could come to port 80. This setup mitigates an internal attack where a user on the company network could potentially view unencrypted traffic between the servers and capture login/password data. IIS was also configured with a valid 3rd party SSL certificate (more on this later) and the *:80 binding for the FMI-TEST site was removed.
Finally grab a copy of
FileMaker Server\Web Publishing\FM_API_for_PHP_Standalone.zip and copy it to the Linux web server.
The steps below are specifically for RHEL6 and the Apache/PHP packages yum provides. There is no reason however the steps can’t be translated to other disto’s or web services such as Nginx. I am only going to focus on the FileMaker specific parts of the install. The web is full of apache config guides so I will assume you already have a functioning, properly configured web server.
- Ensure the following packages are installed with:
yum install httpd php5 mod_ssl
- Extract the FM_API_for_PHP_Standalone.zip to an appropriate location. I used:
Once complete it should look like above.
- SELinux on RHEL6 will prevent the httpd process accessing files in this location. To update the definitions run the following:
semanage fcontext -a -t httpd_sys_content_t "/usr/share/php/(/.*)?"
restorecon -R -v /usr/share/php/
- Edit the php.ini file located at /etc/php.ini and update the include path to include this location. I changed:
include_path = ".:/php/includes" to
include_path = ".:/usr/share/php/FM_API:/php/includes"
/usr/share/php/FileMaker/conf/filemaker-api.phpand update the host option
$__FM_CONFIG['host spec']to point to the FileMaker server and use SSL. e.g.:
$__FM_CONFIG['hostspec'] = 'https://prod-fms1.example.com.au';
Now restart apache.
To direct database requests to the FileMaker server just ensure when you define $fm in your php connect function you specify https. For example:
$fm = new FileMaker ( 'database', 'https://prod-fms1.example.com.au', 'php_user', 'php_password');
Self Signed Certificates
I mentioned above that a valid 3rd party SSL certificate was applied to IIS. Actually the certificate was from a vendor on the FileMaker list that was inserted using the fmsadmin tool; which as a side effect installs it automatically in IIS for use.
While paying for production certificates is fine, in some situations (like a development environment) you still want to replicate the same architecture as production but without the expense and management of additional SSL certificates. The default self signed FMI certificate, or another self signed (or company signed) SSL certificate can be use in IIS instead. However when connecting from PHP on the Linux web server it will throw a certificate error and prevent any further communication.
You can override this in:
/usr/share/php/FileMaker/conf/filemaker-api.php by setting one or both of these additional curl options as required:
$__FM_CONFIG['curlOptions'] = array(CURLOPT_SSL_VERIFYHOST => false);
$__FM_CONFIG['curlOptions'] = array(CURLOPT_SSL_VERIFYPEER => false);
Restart Apache to pick up the changes and you are away!
If you have any questions or queries feel free to contact us