LNMP 1.2 Causes WordPress Frontend to Fail to Open

Publish: 2015-10-30 | Modify: 2017-06-21

Recently, I switched from AMH4.2 to Junge's LNMP 1.2 one-click package. The data transfer was successful, but a problem occurred. The WordPress front-end showed a 502 bad gateway error. I followed the official instructions to adjust the php.ini and php-fpm configurations, but the front-end was still slow and sometimes couldn't load, displaying a blank page. I wonder if anyone has encountered a similar situation.

However, it's strange that I can still log in to the WordPress back-end without any issues. So, I suspected that the problem might be with the plugins. I deactivated all the plugins, but the front-end still couldn't load. It could also be a theme issue, so I switched to the official default theme, but the problem persisted. The homepage still couldn't load and timed out.

It's really frustrating. I checked the website logs, nginx logs, and php-fpm logs, but found no clues. There were no error reports, so I ruled out plugin and theme problems. Finally, I found out that a ".user.ini" file was causing the issue. When creating a website using LNMP 1.2, there is a hidden ".user.ini" configuration file in the site's root directory, which cannot be directly modified or deleted.

In LNMP 1.1 and earlier versions, the "open_basedir" setting was used in the php.ini file, while in LNMP 1.2 and later versions, the anti-cross-directory feature uses ".user.ini". This file is located in the website's root directory and can be modified to set the restrictions on directory access.

The solution is to first execute the command: "chattr -i /website_directory/.user.ini". Then, completely delete the contents of ".user.ini" and save it. After that, execute the command: "chattr +i /website_directory/.user.ini". Finally, restart the LNMP-related services using the command: "lnmp restart".

After following these steps, the problem was resolved and the front-end loading returned to normal. For those who encounter similar issues, you can refer to this solution. I couldn't find a solution online and spent several hours troubleshooting before figuring it out.


Comments