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

I tried installing GEOS php using the instructions above on Amazon Linux 2023, but got stuck here… any ideas?


checking for gawk… gawk
checking whether to enable geos support… yes, shared
checking for geos-config… yes, shared
checking for geos-config… no
configure: error: Cannot find geos_c.h. Please specify correct GEOS installation path

Looks like the path is inherited from some place that I can’t find.

1 Like

As an aside, geos_c.h is installed here:

[root@ip-10-0-0-28 include]# pwd
/usr/local/geos/include
[root@ip-10-0-0-28 include]# ls -lrt
total 204
-rw-r–r–. 1 root root 1125 Jun 5 20:35 geos.h
-rw-r–r–. 1 root root 185848 Jul 11 03:11 geos_c.h
drwxr-xr-x. 20 root root 16384 Jul 11 04:14 geos
[root@ip-10-0-0-28 include]#

@lmcmullen hi, can you share what are the steps you were followed? Please share more details.

Hi @aathi179 thanks for following up. Here’s an update on where I stand today…

# run as ec2-user
cd ~
mkdir -p geos-3.12.2-build
cd geos-3.12.2-build/
curl -o geos-3.12.2.tar.bz2 https://download.osgeo.org/geos/geos-3.12.2.tar.bz2
bunzip2 geos-3.12.2.tar.bz2
tar -xvf geos-3.12.2.tar
cd geos-3.12.2/
sudo yum install cmake
sudo yum install gcc
sudo ./configure --prefix /usr/local/geos
sudo make
sudo make install

# run as ec2-user
cd ~
sudo yum install libgeos-dev  #failed no match found
wget https://github.com/libgeos/php-geos/archive/e77d5a16abbf89a59d947d1fe49381a944762c9d.tar.gz
gunzip e77d5a16abbf89a59d947d1fe49381a944762c9d.tar.gz
tar -xvf e77d5a16abbf89a59d947d1fe49381a944762c9d.tar
cd php-geos-e77d5a16abbf89a59d947d1fe49381a944762c9d/
sudo ./autogen.sh
sudo ./configure
sudo make
[ec2-user@ip-10-0-0-28 php-geos-e77d5a16abbf89a59d947d1fe49381a944762c9d]$ sudo make install
Installing shared extensions:     /usr/lib64/php8.3/modules/
[ec2-user@ip-10-0-0-28 php-geos-e77d5a16abbf89a59d947d1fe49381a944762c9d]$

cd /etc
sudo cp php.ini php.ini.bak
sudo vi php.ini
# add extension=geos.so at the bottom

cd /var/www/html/farmOS/vendor/bin/

[ec2-user@ip-10-0-0-28 bin]$ sudo ./drush cr
PHP Warning:  PHP Startup: Unable to load dynamic library 'geos.so' (tried: /usr/lib64/php8.3/modules/geos.so (libgeos_c.so.1: cannot open shared object file: No such file or directory), /usr/lib64/php8.3/modules/geos.so.so (/usr/lib64/php8.3/modules/geos.so.so: cannot open shared object file: No such file or directory)) in Unknown on line 0
 [notice] Reverted config: core.entity_view_display.asset.animal.map_popup
 [notice] Reverted config: core.entity_view_display.asset.equipment.map_popup
 [notice] Reverted config: core.entity_view_display.asset.land.map_popup
 [notice] Reverted config: core.entity_view_display.asset.plant.map_popup
 [notice] Reverted config: core.entity_view_display.asset.structure.map_popup
 [notice] Reverted config: core.entity_view_mode.asset.map_popup
 [notice] Reverted config: core.entity_view_mode.quantity.plain_text
 [notice] Reverted config: log.type.activity
 [notice] Reverted config: log.type.harvest
 [notice] Reverted config: log.type.input
 [notice] Reverted config: log.type.maintenance
 [notice] Reverted config: log.type.observation
 [notice] Reverted config: log.type.seeding
 [notice] Reverted config: migrate_plus.migration_group.farm_import_csv
 [notice] Reverted config: system.action.asset_assign_action
 [notice] Reverted config: system.action.asset_parent_action
 [notice] Reverted config: user.role.farm_account_admin
 [notice] Reverted config: views.view.farm_asset
 [notice] Reverted config: views.view.farm_asset_geojson
 [notice] Reverted config: views.view.farm_import_csv_asset
 [notice] Reverted config: views.view.farm_import_csv_log
 [notice] Reverted config: views.view.farm_import_csv_taxonomy_term
 [notice] Reverted config: views.view.farm_inventory
 [notice] Reverted config: views.view.farm_log
 [notice] Reverted config: views.view.farm_people
 [notice] Reverted config: views.view.farm_quantity
 [notice] Reverted config: views.view.log_admin
 [success] Cache rebuild complete.
[ec2-user@ip-10-0-0-28 bin]$

# But it's there...

[ec2-user@ip-10-0-0-28 bin]$ ls -lrt /usr/lib64/php8.3/modules/geos.so
-rwxr-xr-x. 1 root root 285808 Jul 14 16:24 /usr/lib64/php8.3/modules/geos.so
[ec2-user@ip-10-0-0-28 bin]$

@lmcmullen Have you tried searching outside of the farmOS forum for solutions to this? This is not a farmOS issue specifically so you might have more luck elsewhere, but please do share the solution here if you find one!

This has a few suggestions:

My gut tells me this is related to there not being a libgeos-dev package for Amazon Linux 2023. I just don’t think dependent libs are installed or available for the version of linux I’m running. As an aside, I spent most of the weekend installing FarmOS on different versions of Linux. I’ll keep plugging away and will publish my findings after.

If it helps at all, the official Docker images are based on Debian. You can see the exact commands used to install GEOS PHP here:

And it gets enabled here (although this technique is specific to the Docker image):

1 Like