Today i found a weird issue when trying to activate a WordPress plugin. I always redirected to 404 Error Page (Not Found). This is the first time i met this error. In most case it is crash problem or PHP Fatal error, which is easily to fix. I tried to debug the Apache error log, Nginx error log and MySQL log. There were no error related to the issue.
After doing debug for hours, i finally found the issue. It was a very slow query which is lead to exceed PHP max execution time. There are 3 queries to the database which is alter the wp_posts that take more than 100 seconds to finished. I found this when i activated mysql slow query log. So to fix the issue, i comment that 3 lines and manually update the database table from PHPMyAdmin. Then i try to activate the plugins.
Now the plugin work perfectly. So if you having the similar issue, please check that plugin’s code at wp_activation_hook function. And find if there is a code or database query that will take forever to finished. Hope my experience could help you all.