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

January 4, 2017 202 views
Nginx PHP Ubuntu


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 http://www.trendle.io/Signup/signup1 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

3 Answers

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

@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


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:


  • thanks for the info @jtittle

    • @ryanjeff

      No problem!

      If you don't mind the extra dependency and a little reading, libsodium is actually a pleasure to work with. It does take a little time to get used to, given its function set is 3-4x mcrypt, but it's definitely an excellent option.

Have another answer? Share your knowledge.