How to enable and configure the mcrypt in PHP7 using NGINX?


I would like to seek your assistance on how to enable and configure the mcrypt in PHP7 using NGINX. Here’s the scenario: the users will signup in to our application using signup button ofcourse. but once the user register all the profile details its hung with error: POST 500 (Internal Server Error). base in error logs this is mcrypt. in PHP5 using apache is easy to create. but when I tried in PHP 7 using this sudo apt-get install php-mcrypt, sudo phpenmod mcrypt, then restart the nginx service. its the same problem.

Hope someone can help.

Thank you


Submit an answer
You can type!ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!

These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.

I think I know where you’re running into trouble. When using nginx with php-fpm it’s not the nginx process you need to restart when enabling a module, it’s the fpm service so you’ll need to run:

sudo service php-fpm restart


Just a side note, as of and especially with PHP 7, you should consider dropping any reliance on mcrypt and instead use something such as libsodium in its place, or at the very least openssl (if you prefer not to add another dependency to your configuration).

You can read this post for some additional information:

@ryanpq thanks for the info. we already fixed, we have some problem in our databases because our setup is separate server for app and dbs. because I already did that and restart nginx also but doesn’t work apparently we tested the inspect network then it shows the DBs side. thanks anyway