Failed to modify server : An Nginx virtual host with the same name already exists

After some updates. The modification of nginx stopped working. When creating a website:

Starting PHP FastCGI server …
… Nginx website failed! : virtualmin-nginx::feature_setup failed : virtualmin-nginx::feature_save_web_php_mode failed : No PHP command found! at …/web-lib-funcs.pl line 1433.

Edit Virtual Server:

Failed to modify server : An Nginx virtual host with the same name already exists

Sorry for my english :frowning:

ty, google translate

Screenshots https://imgur.com/a/GvqAH

I have a same error in CentOS6 virtualmin6.

and I find that there is no file in below

/etc/rc.d/init.d

it should be there but no file such as “php-fcgi-example-com”

AND
there is no script such a below in nginx.conf
fastcgi_pass unix:/var/php-nginx/1495xxxxxx5959.sock/socket;

Did you get this error after the update?

I using Debian Linux 8

Maybe YES

YES

Hello, I am experiencing a similar issue on a CentOS 7 + nginx:

Failed to modify server : An Nginx virtual host with the same name already exists

This happens when trying to create a new virtual server. The server is created but the “Enabled features > Nginx Website Enabled” stays deselected, and on attempting to enable it I get the error: “Failed to modify server : An Nginx virtual host with the same name already exists”

The “Webalizer reporting enabled?” feature presents the same issue (remains deselected and cannot be enabled).

Then on deleting the virtual host, its server block does not get removed from /etc/nginx/nginx.conf. And incidentally, this file seems to include all of the virtual hosts as opposite to having a separate nginx conf file for each separate host. I would suggest escalating this issue to critical as far as CentOS 7 + nginx support.

I think the cause of this error is maybe ”wbm-virtualmin-nginx 2.3-1"

“And incidentally, this file seems to include all of the virtual hosts as opposite to having a separate nginx conf file for each separate host.”

This is how CentOS virtual hosts are done, for both Apache and nginx. It is done as individual files on Debian/Ubuntu and a single file on CentOS. It’s configurable for Apache, I’m not sure about for nginx (but I would assume it is). This behavior is not a bug, it is working as intended. We trust you to choose the OS that works the way you want (CentOS puts vhosts in the main configuration file, by default).

Edit: Yeah, this is configurable. Go to Features and Plugins->Nginx Website and the set a directory where you want your vhost files to go in the option labeled File or directory for new virtual hosts.

"Then on deleting the virtual host, its server block does not get removed from /etc/nginx/nginx.conf. "

Sounds like a bug. Bugs can always be reported in the issue tracker (whether for GPL or Pro), and Jamie will be able to sort it out if it is reproducible. I’m running a test install on CentOS 7 right now to see if I can reproduce the problem.

Edit: I didn’t see this behavior on my test system. Did you perform a --minimal installation? If so, if you didn’t disable Webalizer and AWStats before creating/deleting any virtual servers, it probably leads to botched configs. That’s either fixed in the current virtualmin-config package or will be in the next, I don’t remember when I checked in the changes.

I’d really recommend you use a new distribution if you are using new features. nginx and the LEMP installation bundle are extremely new and rely on a bunch of new stuff. It should work in old distros, but we have to focus our testing on newer distributions. If you want to use an old distribution, use the old tried and true Apache installation target.

I’ll work on making sure the LEMP (nginx) installation works well as best I can, but I have to focus on new distributions first and foremost.

So, use a new distro (CentOS 7, Debian 9, or Ubuntu 16.04), and report bugs. We’ll get them fixed as fast as we can.

OK, in my testing on CentOS 7, it looks like the only thing that is failing is that nginx isn’t restarting when Webmin tells it to restart. Restarting it manually allows the new virtual host (server block) to show up, and I’m able to browse the newly created domain. But, I didn’t get any of the errors y’all have mentioned, so you’re seeing something other than merely nginx failing to restart.

I’m gonna figure out why nginx isn’t restarting, and we’ll get that sorted in Virtualmin.

But…all this other stuff, I can’t reproduce so far. So, I need more specifics about what you’ve changed from the defaults, or whether it was installed with any flags other than --bundle LEMP. Was it a --minimal installation? There were some bugs with Webalizer and AWStats being enabled even though they don’t get installed, so you have to make sure you’ve got the Webalizer feature and AWstats plugin disabled before doing anything with virtual servers (re-check configuration will warn you about this, but it won’t stop you from trying to create virtual hosts anyway and getting botched configuration probably).

Hi Joe, thank you so much for taking the time to answer.

The main issue I am experiencing is that after creating a new virtual host, the option “Nginx website enabled?” appears deselected and when trying to enable it the error “Failed to modify server : An Nginx virtual host with the same name already exists” is thrown. I tried manually restarting nginx to no avail.

The CentOS 7 server has a default install of Virtualmin from the install script and there are already 3 other virtual servers that were created successfully earlier, so this issue might be a recently introduced one.

The “Webalizer reporting enabled?” option being deselected is probably a consequence of the disabled “Nginx website enabled?”. By the way with nginx I found that the stats folder needs to be manually protected with “auth_basic” directive in the nginx conf file but other than that Webalizer seemed to be working fine with nginx for the previously created virtual servers.

AFTER update to wbm-virtualmin-nginx 2.4-1

I cannot create virtualserver correctly, show you my getting logs.

—logs—

Creating administration group iriey …
… done
Creating administration user iriey …
… done

Creating aliases for administration user …
… done

Adding administration user to groups …
… done

Creating home directory …
… done

Creating mailbox for administration user …
… done

Adding new DNS zone …
… done

Adding to email domains list …
… done

Adding default mail aliases …
… done

Adding DKIM records to DNS domain iriey.com
… added successfully

Creating Nginx virtual host …
… done

Starting PHP FastCGI server …
… Nginx website failed! : virtualmin-nginx::feature_setup failed : virtualmin-nginx::feature_save_web_php_mode failed : No PHP command found! at …/web-lib-funcs.pl line 1433.

Setting up scheduled Webalizer reporting …
… no logging directive found in webserver configuration!

Setting up log file rotation …
… no logging directive found in webserver configuration!

Creating MySQL login …
… done

Creating MySQL database iriey …
… done

Setting up spam filtering …
… done

Setting up virus filtering …
… done

Creating SSL certificate and private key …
… done

Adding SSL to Nginx virtual host …
… done

Creating Webmin user …
… done

Re-starting DNS server …
… done

Applying Nginx configuration …
… done

Re-starting Webmin …
… done

Re-starting Usermin …
… done

Re-loading Webmin …
… done

Saving server details …
… done

—/logs—

I had installed just like below.

https://www.virtualmin.com/documentation/web/nginx

I can restart nginx, not failing to restart nginx.

if it is “wbm-virtualmin-nginx 2.2-1” in CentOS6.9.

I have a “no” error to create virtualserver.

—logs—

Starting PHP FastCGI server …
… done

—/logs—

I’m running Webmin/Virtualmin on Debian 8.9.
After updated different packages, I also got error during the creation of virtualserver.

Starting PHP FastCGI server … … Nginx website failed! : virtualmin-nginx::feature_setup failed : virtualmin-nginx::feature_save_web_php_mode failed : No PHP command found! at …/web-lib-funcs.pl line 1433.

The creation was incomplete!
If I deleted the virtualserver, the Nginx’s virtualhost was not deleted. I need to manually delete the virtualhost in Nginx before I can re-create it again!

Thanks to @irieyuusuke, After I downgraded “webmin-virtualmin-nginx” to 2.2 then I had no problem in creating the virtualserver now!

@wyoungca, how are you rolled back?

@alabamaster1337

apt-get install webmin-virtualmin-nginx=2.2

@alabamaster1337

apt-get install webmin-virtualmin-nginx=2.2