How do I install/use the phpize command? - php

I am intending to use SQLite 3 with PHP 5. I found this: http://packages.debian.org/etch/web/php5-sqlite3 but I am having problems with installation:
unzip & untar the package
run "phpize"
run "./configure --with-sqlite3=/path/to/your/sqlite3/install
make && make install
(optionally) copy DB/sqlite3.php to /path/to/php/lib/php/DB/sqlite3.php
I understand that phpize is a command used in cmd. But in which folder should I run this command? It seems that I don't have this command installed yet. How do I install this? I'm on Windows, and is using Wampserver for PHP.
Thanks!

The instructions you've got don't typically make sense for Windows, unless you're running GNU Make.
You ought to have a look at this:
http://us2.php.net/manual/en/sqlite3.installation.php

Related

How to build a php extensions from tgz file using make?

Background
I use a RedHat machine without root access, no access to the yum packet manager and no Docker support. This is the policy unfortunately at my work.
I have configured Apache and PHP using a tar file in a folder. Also done same for MongoDB, now I try to configure the PHP drivers for MongoDB according to these instructions:
https://docs.mongodb.com/drivers/php/
However I get stuck on the first bullet:
sudo pecl install mongodb
Problem
Do I need PECL? Can the extension be downloaded manually, and added to PHP?
I have tried to download the mongodb extension manually from:
https://pecl.php.net/package/mongodb
How to compile it mongodb.so? I tried to run pecl on a machine where I have root access then I saw it downloaded the mongodb-1.10.0.tgz and run make (in output when installing).
When I unpack the tgz file manually, I am not able to run make. How to use the makefile.frag? How to run make?
Here is a link on how to build mongodb.so:
https://www.php.net/manual/en/mongodb.installation.manual.php
git clone https://github.com/mongodb/mongo-php-driver.git
cd mongo-php-driver
git submodule update --init
phpize
./configure
make all
sudo make install
You can also unpack the mongodb-1.10.0.tgz file with:
tar -xvf mongodb-1.10.0.tgz
phpize
make all
sudo make install

Where is php7 bin? PHP

I'm trying to install a PHP Extension on my Linux Server however the installation process is confusing.
They provide this instructions.
git clone https://github.com/longxinH/xhprof.git ./xhprof
cd xhprof/extension/
/path/to/php7/bin/phpize
./configure --with-php-config=/path/to/php7/bin/php-config
make && sudo make install
I done git clone on PHP Extensions Folder
The thing that confuse me is
/path/to/php7/bin/phpize
Where is php7 bin?
The closest thing i found is /usr/bin/php
but its an executable file.
Inside this directory
/usr/bin/
I have php , php7.4, php-config, phpconfig7.4

Can I use composer without installing it?

I've noticed on a lot of open source user systems, like UserFrosting or Drupal they some how use composer, without the user actually having to install composer on to there server. I was just wondering how would I be able to do this, I've had a look around and can't find anyway of just using the files.
Thank you.
Yes, you could simply download the composer.phar file, and run it from CLI like:
cd ~/
wget https://getcomposer.org/composer.phar
php composer.phar [command]
You'll need at least PHP v5.6.x and the mcrypt extension installed for the CLI SAPI.

phpize reports "Cannot find config.m4"

I am trying to run the 'phpize' command on MacOSx Mountain Lion, but this is what I get:
Cannot find config.m4.
Make sure that you run '/opt/local/bin/phpize' in the top level source directory of the module
How do I resolve this error ?
The phpize command is meant to be run at the top level of an extension source dir (this source dir should contain a file name config.m4).
See http://php.net/manual/en/install.pecl.phpize.php for more information.
In plain English, it means you're running the command from the wrong directory. You need to be in the directory that contains the source for the extension you're trying to install.
For example, if you're trying to install mcrypt, like I was when I came across this stack overflow page, you need to be in php-5.6.24/ext/mcrypt and then run the command.
My problem was that I was trying to execute the command just to see if I had it installed.
Trying to execute the command alone gives you that error, only use it inside the directory (most likely you downloaded) that contains the extension that you're trying to install.
Here some instructions to install Xdebug for php7.2 for example.
Take special care in step 3 and 4, first you change dir to the unpacked downloaded extension and then you run phpize.
http://qiita.com/MasatoYoshioka#github/items/e542f39a6f1a3bc1f71e
In terminal
ls config.m4
ls config*
config.w32 config0.m4
cp config0.m4 config.m4
cd /usr/local/src/php-5.3.29/ext/zlib
phpize
./configure
make clean && make && make install
nano php.ini
add extension=zlib.so
got inside the xdebug folder than try to run the phpize
Sometimes, using the pecl installer is not an option. This could be because you're behind a firewall, or it could be because the extension you want to install is not available as a PECL compatible package, such as unreleased extensions from git. If you need to build such an extension, you can use the lower-level build tools to perform the build manually.
The phpize command is used to prepare the build environment for a PHP extension. In the following sample, the sources for an extension are in a directory named extname:
$ cd extname
$ phpize
$ ./configure
$ make
# make install
first run ./configure it will create config.m4 file, rest the steps are same

How do I install Pdftk on my server?

I am using a Linux Server and am trying to install Pdftk, but I am problems trying to figure out what exactly to do.
I found the following documentation on how to install it, but they refer mostly to installing it on the local Windows machine.
They are:
http://www.andrewheiss.com/blog/2009/07/29/installing-pdftk-php/
http://www.accesspdf.com/pdftk/#packages
Can someone help me unserstand exactly what files I need to place where on my server so I can refer to pdftk?
Pdftk is a version of iText which has been converted from Java to c++ and rebuilt with a command-line bridge for easy access from PHP applications.
To build pdftk on Redhat / CentOS please follow the below instructions.
ssh [server to install pdftk on]
Now that we are in the server we need to create the directories to store pdftk.
cd /
sudo mkdir extra
cd extra
sudo mkdir src
cd src
sudo wget http://www.pdfhacks.com/pdftk/pdftk-1.41.tar.gz
sudo tar zxvf pdftk-1.41.tar.gz
cd pdftk-1.41/pdftk
Now we need to install the gcj libraries.
sudo yum install java-1.4.2-gcj-compat-devel.i386
The gcc-c++ library doesn't get installed with the gcj package so we will install it now, so we don't get an error halfway through the compile process.
sudo yum install gcc-c++
If you compile the application right now you will receive a warning that tmpnam is dangerous to use and you should use mkstemp.
sudo vi report.cc
Run this from inside VI to do a search and replace for the tmpnam method.
:%s/tmpnam(/mkstemp(/g
Press escape and save the changes with
:wq!
Now that we have all the packages installed, we are going to start compiling pdftk-1.41
from /extra/src/pdftk-1.41/pdftk run the following command
sudo make -f Makefile.RedHat
This will kick off the build process for compiling and converting the java file to c++. This could take SEVERAL minutes to convert iText to c++. Go grab yourself a margarita from our new margarita machine in the break room :).
Now with the pdftk file created we will want to copy it to the /bin directory so that we can run it from anywhere.
sudo cp pdftk /usr/local/bin
Let's make sure the build was successful and run
pdftk --version
As of 2020, things are different now. CentOS 6 is stepping out and pdftk can only support CentOS 5/6. GCJ on CentOS 7 is removed, so installing from source is not easy too. But we have docker now:
FROM centos:centos6
RUN yum install -y https://www.pdflabs.com/tools/pdftk-the-pdf-toolkit/pdftk-2.02-1.el6.x86_64.rpm
Then build with docker build . -t pdftk and run as:
docker run -it --rm -v $PWD:/data --workdir /data pdftk pdftk ./input.pdf output ./output.pdf
The example above can repair a pdf file missing a dozen of KB of data if you are lucky.
As mentioned by #rsc, pdftk-java will be available for Rocky Linux, but currently (2021.10.28), still cannot install it via yum.
Fortunately, there is a built command for x86_64 GNU/Linux systems, which does not require any runtime dependencies. So we can use it as follows
# the version number might be updated, check https://gitlab.com/pdftk-java/pdftk
wget https://gitlab.com/pdftk-java/pdftk/-/jobs/1527259632/artifacts/raw/build/native-image/pdftk
chmod +x pdftk
./pdftk ...
It works well in the server with the following system info,
$ lsb_release -a
LSB Version: :core-4.1-amd64:core-4.1-noarch
Distributor ID: Rocky
Description: Rocky Linux release 8.4 (Green Obsidian)
Release: 8.4
Codename: GreenObsidian
As of 2021, there is pdftk-java: A port of the original GCJ-based PDFtk to Java, which is currently on the way to the repositories for Fedora 33+ and EPEL 7+ (latter for CentOS, RHEL or Rocky), allowing yum install pdftk-java to succeed (once the package reached the stable repositories).
Edit: The pdftk-java package is in the stable repositories since yesterday, 2021-10-29.

Categories