0

I've, somehow, managed to play with LUA on my local machine (Windows). Now I tried to put that on my dev server (Debian 9 with Apache 2.4.25 with PHP 7.0.27-0+deb9u1 and Lua 5.3.3).

After hours, dozens of errors and thousands of StackOverflow's pages read, I have finally been able to manually compile and build PECL lua-2.0.5 and successfully made apache module.

I used $ a2enmod lua. Now, on phpinfo() I see mod_lua along others Loaded Modules.

I can run lua scripts from cli. No problem here.

I can't use lua from PHP scripts:

Fatal error:  Uncaught Error: Class 'Lua' not found in [...]

I can't use lua through Apache as well (through http://domain/path/to.lua), even after editing /etc/apache2/apache2.conf with new lines:

LoadModule lua_module modules/mod_lua.so
<Files "*.lua">
    SetHandler lua-script
</Files>

None of the 4 line made any noticeable difference.

Running Lua scripts directly through Apache (from URL) is optional. But I really need to be able to interpret Lua from my PHP scripts. But even with mod_lua displayed in Loaded Modules in phpinfo(), PHP can't find class Lua. Why?

4
  • maybe you need a php extension also. I found this script look at line 28+ it downloads and builds a php extension github.com/chtombleson/php-lua-install-script/blob/master/… Commented Apr 3, 2018 at 3:41
  • @aloMalbarez that's what I've done with PECL lua-2.0.5 and Lua 5.3.3 from aptitude, but all it did was making apache module. It is seen by PHP in phpinfo(), but still, no Lua class :/ Commented Apr 3, 2018 at 4:00
  • and its listed as extension in the /etc/php/7.0/apache2/php.ini ? or its conf.d own ini? tried to install lua via pecl but found some errors, but I remember that some extensions that use apache mods also needs you to explicity set the php.ini option Commented Apr 3, 2018 at 4:12
  • @aloMalbarez oh, I feel dumb. Yes, you are right. I've added extension=lua.so to main php.ini and it works now. Post an answer if you want Commented Apr 3, 2018 at 12:20

1 Answer 1

1

After building the extension it has to be enabled, some install scriptss do it for you.

depending on your OS the php.ini to do it could vary in mine (ubuntu 16) are

/etc/php/7.0/apache2/php.ini
/etc/php/7.0/CLI/php.ini

if it has multiple config options you can/should make a dedicated extensionname.ini under /etc/php/7.0/{CLI|apache2}/conf.d

shortcut from commandline

$ php -dextension=/path/to/extension.so

or

$ phpenmod extensionname

this one can be found as php5enmod for php5

edit: in your case as you noticed the line to add to the .ini is extension=lua.so

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.