Ticket #9300: Final Report.txt

File Final Report.txt, 6.0 KB (added by dave.vishal789, 7 years ago)
1Apache http server php support:
3There are three ways to set up PHP to work with Apache 2.x You can run PHP as a handler, as a CGI, or under FastCGI.
51. Installing as an Apache handler
6You need to insert the following lines into your Apache httpd.conf configuration file to load the PHP module for Apache 2.x:
8Example #1 PHP and Apache 2.x as handler
10LoadModule php5_module "c:/php/php5apache2.dll"
11AddHandler application/x-httpd-php .php
13# configure the path to php.ini
14PHPIniDir "C:/php"
15Note: Remember to substitute your actual path to PHP for the C:/php/ in the above examples. Take care to use either php5apache2.dll or php5apache2_2.dll in your LoadModule directive and verify that the referenced file is in fact located at the file path that you point to in this directive.
17The above configuration will enable PHP handling of any file that has a .php extension, even if there are other file extensions. For example, a file named example.php.txt will be executed by the PHP handler. To ensure that only files that end in .php are executed, use the following configuration instead:
19<FilesMatch \.php$>
20 SetHandler application/x-httpd-php
21 </FilesMatch>
24If PHP is run as an Apache Module, then when a file is created it does this as the “apache” user. Similarly, when it needs overwrite files it needs those files to be writable by the Apache group, or the files need to be owned by “apache” (or they need to be 777 so that everyone can overwrite them).
262. Running PHP as CGI
27To run PHP as CGI, you'll need to place your php-cgi files in a directory designated as a CGI directory using the ScriptAlias directive.
29You will then need to insert a #! line in the PHP files, pointing to the location of your PHP binary:
31Example #2 PHP and Apache 2.x as CGI
34 phpinfo();
38CGI is the simplest, and most common, way to put dynamic content on your web site. However a server deployed in CGI mode is open to several possible vulnerabilities (can be fixed).
403. Running PHP under FastCGI
42Running PHP under FastCGI has a number of advantages over running it as a CGI. Setting it up this way is fairly straightforward:
44Obtain mod_fcgid from » http://httpd.apache.org/mod_fcgid/. Win32 binaries are available for download from that site. Install the module according to the instructions that will come with it.
46Configure your web server as shown below, taking care to adjust any paths to reflect your how you have installed things on your particular system:
48Example #3 Configure Apache to run PHP as FastCGI
49LoadModule fcgid_module modules/mod_fcgid.so
51# Where is your php.ini file?
52FcgidInitialEnv PHPRC "c:/php"
54AddHandler fcgid-script .php
55FcgidWrapper "c:/php/php-cgi.exe" .php
56Files with a .php extension will now be executed by the PHP FastCGI wrapper.
59If PHP would instead be run as FastCGI, then the actual file owner of the account could let PHP write to it’s own files – they woulnd’t need to be “apache” owned nor writable.
60FastCGI is running low on memory. By default the Apache configuration does not include a statement to allocate enough memory. The programs invoked by mod_fcgid continue to consume resources
62My Conclusion:
63Adding php support with cgi is the best way to add php support as far as apache is concerned.
65Nginx php support:
67PHP support can be added to nginx by adding a php.conf file into /etc/nginx/ folder with the codes available on the nginx wiki.
68The other way to add php support to nginx is through fastcgi. In fact adding php support to nginx via fastcgi is much easier than adding php support to apache via fastcgi.
69Nginx does not support CGI due to security reasons (according to nginx wiki) so php support can be added using fastcgi instead.
71My Conclusion:
72I think as far as nginx is concerned adding php support via php.conf file is the simplest - just type a code. A code is available on the nginx wiki which can just be copy-pasted. I think thats awesome if you're a beginner. There are other example codes too. Since Poorman needs php support in a very simple way, the nginx way can be followed. The bonus is it doesnt have file permission issues like there are when php support is added to apache as an apache module.
74Lighttpd php support:
76Lighttpd supports PHP through CGI and FastCGI but prefers FastCGI. However, from what i have read, configuring lighttpd to run php through cgi is simpler than running it through fastcgi but FastCGI is faster. So if you need speed there's no second thought on adding php support fastcgi (though you have to do some extra downloading morever its not very complicated.) For Poorman (from lighttpd only) i think cgi is better because it is simple and its performance is not much worse than fastcgi.
78Cherokee php support:
80Cherokee-admin ships a one-click wizard that will look for the PHP interpreter, it will check whether it support FastCGI, and then it’ll perform all the necessary operations to set it up on Cherokee. If PHP-fpm binaries are found, those will be prioritized over the regular binaries.
81FastCGI is enabled by default. Configuring fastcgi to suit your needs is also very simple. Adding php support to Cherokee is very very simple and very user friendly. All you have to do is click and Cherokee will do the rest. You can tweak it to suit your requirements. Even this is simple in Cherokee.
83Adding php support in Poorman:
85The most widely used method (atleast in my reasearch) to add php support is through FastCGI. However FastCGI is not the simplest of methods to add php support (unless of course it comes prepackaged as in Cherokee). After considering all the methods of adding php support (including as an Apache module, php.conf in Nginx, FastCGI and CGI in Apache, Nginx, Cherokee and Lighttpd), I have come to this conclusion: the best way to add php support to Poorman is through FastCGI because those who have added php support through FastCGI in other webservers already can do it easily and beginners will find it easy to add php support in other webservers.