Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Compile Mongodb module statically into PHP to run it on AWS Lambda

I am trying to compile Mongodb module statically into PHP.

I have successfully compiled PHP (without Mongodb module) using the instructions here: https://aws.amazon.com/blogs/compute/scripting-languages-for-aws-lambda-running-php-ruby-and-go/

Then I compile Mongodb driver using the instructions here: http://php.net/manual/en/mongodb.installation.manual.php. The module mongodb.so is generated and stored successfully in the PHP source files.

But in order to re-compile PHP to bundle the Mongodb module, I tried the following instructions http://php.net/manual/en/install.pecl.static.php, but I don't know which flag I need to use to compile PHP with the Mongodb module.

I have tried --with-mongodb, --with-mongo, --enable-mongodb and --enable-mongo but none of those are valid flags.

Could somebody be so kind to help me out with this problem?

Many thanks in advance.

like image 534
Migsy Avatar asked Oct 29 '22 16:10

Migsy


1 Answers

After spend lot of time on this, I finally can compile PHP with mongodb extension statically installed. I realized that the version of extension I was trying was not supported to accomplish this.

RUN git clone https://github.com/mongodb/mongo-php-driver.git mongodb && \
    cd mongodb && \
    git checkout 1.5.3 && git submodule update --init && \
    cd ../ && mv mongodb ext/mongodb

RUN ./buildconf --force

RUN ./configure \
    ...
    --enable-mongodb \
    ...

RUN make -j 5 && make install

When checkout the extension to tag 1.5.3 I could add the ---enable-mongodb flag on the /configure command.

like image 114
Tales Santos Avatar answered Nov 15 '22 06:11

Tales Santos