Posted on

One day, my website was replaced by a OpenRestry installed page. I did nothing, but it just happened.

I checked the nginx log and it showed the following.

2020/06/15 08:57:15 [error] 5653#5653: lua_load_resty_core failed to load the resty.core module from https://github.com/openresty/lua-resty-core; ensure you are using an OpenResty release from https://openresty.org/en/download.html (rc: 2, reason: module 'resty.core' not found:
        no field package.preload['resty.core']
        no file '../lua-resty-core/lib/resty/core.lua'
        no file '../lua-resty-lrucache/lib/resty/core.lua'
        no file './resty/core.lua'
        no file '/usr/share/luajit-2.0.4/resty/core.lua'
        no file '/usr/local/share/lua/5.1/resty/core.lua'
        no file '/usr/local/share/lua/5.1/resty/core/init.lua'
        no file '/usr/share/lua/5.1/resty/core.lua'
        no file '/usr/share/lua/5.1/resty/core/init.lua'
        no file './resty/core.so'
        no file '/usr/local/lib/lua/5.1/resty/core.so'
        no file '/usr/lib/x86_64-linux-gnu/lua/5.1/resty/core.so'
        no file '/usr/local/lib/lua/5.1/loadall.so'
        no file './resty.so'
        no file '/usr/local/lib/lua/5.1/resty.so'
        no file '/usr/lib/x86_64-linux-gnu/lua/5.1/resty.so'
        no file '/usr/local/lib/lua/5.1/loadall.so')

After 10 mins, I found the solution on Github, which is to add the following line in the http section of /etc/nginx/nginx.conf to disable the abnormal dependency.

lua_load_resty_core off;

After that, it is still not possible to start the server on port 80 since there’s still some service running on port 80. To kill that process, firstly see what that process is.

echo kill $(sudo netstat -anp | awk '/ LISTEN / {if($4 ~ ":80$") { gsub("/.*","",$7); print $7; exit } }')

Then actually kill it.

kill $(sudo netstat -anp | awk '/ LISTEN / {if($4 ~ ":80$") { gsub("/.*","",$7); print $7; exit } }')

After that, we can safely restart the nginx service and our website is normal again.

service nginx restart

References

  1. https://github.com/openresty/lua-nginx-module/issues/1509#issuecomment-486122328
  2. https://unix.stackexchange.com/questions/244531/kill-process-running-on-port-80#:~:text=There%20are%20several%20ways%20to,associated%20with%20the%20listening%20port.&text=After%20finding%20out%2C%20you%20can,kill%20the%20process(es).&text=Replace%20echo%20by%20sudo%20for%20the%20process%20to%20actually%20be%20killed.

Leave a Reply

Your email address will not be published. Required fields are marked *