The Problem
Cannot open php file in htdocs folder.
Message is “You don’t have permission to access the requested directory. There is either no index document or the directory is read-protected. You don’t have permission to access the requested object. It is either read-protected or not readable by the server.”
Diagnosis
PHP and/or web serving hasn’t been configured properly on the machine.
Response
Follow the instructions provided at Claris FileMaker Server Help. Follow the “Hosting Websites” link and then follow the link “Hosting PHP websites.”
In short, you need to setup FMS to serve PHP from the command line. You will need to ensure that FMS web publishing is enabled and the status is RUNNING. This may require you to download a Java JRE.
After doing this, STOP and RESTART all services associated with FileMaker Server.
Test a php file, hopefully it works.
Still not working?
Put a file into the web root named index.php. For setup and testing the content of my index.php looks like this:
<?php
phpinfo();
?>
FileMaker Server controls Apache and uses configuration files stored in /Library/FileMaker\ Server/HTTPServer/conf/
.
You need to modify httpd.conf
to get it working for you.
Search for the DirectoryIndex block.
192 <IfModule dir_module>
193 DirectoryIndex index.html
194 </IfModule>
Add index.php to that instruction. It is first in, best dressed, so if you’re using .php, place it first. It should look like this.
192 <IfModule dir_module>
193 DirectoryIndex index.php index.html
194 </IfModule>
Now search for the FilesMatch code block that handles .php extensions
208 <FilesMatch "\.php$">
209 Require all denied
210 </FilesMatch>
You want to change denied
to granted
208 <FilesMatch "\.php$">
209 Require all granted
210 </FilesMatch>
Save the file and exit.
Including PHP in the mix
The default configuration file for PHP is stored in a different location to httpd.conf
and that needs to be included. Although we’ve just modified httpd.conf
it can be easier for maintenance when we put our modifications to the standard config into the extra
directory.
We’ll create an additional file there called httpd-php.conf
.
cd /Library/FileMaker\ Server/HTTPServer/conf/extra
touch httpd-php.conf
We want to include one of the config files that are included in /Library/FileMaker\ Server/Web\ Publishing/publishing-engine/php/
. Switch to that directory and you’ll see two directories, mojave and catalina. Choose the appropriate directory for your OS. I’m on catalina. Within the directories there are two config files and we want to use the one which is modified for FMI. That is, httpd.fmi.conf.php
.
We’ll edit our new config file now that we have the details we need.
vi httpd-php.conf
Insert the following text, make sure you get the correct OS for your setup in the path. If you’re on mojave, specify the mojave directory.
Include "/Library/FileMaker\ Server/Web\ Publishing/publishing-engine/php/catalina/httpd.fmi.conf.php"
Save and exit.
After you save your file, change the permissions.
sudo chown fmserver:fmsadmin httpd-php.conf
Restart Apache
FileMaker Server provides a batch script to control Apache. It takes exactly the same commands as apachectl
.
cd /Library/FileMaker\ Server/HTTPServer/bin
sudo ./httpdctl graceful
Give Apache a minute to reboot and check localhost in your browser.
Good luck, and let us know how you go.