How to change the default index for all websites

Created:

2017-04-20 19:02:31 UTC

Modified:

2017-08-08 13:08:50 UTC

1

Was this article helpful?


Have more questions?

Submit a request

How to change the default index for all websites

Applicable to:

  • Plesk for Linux

Question

How to change or reorder default index files (DirectoryIndex) to index.php for all websites on the server?

Answer

  • For existing domains the following command can be used:

    # MYSQL_PWD=`cat /etc/psa/.psa.shadow` mysql -uadmin psa -sN -e"SELECT name FROM domains WHERE htype='vrt_hst'" | while read i; do plesk bin subscription --update-web-server-settings $i -apache-directory-index "index.php index.html index.cgi index.pl index.xhtml index.htm index.shtml"; done

  • For a new domains create a event handler under Tools & Settings > Event Manager. For example:

    1. Create a script file with the content like below:

      CONFIG_TEXT: #!/bin/bash
      touch /tmp/event_handler.log
      /bin/date >> /tmp/event_handler.log
      /usr/local/psa/bin/subscription --update-web-server-settings "${NEW_DOMAIN_NAME}" -apache-directory-index "index.php index.html index.cgi index.pl index.xhtml index.htm index.shtml"
      echo "${NEW_DOMAIN_NAME} was suceessfuly updated" >> /tmp/event_handler.log

    2. Click Add Event Handler and select Physical hosting created event.

    3. Under Priority, set the handler execution priority by selecting it from the list or typing a custom number in the field.
    4. Select the system user on whose behalf the handler will be executed from the User list (in this case, that would be root user).
    5. Type the path to the shell script from the step 1 (for example, /root/script.sh).
    6. Click OK.

Additional Information

Reference for Command-Line Utilities, Plesk for Linux. subscription: Subscriptions

Administrator's Guide. Event Handlers

Administrator's Guide. Event Handlers. Physical hosting created

Have more questions? Submit a request

2 Comments

  • 0
    Avatar
    Faris Raouf

    This is really helpful. I'd like to make some suggestions please:

    For item 3, users who are not familiar with Event Handler may wonder which priority to use. Maybe it could be suggested that the default priority should be used.

    For item 4, again new users may be confused. I would assume only the root user would have the correct permissions to run the "subscription" command. But if there is a better user to select, maybe you could add an appropriate suggestion?

     

     

  • 0
    Avatar
    Artyom Baranov

    @Faris Hi!

    Thank you for the feedback. 

    > For item 3, users who are not familiar with Event Handler may wonder which priority to use. Maybe it could be suggested that the default priority should be used.

    Its hard to say for sure, how many handlers already exist and recommending to set the default (lowest) priority can lead to incorrect behavior.

    > For item 4, again new users may be confused. I would assume only the root user would have the correct permissions to run the "subscription" command

    I have updated the article according your recommendation. Thanks again :)

Please sign in to leave a comment.