Questions to Answer today ● What could be better than Apache & mod_php? ● What is php-fpm? What does it look like? ● How does it help Apache be better? ● What kind of extra features are in php-fpm? ● What is "Opcode caching"? ● What is Nginix? ● But not exactly - How do I set it up?
php-fpm pools configured separately ● logging ● custom runtime environments ● resource allocation ● running as user/groups ● restrictions around what can access the pool
mod_fcgi Newer, Bigger Brother Duplicates a lot already in php-fpm Useful for non php-fpm cgi’s Can be used with mod_suexec Available in most package managers
Adding an OpCode cache ● Full stack frameworks are big ● Wordpress is big ● Drupal is big ● 100+ php scripts need to be compiled per requests ● php's compiler is still FREAKY FAST ● But still, that's a lot of compiling
Opcode Caching Options ● Zend's Opcache ○ Recently Open Sourced, built into PHP 5.5 ● APC ○ LOTS of years of production use. ○ Additional software ○ APC can also act like a generic cache much like mcached...but that's a whole other talk
Zend’s PHP’s Opcache Looking at Chris Jones' post, in 5.5 is should be as easy as: ; Adding the extension ... zend_extension=opcache.so ; and turning it on... opcache.enable=On
APC - Alternate PHP Cache Install from PECL or your OS's package manager Can use a .php script to see statistics LOTS of blog posts on helping configure with your setup http://www.electrictoolbox.com/apc-php-cache-information/
Replacing Apache Apache is still a GREAT, mature, well tested server Now we get to ask the questions: ● Do we need or even use what it offers? ● Can we squeeze out more performance with something else? ● Is there something easier to configure?
Nginx Was originally a Reverse Proxy -- so built for speed May take less memory (so more for php and mysql) Supports fastcgi natively Allows precise control with a simpler syntax Is not Apache -- so no .htaccess files Still "new" compared to Apache's maturity, but this doesn't mean experimental
Nginx Config location ~ \.php$ { try_files $uri =404; fastcgi_split_path_info ^(.+\.php)(/.+)$; # NOTE: You should have "cgi.fix_pathinfo = 0;" in php. ini fastcgi_pass unix:/var/run/php5-fpm.sock; fastcgi_index index.php; include fastcgi_params;
Nginx Config Like Apache, you can also configure Nginx to: ● route all non-matching requests through an index.php script (Wordpress, Drupal, etc) ● block access to config files, etc. ● configure extra modules to add functionality
Want to dive deeper? Just ask! KC PUG is always looking for speakers and topic ideas Don’t be afraid to speak up! http://www.meetup.com/kcphpug/suggestion/