• We value your experience with Plesk during 2024
    Plesk strives to perform even better in 2025. To help us improve further, please answer a few questions about your experience with Plesk Obsidian 2024.
    Please take this short survey:

    https://pt-research.typeform.com/to/AmZvSXkx
  • The Horde webmail has been deprecated. Its complete removal is scheduled for April 2025. For details and recommended actions, see the Feature and Deprecation Plan.
  • We’re working on enhancing the Monitoring feature in Plesk, and we could really use your expertise! If you’re open to sharing your experiences with server and website monitoring or providing feedback, we’d love to have a one-hour online meeting with you.

Auto enable Nginx as default web server

Xavier12

Regular Pleskian
Hey guys,

Hope you're doing excellent. Just wanted to inquire how to automatically enable nginx by default for all domains/subscriptions and or even just as a whole since we do not use apache at all.

Please advise, thank you.
 
Hey there,

Thanks for this! Do you know if there is anyway to enable all in a command?

Also, I was thinking as well, I think this may be easier and work great if event handler is used to automatically enable nginx upon "Default domain created" option with a specific command.

What do you think?
 
Hi Xavier12,

at the moment, there is no "NGINX" - only way, when you use Plesk, but you can always perform a command like "./subscription --update-web-server-settings example.com -nginx-serve-static true -nginx-serve-php true".

Please see all possible commands for this subscription utility in the documentation:


Also, for some reason this isn't working for me and is stating "no such file or directory" when entering in command line (Im using Debian 7 x64)

Please advise, thanks
 
Hi Xavier12,

do you think that there was a reason, why I provided the link to the documentation, Xavier12? ^^ Well, yes... there is one... I wanted to push you into the direction, where you might find your answer. There are really a lot of options and I'm pretty sure, that you will find exactly these strings, which will perform the command to your very own, specific configuration.
You can add more than one domain in this command and the command starts with "./subscription" from the Plesk bin folder. If you are not at this folder, when using the command, you could use "plesk bin subscription ....."

Again, if you would like to use more strings, in order to update settings, please see the documentation for it or use the command "plesk bin subscription --help"
 
Nevermind, figured it out.. it would have to be

/usr/local/psa/bin/subscription --update-web-server-settings example.com -nginx-serve-static true -nginx-serve-php true
 
Hi UFHH01,

Thanks for the response regarding all domains being changed at once.

Now one issue that I am trying to resolve (I may be typing in something wrong) is the event handler..

What I am trying to do is auto enable nginx everytime an action is taken. In this case, I am using domain created for a customer who already has an account..

Based on the documentation here http://download1.parallels.com/Plesk/PP12/12.0/Doc/en-US/online/plesk-administrator-guide/ I am having an issue with plesk executing the variable. Below are my settings:

Event: Domain Created
Priority: Normal
User: root

Command:

/usr/local/psa/bin/subscription --update-web-server-settings [NEW_DOMAIN_NAME] -nginx-serve-static true -nginx-serve-php true

I've tried to replace [NEW_DOMAIN_NAME] with the following:

{new_domain_name}
$new_domain_name
new_domain_name
${new_domain_name}
<new_domain_name>

None seem to have worked yet for some reason in regards to auto enabling nginx for a user that adds a new domain.

Please advise, thanks
 
Last edited:
Hi Xavier12,

the informations from you are incomplete. You are trying to implement this command in a script? Then please provide the script, because it is unclear, where you would like the variable "[NEW_DOMAIN_NAME]" to be replaced from. If you performed previous commands, please provide them as well in order to understand your variable usage.
 
Hey there, thanks for the response.

This is the same command that you provided, which works with the domain that you input:

usr/local/psa/bin/subscription --update-web-server-settings YOURDOMAIN.com -nginx-serve-static true -nginx-serve-php true


What I am trying to do is have Plesk automatically enable nginx when the user creates a domain. The domain that I would like the script to enable Nginx should be the same exact domain that they created.

Scenario:
1. Customer adds a new domain to their account called DOMAIN.COM
2. Event handler initiates the event "domain created", the command script within that event handler takes DOMAIN.com and enables nginx automatically

I am under the impression that "new_domain_name" should be the variable mentioned where new_domain_name is considered as DOMAIN.com . Unless I am using variables incorrectly to execute the overall action that I am looking for.

Does this make sense?
 
Last edited:
Hi Xavier12,

sure does it make sense, but you have to define in your command WHERE you want the variable "NEW_DOMAIN_NAME" should be taken from - the subscription utility doesn't know this by default, because the variable is not used in any parameter definition with this utility.

Please use this documentation to learn how the event handler works:

 
Thanks for the follow-up

I literally followed the first link sent to the T, and the event handler never processed any kind of information. Even tried a simple echo to a document and nothing happened.

Please advise, thanks.
 
Hi Xavier12,

did you read THIS information as well?
Note: We strongly recommend that you use shell script files to handle events. Although you can assign direct system commands, they might not work. For example, commands with output redirection operators < or > will not work.

My test-script, which I ONLY created for investigations to your issue, works as expected.

touch /opt/psa/bin/test_for_Xanier12

vi /opt/psa/bin/test_for_Xanier12
Code:
#!/bin/bash

echo "Start test for event-handler to event_handler.log" >> /tmp/event_handler.log

/bin/date >> /tmp/event_handler.log

/usr/bin/id >> /tmp/event_handler.log

echo "New customer created for testing" >> /tmp/event_handler.log

echo "name: ${NEW_CONTACT_NAME}" >> /tmp/event_handler.log

echo "login: ${NEW_LOGIN_NAME}" >> /tmp/event_handler.log

echo "End test for event-handler to event_handler.log" >> /tmp/event_handler.log
chmod +x /opt/psa/bin/test_for_Xanier12

Added the event-handler as suggested in the documentation!

Added new customer over Plesk Control Panel

Control if the log was created AND with the right content:

tail /tmp/event_handler.log

Start test for event-handler to event_handler.log
Sun Jan 11 12:35:40 CET 2015
uid=0(root) gid=0(root) groups=0(root)
New customer created for testing
name: Test-User Xavier12
login: Test-Xavier12
End test for event-handler to event_handler.log
 
Last edited by a moderator:
Hey there,

I did follow the instruction, only thing is I did not chmod +x the file. Will reach back with results
 
Hi Xavier12,

sure does it make sense, but you have to define in your command WHERE you want the variable "NEW_DOMAIN_NAME" should be taken from - the subscription utility doesn't know this by default, because the variable is not used in any parameter definition with this utility.

Please use this documentation to learn how the event handler works:


As far as this part, I tried the command in the event handler:

domainname="{NEW_DOMAIN_NAME}"

/usr/local/psa/bin/subscription --update-web-server-settings echo "$domainname" -nginx-serve-static true -nginx-serve-php true


Tried to replace {NEW_DOMAIN_NAME} without brackets as well. For some reason this isn't handling the script. Not sure if I am inserting it incorrectly. Please advise, thanks
 
Back
Top