Plesk

How to update web server settings via CLI for all domains on Plesk for Linux server?

Question

How to update web server settings via CLI for all domains on a Plesk for Linux server?

Answer

  1. Connect to the server using SSH.

  2. Execute one of the commands depending on which setting should be changed:

    • To enable serving PHP by nginx:

      # plesk bin site -l | while read i; do plesk bin subscription --update-web-server-settings $i -nginx-serve-php true; done

    • To disable the option Domains > example.com > Apache & nginx Settings > Smart static files processing on all domains:

      # plesk bin site -l | while read i; do plesk bin domain --update-web-server-settings $i -nginx-transparent-mode true; done

    • To enable the options Domains > example.com > Apache & nginx Settings > Serve static files directly by nginx on all domains:

      # plesk bin site -l | while read i; do plesk bin domain --update-web-server-settings $i -nginx-serve-static true; done

    Other settings can be updated by substituting the setting name (after --update-web-server-settings $i) in the commands above.

    Available settings

    • -apache-directory-index <directory index> - Set index pages for the specified website. For example: index.html index.htm index.text

    • -apache-restrict-follow-sym-links true|false - Restrict the ability to follow symbolic links.

    • -nginx-proxy-mode <true|false> - Proxy mode

    • -nginx-transparent-mode <true|false> - Smart static files processing

    • -nginx-serve-static <true|false> - Serve static files directly by nginx

    • -nginx-static-extensions <extensions> - Sets static files extensions that should be served directly by nginx. If empty value is specified, the static files extensions from the default nginx configuration (/var/www/vhosts/example.com/system/conf/last_nginx.conf) will be used. Use this option with the -nginx-serve-static command.

    • -nginx-serve-php <true|false> - Turns on/off processing PHP files by the nginx reverse proxy server. The default value is "false".