One of the main benefits of using Moss is that you rarely have to deal with the low-level details of server and site configuration 😊. However, sometimes you need to get your hands dirty and provide extra configuration for your applications.

Moss will honor your own config and won't overwrite it. In this article we tell you how you can set it up.

PHP-FPM extra config

Moss serves your PHP applications using PHP-FPM, an implementation of the FastCGI protocol for PHP.

The configuration for PHP-FPM can be found on your servers within directories /etc/php/<version>/fpm/, where <version> are each of the PHP versions installed on your server. For the sake of simplicity, in the remainder of this article we provide examples for PHP 7.0. However everything stated here applies to all supported PHP versions. Just substitute 7.0 for the PHP version you're actually tweaking.

moss@<server>:~$ ls -F /etc/php/7.0/fpm/
conf.d/  php-fpm.conf  php.ini  pool.d/

Moss sets up some of these configuration files on your behalf. But luckily, you may overwrite the values of the directives you want by including additional .ini files within /etc/php/7.0/fpm/conf.d/ (e.g. /etc/php/7.0/fpm/conf.d/99-extra.ini).

Moss won't overwrite the configuration that you put into those files. Once you're done with the config, log into Moss and provision your website so that PHP-FPM is reloaded.

Nginx extra config

Moss installs and sets up the Nginx web server on your behalf. You can find the Nginx configuration files within the /usr/local/openresty/nginx/conf/ and /usr/local/openresty/nginx/sites/ directories of your server.

You can tweak the configuration of each site by editing the following files:

  • /usr/local/openresty/nginx/conf/server_params.site.com: Nginx directives within the server block of your site.com.
  • /usr/local/openresty/nginx/conf/root_params.site.com: Nginx directives within the location / block of your site.com.
  • /usr/local/openresty/nginx/conf/fastcgi_params.site.com: Nginx directives within blocks with FastCGI configs (block location ~ .php$ at the moment) of your site.com.

Moss won't overwrite the configuration that you put into those files. Once you're done with the config, log into Moss and provision your website so that Nginx is reloaded.

Apache extra config

Most sites provisioned via Moss either use Nginx in standalone mode or as a reverse proxy in front of Apache. In the latter case, you may fine-tune Apache configs in different ways:

  • Create config files within /etc/apache2/conf-available/ and run a2enconf afterwards (e.g. create file myconfig.conf and run a2enconf myconfig). Since you're changing the global configuration, you must SSH into your server as user moss and become root using sudo. Once you're done, you must log into Moss and provision your website so that Apache is reloaded.
  • Create .htaccess files within your sites' directories. Since you're dealing with a given website, you must create these files as the server user that runs such website.
  • WordPress users will likely employ a plugin to make some configs like setting up the browser cache, among others. Such plugins could add the required configs to a .htaccess file, so you don't need to do it by hand.

What's next?

Need some examples? Below you can find articles that describe some common use cases:

Don't hesitate to contact us if you have any other use case in mind 😉.

Did this answer your question?