2

I have Ubuntu 15.10 installed. I have also installed LAMP using the Ubuntu wiki help page. I then proceeded to set up Moodle via the web page installation. I hit a road block when I got

Moodle requires the json PHP extension. 
Please install or enable the json extension.

With the link above, I have tried installing, whilst LAMP was still installed, only PHP5 (libapache2-mod-php5) -- and of course restarting the apache2 service. The problem is in the the /etc/php5/mods-available folder, no json.ini file appears. When I type in terminal sudo php5 -m, json is not a module running. However if I attempt to remove PHP5, it shows before I confirm the removal that the package php5-json will go.

The question I have is how do I get the json extension if I don't have it already, or if I do have it (and it's placed somewhere else) how do I enable it?

EDIT: output of apt-cache policy php5-json

php5-json:
  Installed: 1.3.7-1
  Candidate: 1.3.7-1
  Version table:
 *** 1.3.7-1 0
        500 http://nz.archive.ubuntu.com/ubuntu/ wily/main amd64 Packages
        100 /var/lib/dpkg/status

Tried sudo apt-get install --reinstall php5-json but still missing file.

Zanna
  • 69,223
  • 56
  • 216
  • 327
Stevie
  • 21
  • 1
  • 1
  • 4
  • 1
    Please [edit] your post and add the output of `apt-cache policy php5-json`. Try reinstalling that package: `apt-get install --reinstall php5-json` – muru Dec 06 '15 at 21:55
  • Have included the detail you requested. – Stevie Dec 06 '15 at 22:39
  • Does php -m or php -i list json? – Progrock Dec 06 '15 at 22:55
  • Neither php -m or php -i list json. – Stevie Dec 06 '15 at 23:02
  • 1
    Try $ sudo php5enmod json , however I would expect something in mods-available. – Progrock Dec 06 '15 at 23:03
  • dpkg-query -L php5-json , to show files. Perhaps copy /usr/share/php5/json/json.ini to /etc/php5/mods-available if you can. (Debian reference here for php5-curl.) – Progrock Dec 06 '15 at 23:20
  • Used the query command and got the following: `/. /etc /etc/php5 /etc/php5/mods-available /etc/php5/mods-available/json.ini /usr /usr/lib /usr/lib/php5 /usr/lib/php5/20131226 /usr/lib/php5/20131226/json.so /usr/lib/php5/json /usr/include /usr/include/php5 /usr/include/php5/ext /usr/include/php5/ext/json /usr/include/php5/ext/json/php_json.h /usr/share /usr/share/doc /usr/share/doc/php5-json /usr/share/doc/php5-json/copyright /usr/share/doc/php5-json/changelog.Debian.gz` – Stevie Dec 06 '15 at 23:24
  • @Progrock @muru I managed to get the extension working by adding `extension=json.so` to `php.ini` – Stevie Dec 07 '15 at 05:58
  • So when you installed the extension there was no /etc/php5/mods-available/json.ini? – Progrock Dec 07 '15 at 18:54
  • Yes, that is correct. – Stevie Dec 07 '15 at 19:38

1 Answers1

5
  1. Open the file /etc/php5/apach2/php.ini

  2. Add this line to the end of the file.

    extension=json.so
    
  3. restart apache2

    sudo service apache2 restart
    
Zanna
  • 69,223
  • 56
  • 216
  • 327
sirajalam049
  • 378
  • 3
  • 21