Is there any best way for installing GEOS PHP?

i tried installing geoPHP on windows and linux. Still i am not able to install. can any one give idea?

The farmOS Docker images are built on Debian (Linux), and they include GEOS PHP. You could refer to the Dockerfile to understand how it is being installed in that context, and then see if that works in your context.

It is basically:

  1. apt-get install libgeos-dev
  2. Download and unpack https://github.com/libgeos/php-geos/archive/e77d5a16abbf89a59d947d1fe49381a944762c9d.tar.gz
  3. Run:
./autogen.sh
./configure
make
make install

I know that works on Debian (because our Docker images build successfully). I don’t know if it will work on other flavors of Linux.

will try.

1 Like

geos installed successfully.but, still geos not enabled.

1 Like

I forgot, the instructions above are only to install the extension, but you also need to enable it in PHP just like any other extension. This process might differ depending on your environment.

In the Docker image this is done here: farmOS/docker/Dockerfile at 219e00c8744d38159d217c353245006374379e3a · farmOS/farmOS · GitHub

The Docker image has a special docker-php-ext-enable command.

I think ultimately you just need to add extension=geos to your PHP configuration (php.ini) wherever that is in your environment. But this is the extent of my knowledge, because I always use the Docker image so I haven’t done this in other contexts myself. Please share what worked for you when you figure it out!

finally solved. i was installed php7.4,8.1 and 8.3.i am using php8.1 for apache2 but, when i was run ./autogen.sh cmd it build geos for php8.3. then i understood (help of chatGPT) . After i run phpize8.1 and ./configure --with-config-file-path=/usr/bin/php-config8.1 it will configure geos for php8.1. then i run make && make test && make install cmd. after added extension reference to below file.

apache2/conf.d/geos.ini

extension=geos.so

now it’s enabled. thank you @mstenta .

2 Likes

Perfect! Thanks for sharing the solution @aathi179! I’m sure someone else will find it helpful in the future. :slight_smile:

1 Like