Advanced Features

Starting and Stopping Services in Linux for PHP

When manually starting and stopping services within a Linux for PHP container, one must use the standard init system to do so.

To start the PHP-FPM server:

$ /etc/init.d/php-fpm start

To stop the PHP-FPM server:

$ /etc/init.d/php-fpm stop

To get the status of the PHP-FPM server:

$ /etc/init.d/php-fpm status

These commands apply to all the main services that are included within all Linux for PHP images :

  • Apache : /etc/init.d/httpd [start/stop/status]
  • nginx : /etc/init.d/nginx [start/stop/status]
  • MariaDB (MySQL) : /etc/init.d/mysql [start/stop/status]
  • PostgreSQL : /etc/init.d/postgresql [start/stop/status]
  • OpenLDAP : /etc/init.d/slapd [start/stop/status]
  • Exim Mail : /etc/init.d/exim [start/stop/status]
  • MongoDB : /etc/init.d/mongod [start/stop/status]
  • OpenSSH : /etc/init.d/sshd [start/stop/status]

Note

All configuration files can be found within the /etc directory.

Automating Services in Linux for PHP

When using a Linux for PHP container in detached mode, it is possible to automate services using the lfphp command. If you wish to start a container with only the MariaDB (MySQL) server running, you would enter the following command when invoking the container:

$ docker run -dit asclinux/linuxforphp-8.2-ultimate:7.4-nts bash -c "lfphp --mysql"

The available services are :

  • Apache (--apache)
  • Exim Mail (--exim)
  • OpenLDAP (--ldap)
  • MariaDB/MySQL (--mysql)
  • nginx (--nginx)
  • PostgreSQL (--pgsql)
  • PHP FPM (--phpfpm)

Note

These optional switches can be combined and that the default behavior of the lfphp command is to start all services when no options are given.

Note

It is possible to get up to date help in using this command by entering the command lfphp --help or lfphp -h.

Package Installation Using the lfphp-get Command

Any Linux for PHP container makes it possible to install optional services from within the container by using the lfphp-get command. To install an additional service, simply enter the following command on the container’s CLI:

$ lfphp-get [options] name_of_service_to_install

Note

The lfphp-get command allows to compile some packages from source, by adding the --compile option to the command.

To get a complete and up to date list of available services, please use the --list option:

$ lfphp-get --list

Note

For now, Linux for PHP does NOT offer an easy way to automate optional services. These must be configured manually by creating and symlinking the appropriate runit scripts (/services/[name_of_service] => /etc/sv/[name_of_service]).

Note

It is possible to get up to date help in using this command by entering the command lfphp-get --help or lfphp-get -h.