Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Next revision
Previous revision
Next revisionBoth sides next revision
howto:php [2010/02/24 23:53] – created digitalmanhowto:php [2015/11/02 11:24] – Initial documentation for PHP-FPM deuce
Line 1: Line 1:
 ====== Use PHP with the Synchronet Web Server ====== ====== Use PHP with the Synchronet Web Server ======
-FIXME+Dynamic [[http://php.net/|PHP]] content may be served by the Synchronet Web Server using //PHP-CGI// or, for 3.17a builds newer than November 1st, 20015, using //PHP-FPM// PHP-CGI is slower and less efficient than PHP-FPM, so PHP-FPM is recommended when available. 
 + 
 +PHP applications //will not// magically have access to your Synchronet content (e.g. users, messages, files). 
 + 
 +===== Install PHP ===== 
 + 
 +Make sure you get PHP-CGI or PHP-FPM support as needed. On *nix platforms, this is achieved for PHP-CGI by excluding the ''--with-apxs2'' option from the ''configure'' command-line during the installation process. 
 + 
 +===== Install PHP Content ===== 
 + 
 +Install your PHP application(s) into your ''[Web] Root directory'', as specified in your ''[[config:sbbs.ini]]'' file. 
 + 
 +:!: Note: many PHP web applications require 3rd party database support (e.g. MySQL), which may need to be installed as well. 
 + 
 +===== Configure Web Server For PHP-CGI ===== 
 + 
 +Edit your ''[[dir:ctrl]]/[[config:sbbs.ini]]'' file, ensuring: 
 +  - The Web Server is enabled (''AutoStart=true''
 +  - If your application has an ''index.php'' file, that that file is included in the ''IndexFileNames'' value (comma separated list) 
 +  - The ''MaxCgiInactivity'' value is set to something sane (default: 120 seconds) 
 +  - The ''CGIExtensions'' key value includes ''.php'' (comma separated list) 
 +  - The ''Options'' key value **does not** include the ''NO_CGI'' option (bit 5) 
 +    
 +Example: 
 +<file> 
 +[Web] 
 +AutoStart=true 
 +IndexFileNames=index.html,index.ssjs,index.php 
 +MaxCgiInactivity=120 
 +CGIExtensions=.cgi,.pl,.php 
 +Options=NO_HOST_LOOKUP 
 +</file> 
 + 
 +Edit your ''[[dir:ctrl]]/[[config:web_handler.ini]]'' file. 
 + 
 +If you're using Synchronet for Windows v3.15 (Web Server Revision 1.525 or later), edit the ''[CGI.Win32]'' section, otherwise, edit the ''[CGI]'' section: 
 + 
 +Ensure the ''php'' key value points to the correct path (location) of your ''php-cgi'' (or ''php-cgi.exe'') file.  
 + 
 +Example (*nix): 
 + 
 +<file> 
 +[CGI] 
 +php = /usr/local/bin/php-cgi 
 +</file> 
 + 
 +Example (Windows): 
 + 
 +<file> 
 +[CGI.Win32] 
 +php = /php/php-cgi.exe 
 +</file> 
 + 
 +Edit your ''[[dir:ctrl]]/[[config:cgi_env.ini]]'' file, ensuring it contains the following lines: 
 +<file> 
 +[REDIRECT_STATUS] 
 +value=200 
 +</file> 
 + 
 +:!: If you see the PHP error ''This PHP CGI binary was compiled with force-redirect enabled.'', that indicates that your ''[[dir:ctrl]]/[[config:cgi_env.ini]]'' file is missing this key. 
 + 
 +===== Configure Web Server For PHP-FPM ===== 
 + 
 +Edit your ''[[dir:ctrl]]/[[config:sbbs.ini]]'' file, ensuring: 
 +  - The Web Server is enabled (''AutoStart=true''
 +  - If your application has an ''index.php'' file, that that file is included in the ''IndexFileNames'' value (comma separated list) 
 +  - The ''MaxCgiInactivity'' value is set to something sane (default: 120 seconds) 
 +  - The ''Options'' key value **does not** include the ''NO_CGI'' option (bit 5) 
 +    
 +Example: 
 +<file> 
 +[Web] 
 +AutoStart=true 
 +IndexFileNames=index.html,index.ssjs,index.php 
 +MaxCgiInactivity=120 
 +Options=NO_HOST_LOOKUP 
 +</file> 
 + 
 +Edit the [[server:web#webctrl.ini per-directory configuration file|webctrl.ini file]] at the root of your PHP application and configure it to use FastCGI. 
 + 
 +Example: 
 +<file> 
 +[*.php] 
 +FastCGISocket=127.0.0.1:9000 
 +</file> 
 + 
 +Make sure that php-fpm is running and that the listener socket is the same as in the FastCGISocket line. 
 + 
 +:!: If you see the PHP error ''This PHP CGI binary was compiled with force-redirect enabled.'', that indicates that your ''[[dir:ctrl]]/[[config:cgi_env.ini]]'' file is missing this key. 
 ===== See Also ===== ===== See Also =====
-  * [[:howto:|HowTo index]]+  * [[http://php.net/]] 
 +  * [[:server:web|Synchronet Web Server]] 
 +  * [[:howto:|How-To Pages]]
  
howto/php.txt · Last modified: 2023/02/05 19:33 by digital man
Back to top
CC Attribution 4.0 International
Driven by DokuWiki Recent changes RSS feed Valid CSS Valid XHTML 1.0