Where is php7 bin? PHP - 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

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

Trying to upgrade SQLite on Amazon EC2

I need SQLite minimum version 3.8 to support a MediaWiki install on Amazon EC2. Amazon Linux is based on CentOS and the latest version available in the yum repository is SQLite 3.7.17.
The downloads available from sqlite.org don't include 64-bit Linux. There is a GitHub repository that has a prebuilt 64-bit version, however it's only the command line version. I put it at /usr/bin:
$ which sqlite3
/usr/bin/sqlite3
$ sqlite3 --version
sqlite3: /lib64/libtinfo.so.5: no version information available (required by sqlite3)
3.26.0 2018-12-01 12:34:55 bf8c1b2b7a5960c282e543b9c293686dccff272512d08865f4600fb58238b4f9
But MediaWiki still complains I have SQLite 3.7.17 installed. When I test it I get:
$ cat x.php
<?php
print_r(SQLite3::version());
?>
Run it:
$ php7 x.php
Array
(
[versionString] => 3.7.17
[versionNumber] => 3007017
)
I am guessing this is because of these libraries:
$ sudo find / -name "libsqlite*"
/usr/lib64/libsqlite3.so.0
/usr/lib64/libsqlite3.so.0.8.6
How can I download/rebuild or otherwise install a later version of these SQLite libraries?
The easiest option I found was to build it myself. Tested on Amazon Linux release 2 (Karoo).
Download the latest source code with the configure script from here. Currently this is:
curl https://www.sqlite.org/2020/sqlite-autoconf-3320300.tar.gz | tar xzf -
Go into the created directory and create the Makefile with our system dependant options:
cd ./sqlite-autoconf-3320300 && ./configure
Build the binary
make
Install it
sudo make install
Clean up
cd .. && rm -r ./sqlite-autoconf-3320300
Note: It's far from ideal to do this without a proper RPM package. If you update sqlite through yum, you will overwrite you manually built version.
Adding on to #halbgut answer, with some changes:
Download the latest source code with the configure script from here. Currently this is:
curl https://www.sqlite.org/2020/sqlite-autoconf-3320300.tar.gz | tar xzf -
Go into the created directory and create the Makefile with our system dependent options:
cd ./sqlite-autoconf-3320300 && ./configure
Build the binary
make
Install it
sudo make install
Now, you have created the sqlite3 file. You need to replace them everywhere you find the file sqlite3.
To find all these places - run the following command:
whereis sqlite3
sqlite3: /usr/bin/sqlite3 /usr/local/bin/sqlite3 /usr/include/sqlite3.h /opt/c9/bin/sqlite3 /usr/share/man/man1/sqlite3.1.gz
Now within the sqlite source folder ./sqlite-autoconf-3320300, find the sqlite3, sqlite3.h files and replace with the following cp command
sudo cp sqlite-autoconf-3320300/sqlite3 /usr/local/bin/sqlite3
sudo cp sqlite-autoconf-3320300/sqlite3 /usr/local/bin/sqlite3
sudo cp sqlite-autoconf-3320300/sqlite3 /opt/c9/bin/sqlite3 {I am using c9, hence this file, figure out what file is in the opt/ dir)
sudo cp sqlite-autoconf-3320300/sqlite3.h /usr/include/sqlite3.h
Once done, you would have upgraded both env and python-env. Now you need to just define the path to it. For it, use the local/lib in usr.
export LD_LIBRARY_PATH="/usr/local/lib"
Now you should have this :
$ python -c "import sqlite3; print(sqlite3.sqlite_version)"
3.23.3
$ sqlite3 --version
3.32.3
If you just need the sqlite3 binary, the SQLite amalgamation also works perfectly on Amazon Linux 2. For SQLite 33.9.04 (or others from the SQLite Download section):
wget "https://www.sqlite.org/2022/sqlite-amalgamation-3390400.zip"
unzip "sqlite-amalgamation-3390400.zip"
cd "sqlite-amalgamation-3390400"
gcc shell.c sqlite3.c -lpthread -ldl -lm -o sqlite3
And then use it as you would any other software compiled from source:
ln -n ./sqlite3 ${wherever}/sqlite3
export PATH="${wherever}:$PATH"
SQLite docs give a good explanation of further options if you need them.
Get the latest sqlite3 download link from https://www.sqlite.org/download.html
and update the link given in the WGET bash command example shown below.
Example:
wget https://www.sqlite.org/2022/sqlite-tools-linux-x86-3400000.zip
unzip sqlite-tools*.zip
cd sqlite-tools*
sudo cp sql* /usr/local/bin/ # Usually this directory is empty, so no need to worry about overwriting files
cd ~
sudo yum update -y
sudo amazon-linux-extras install epel -y
sudo yum install glibc.i686 -y
sqlite3 --version

Paypal core SDK without Composer

I'm trying to get the PHP Core SDK to work without composer. There doesn't seem to be a simple way of working with the SDK without composer (https://github.com/paypal/sdk-core-php)
Any chance someone has an autoloader script or another solution to get this working?
I've been scanning for other information throughout the web, but it seems i'm the only person alive trying to get this to work without Composer.
Any chance? Thanks!
Alright, so it seems that i am really the only person on this planet who wants to do this. Well, then i'll answer my question myself. It seems like this is the guide for running every composer package without composer. Yihaa \o/. Probably easy stuff for most people using composer, but i've never used it because i'm on a shitty windows shared-host.
This is based on debian, but replace every apt-get with YUM for redhat or whatever.
So, i'm doing this in my root directory, don't whine about it :)
Ssh into your Linux Box (local mac or windows will work aswell but i'm not telling you)
# cd into the root directory (or user directory)
cd ~/
# install php5 and php5-curl and unzip (because the package we're
# getting is from GitHub). There might be other stuff your package is asking for.
# So just include it at the end
apt-get install php-5 php5-curl unzip
# install composer
curl -sS https://getcomposer.org/installer | php
# get the master archive
wget https://github.com/paypal/sdk-core-php/archive/master.zip
# unzip it
unzip master.zip
# cd into the directory
cd master
# move the files back to the ~/ directory
mv * ..
# remove the master directory
rm -r master
# install package using composer
php composer.phar install
# now we have the lib directory and the vendor directory. Lets tar that up
tar -cf package.tar lib/ vendor/
#we now have a tar file called package.tar copy that to your computer, ftp, whatever.
You can now create a directory in the place where you include all your stuff called lib-package (or whatever fancy name you'd like to call it) and add the following line in your project
require_once(/path/to/your/package/lib-package/vendor/autoload.php)
Voila, you're done.

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 to install php-gtk in the Acer Aspire One?

I have an application that works pretty well in Ubuntu, Windows and the Xandros that come with the Asus EeePC.
Now we are moving to the Acer Aspire One but I'm having a lot of trouble making php-gtk to compile under the Fedora-like (Linpus Linux Lite) Linux that come with it.
I managed to get all components needed for Phoronix test suite installed on Fedora but still have one issue.
# phoronix-test-suite gui
shell-init: error retrieving current directory: getcwd: cannot access parent directories: No such file or directory
pwd: error retrieving current directory: getcwd: cannot access parent directories: No such file or directory
pwd: error retrieving current directory: getcwd: cannot access parent directories: No such file or directory
/usr/bin/phoronix-test-suite: line 28: [: /usr/share/phoronix-test-suite: unary operator expected
You need two packages that aren't in Fedora, php-gtk, but php-gtk also has it's dependency - pecl-cairo
php-gtk needs to be downloaded from svn because tar.gz version is really old and doesn't work with php 5.3
Here is how I got all components built.
su -c "yum install php-cli php-devel make gcc gtk2-devel svn"
svn co http://svn.php.net/repository/pecl/cairo/trunk pecl-cairo
cd pecl-cairo/
phpize
./configure
make
su -c "make install"
cd ..
svn co http://svn.php.net/repository/gtk/php-gtk/trunk php-gtk
cd php-gtk
./buildconf
./configure
make
su -c "make install"
cd ..
wget http://www.phoronix-test-suite.com/download.php?file=phoronix-test-suite-2.8.1
tar xvzf phoronix-test-suite-2.8.1.tar.gz
cd phoronix-test-suite
su -c "./install-sh"
So please take where I left to get Phoronix test suite running on Fedora.
Hi Guys well I finally got this thing to work the basic workflow was this:
#!/bin/bash
sudo yum install yum-utils
#We don't want to update the main gtk2 by mistake so we download them
#manually and install with no-deps[1](and forced because gtk version
#version of AA1 and the gtk2-devel aren't compatible).
sudo yumdownloader --disablerepo=updates gtk2-devel glib2-devel
sudo rpm --force --nodeps -i gtk2*rpm glib2*rpm
#We install the rest of the libraries needed.
sudo yum --disablerepo=updates install atk-devel pango-devel libglade2-devel
sudo yum install php-cli php-devel make gcc
#We Download and compile php-gtk
wget http://gtk.php.net/do_download.php?download_file=php-gtk-2.0.1.tar.gz
tar -xvzf php-gtk-2.0.1.tar.gz
cd php-gtk-2.0.1
./buildconf
./configure
make
sudo make install
If you want to add more libraries like gtk-extra please type ./configure -help before making it to see the different options available.
After installing you'll need to add php_gtk2.so to the Dynamic Extensions of /etc/php.ini
extension=php_gtk2.so
Sources:
[1]: Dependency problems on Acer Aspire One Linux
If you could give us more to go on than just trouble making it compile; we might be better able to help you with your issues.

Categories