PHP-FPM – config improvements

We’ve already installed Nginx web server, PHP, run wrappers and configure php.ini settings. Next step will be some small improvements on global PHP-FPM configuration and also, additional settings on websites wrappers. Today we will edit /etc/php-fpm/version/fpm/php-fpm.conf file. It’s PHP-FPM main configuration file. Not PHP like php.ini from last chapter, but for FastCGI Process Manager. There is no time for unnecessary descriptions, let’s edit this file.

Continue reading “PHP-FPM – config improvements”

Nginx and PHP – configure php.ini file

We already have a configured a Nginx web server and PHP-FPM wrapper. It’s time to change PHP default settings now – default configuration files from Ubuntu or Debian repositories aren’t bad, but we can make them better for our needs. In this chapter we will change only one file, php.ini, which should be located on /etc/php/YOUR_VERSION/fpm/ directory. Of course, fell free to use other settings than proposed on this blog entry.

Continue reading “Nginx and PHP – configure php.ini file”

PHP – generate secure password

This post will be very short. We must sometimes generate random password in PHP – for example when users create accounts on our service, or we send them new password after reset. Yes, we can do this in many ways, but most of them are bad solutions – we can create function (or method, class) to generate random string from given range, do it manually and try to make all random. But it isn’t random – it must by real secure, we must  use cryptographically secure pseudorandom generator.

Continue reading “PHP – generate secure password”

Nginx – Add PHP-FPM

Recently I posted an entry related to the installation and basic configuration of the Nginx web server. In this episode, we’ll take care of adding PHP to it. Unlike Apache, we can not use the module for the server (mod_php) because Nginx does not have its native support. However, it is possible to redirect PHP-related requests to a separate PHP wrapper service. For this purpose, we will re-use Ubuntu distribution as well as an additional PPA repository. The entry does not describe the exact configuration of PHP, but only its installation and connection with Nginx – details of additional settings will be raised in the subsequent episodes of the cycle.

Continue reading “Nginx – Add PHP-FPM”

GROUP BY ($group) in MongoDB

Mongodb is not relational database, but we sometimes want to use functions similar from such databases. I wrote about JOINs in Mongo few weeks ago, but it isn’t only one option. Second and very interesting is grouping – something like GROUP BY in for example MySQL database. Do we really need grouping in Mongo? Maybe yes, maybe no, but I must implement such option for one of application modules. It isn’t difficult and we can do this very simply. Again, I will use examples from PHP and mongodb extension for this language – code should be very similar in other languages.

Continue reading “GROUP BY ($group) in MongoDB”