Fixing WordPress Theme Display and Editing Issues in LNMP 1.2 Environment

LNMP environmentWordPress theme editorscandir functionphp.ini configurationWordPress troubleshooting
Published·Modified·

After switching the website environment from AHM 4.2 to Junge's LNMP 1.2 one-click package, various issues arose. While most were resolved through online documentation, one persistent problem was that the WordPress theme options only displayed the currently active theme, preventing the display of other themes and blocking online code editing and saving.

Research indicates that the LNMP environment disables the scandir function by default. To fix this, you need to edit the /usr/local/php/etc/php.ini configuration file and enable the scandir function.

scandir

Remove the scandir function from the configuration (as shown in the screenshot above), save the php.ini file, and then restart the LNMP services by running the following command (applicable for LNMP 1.2):

lnmp restart

After restarting, check the WordPress backend; all themes should now display correctly, and online code editing should work.

Alternatively, you can execute the following command to remove the restriction and then restart PHP-FPM:

sed -i 's/,scandir//g' /usr/local/php/etc/php.ini
/etc/init.d/php-fpm restart

Additionally, you might encounter issues such as SMTP emails failing via Socket connection or the WordPress Akismet plugin not working. These problems are often caused by the pfsockopen and fsockopen functions being disabled. To resolve this, execute the following three commands in sequence:

sed -i 's/,fsockopen//g' /usr/local/php/etc/php.ini
sed -i 's/,pfsockopen//g' /usr/local/php/etc/php.ini
/etc/init.d/php-fpm restart