Plugin not working on new nginx server

Recently I shifted one of my websites from apache based server to nginx and a plugin I coded (BMI calculator) stopped working on it.

wordpress plugin not working after server changeI thought it might be due to wordpress upgrade which happened almost the same day too. As WP is fond of deprecating old stuff, I thought it might have caused the plugin to fail.

Anyway, I launched the plugin on my localhost (apache based, xampp on mac os x) and it worked fine! confusing right?

Well the next thing I did, I uploaded the plugin to one of my clean installation on the nginx server and it didn’t work there too! So definitely the issue was with the plugin code itself not the website or any other plugin conflicting with the code (not WordPress update issue too).

What did the plugin do?

Well the plugin was a simple code I coded (and will be launching soon) for a widget to show a BMI calculator to the sidebar at https://offlineclinic.com/

How did I attempt the fix?

I tested plugin on my apache based localhost: working fine

I tested on clean WordPress 4.0.1 install on the same nginx server: Not working

I sliced the code and tested in bits and found a very funny thing (my bad, should have known! anyway now I know!) that the issue was with the code.

Now the issue wasn’t with the code or hooks or functions, but the opening tag for php. I was using <? only and not <?php

Apache I’m using probably had short open tag open by default so it didn’t gave the issue. Nginx however, seems to be a concise server and thus didn’t have this turned on.

Solution:

To solve the issue of wordpress plugin not working on server change from apache to nginx or any other, make sure that the opening and closing tags for php are standard <?php one.

hire best wordpress php css developer
Need Help? Hire me now!
I can help you in anything related to webdevelopment, including: HTML, CSS, PHP & MySql, WordPress (plugins & themes development, others), regular expressions, server management, etc.

Leave a Reply

Your email address will not be published.