Moss allows you to specify the PHP version that a website will use. Moreover, you're free to upgrade/downgrade the PHP version of your websites at will. Hence you may have multiple sites using different PHP versions, even if they're on the same server.
Moss ensures that the proper version of
php-fpm is employed to serve your applications and to run your deployment scripts. But what if you need to run something right from your server? How can you make sure the PHP version of your website is being used? Easy, just activate a virtual environment for your site.
Activate your site's environment
We've taken the approach followed by Python's virtualenv to isolate the PHP environment of an application from another one. While you're within the virtual environment of a site, any call to
php-fpm will use the version you set up in Moss for such website.
- Enter virtual environment: source the activation script at
- Do stuff
- Exit virtual environment: run
deactivatecommand (prompt restores)
The following example with a PHP 5.6 site shows how it works:
user@myserver$ cd sites/mysite
user@myserver$ ls bin/
activate composer php php-fpm
user@myserver$ source bin/activate # enter virtualenv
(mysite) user@myserver$ php --version
PHP 5.6.31-6+ubuntu16.04.1+deb.sury.org+1 (cli)
(mysite) user@myserver$ php-fpm --version
PHP 5.6.31-6+ubuntu16.04.1+deb.sury.org+1 (fpm-fcgi)
(mysite) user@myserver$ deactivate # exit virtualenv