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.
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.
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.
The basic question is: why should we use this type of library and why not use the float type instead? The problem is that computers are not able (and have never been) to handle floating point values with real accuracy. While for some insignificant data this should not be a problem, in the case of recalculating the amounts of money-related transactions, it is already a serious concern. This library frees us from issues related to currency operations, storing them (or just preparing for it), adding or converting. All this without fear about lack of precision.