Install with pecl to local dir on shared hosting - mongodb

I'd like to install a PHP extension on a bluehost shared site; specifically the MongoDB driver. Since pecl is unable to write to the primary server directory that has all the installed extensions, I'd like to install the mongo.so file to a directory I specify under my home. The closest article I found on the web was:
http://www.site5.com/blog/programming/php/how-to-setup-your-own-php-pear-environment/20090624/
However, after following the steps when I use the "pecl install mongo" command, it still keeps trying to install to bluehost's central directory on the server.

According to my web host's technical support team, utilising the pecl installer attempts to install the extension server-wide rather than under your account only. My web host doesn't allow server-wide installations in their shared environment for security reasons and because they want to keep their fleet universally the same across the board. I suspect your host is the same.
However, they did suggest I download, configure and install the pecl package (pecl_http) in my account only (rather than server-wide) via the following manual process:
$ cd ~/
$ wget http://pecl.php.net/get/pecl_http
$ tar -zxvf pecl_http.tar.gz
$ cd pecl_http
$ phpize
$ ./configure --prefix=~/bin
$ make
$ make test
$ make install
A successful install will have created extname.so and put it into the
PHP extensions directory. You'll need to edit php.ini (in my case,
this was a copy of the standard php.ini file that I placed in the same
folder as the script using the extension) and add an
extension=extname.so line (in my case, extension=http.so) before you can use the extension.
http://www.php.net/manual/en/install.pecl.phpize.php
Note that the tilde character (~) in the above code refers to the home directory of the current user (e.g. /home/username on my host's server).
Issues you may run into
When using the tar command, a "cannot open: not a directory" error
appeared as pecl_http had been downloaded without a file extension.
This was easily corrected:
mv pecl_http pecl_http.tar.gz
When using the make install command, a "cp: cannot create regular
file...: Permission denied" errror appeared. I resolved this issue
by changing the ext_dir for pecl...
pecl config-set ext_dir /home/username/bin/extensions
...and re-running make install. I also had to copy the http.so extension to /home/username/bin/extensions and then reference that location in my php.ini file:
extension_dir = "/home/username/bin/extensions"

this sounds like you don't have root access to your server. if your need to compile anything you must be have root access permission to server, or maybe you must be one of the sudoers.

Related

Install laravel ends up in wrong directory (composer with cygwin)

I am trying to install laravel with the use of cygwin, a command line tool for windows.
I use this line
composer create-project laravel/laravel=4.2.0 c/my_workspace/projectname --prefer-dist
which installs everything. But it does not end up in c:/my_workspace/projectname. Instead it ends up in cygwin64/c/my_workspace/projectname.
The next time I tried it it ended up in a different folder, also inside "cygwin64".
It doesn't matter what path I specify, the path will start in the cygwin64 folder for some reason. By the way, in cygwin there is a always a prefix for the paths called /cygdrive/. Is that what causes it to start from cygwin64?
I also tried instead to execute it from cmd by navigating to
cd c:/myworkspace
And then entering
composer create-project laravel/laravel=4.2.0 /projectname --prefer-dist
It says "Installling", and then "loading from cache" (?), then it says
failed to download laravel/laravel from dist: C:my_workspace/vendor/composer/5079c43b does not exist and could not be created
Then it tries to download from source. When cloning starts it fails:
Failed to clone git#github.com:laravel/laravel.git, git was not found
I managed to get it installed finally. I suppose there was something wrong with the way I wrote the filepath:
c/my_workspace/projectname
so it was created in the cygwin64 folder (for some reason). This time I navigated to the folder where I want the install:
cd c:/my_workspace/projectname
then install with:
composer create-project laravel/laravel=4.2.0 --prefer-dist
However, I got a mkdir() permission denied problem, which was solved by running cygwin as administrator.
Then I got another problem where you setup the laravel development server with
$ php artisan serve
It could not find the artisan file because it was located inside a "laravel" folder(!?), which I guess wasn't right, so I moved the laravel files back to my project folder and deleted the laravel folder. The laravel development server has started so I guess it works now.

How to download, compile & install ONLY the libpq source on a server that DOES NOT have PostgreSQL installed

How can I download, compile, make & install ONLY the libpq source on a server (Ubuntu) that DOES NOT have PostgreSQL installed?
I have found the libpq source here. However it does NOT seem to be separable from the entire PostgreSQL. Thanks in advance.
I DO NOT want to install the entire PostgreSQL. I want to use libpq as a C interface to PostgreSQL on a DIFFERENT server (also Ubuntu) that DOES have it installed.
I also found this old link which indicates that the above is POSSIBLE but not HOW to do it.
I have found the libpq source here. However it does NOT seem to be separable from the entire PostgreSQL.
It has to be configured with the entire source tree because that's what generates the necessary Makefile parts. But once configured, make && make install can run inside the src/interfaces/libpq directory alone, and the rest being left out completely.
In steps:
download the source code archive, for example https://ftp.postgresql.org/pub/source/v9.4.1/postgresql-9.4.1.tar.bz2
unpack into a build directory: tar xjf ~/Downloads/postgresql-9.4.1.tar.bz2
apt-get install libssl-dev if it's not installed already
cd into it and configure: cd postgresql-9.4.1; ./configure --with-openssl --without-readline
Assuming configure succeeds, cd into src/interfaces/libpq and run make
still in the libpq directory, run make install as root: sudo make install.
That will install into /usr/local/pgsql and subdirectories as a library independent and insulated from the one packaged in Ubuntu if it happens to be installed. To install it elsewhere, specify the location with the --prefix option to configure.
Besides downloading and configuration, the steps are:
cd src/interfaces/libpq; make; make install; cd -
cd src/bin/pg_config; make install; cd -
cd src/backend; make generated-headers; cd -
cd src/include; make install; cd -
These steps will give you the library and headers of libpq, and a binary called pg_config, and all postgresql backend headers, so that you could compile things like libpqxx correctly.
(I've just tested with postgresql-9.6.5.)

How to install MongoDB Driver in XAMPP mac (OSX)

I have installed mongodb and I can access it through my terminal. I want to install drivers for XAMPP in OSX (Yosemite). I downloaded mongo.so file and kept it under /Applications/XAMPP/xamppfiles/lib/php/extensions/no-debug-non-zts-20131226 path which is my extension_dir pointing to and wrote extension=mongo.so in php.ini file but no luck. After restarting Apache I can't find any mongodb when I run phpinfo(). Please help. Maybe I just want the correct mongo.so file. Please help.
in command line...
sudo /Applications/XAMPP/xamppfiles/bin/pecl install mongo
if it gives ERROR: `phpize’ failed
Download autoconf
curl http://ftp.gnu.org/gnu/autoconf/autoconf-latest.tar.gz > autoconf.tar.gz
Untar the autoconf archive
tar -xvzf autoconf.tar.gz
Configure and make – note the folder un-archived may have a different name.
cd autoconf-2.69
./configure
sudo make && sudo make install
This installs autoconf to ‘/usr/local/bin/autoconf’. In order to get phpize to work set the PHP_AUTOCONF environment variable to point to the newly installed autoconf.
export PHP_AUTOCONF=/usr/local/bin/autoconf
write anywhere in php.ini: extension=mongo.so (not ;extension=mongo.so or ;extension=:"mongo.so") just write extension=mongo.so
then restart this
if you get any problem then let me know I'll for sure fix it...

pecl instal ibm_db2 fails

I need to install ibm_db2 extension for making php connection with db2. So I have used pecl. But it produces error.
$ pecl install ibm_db2
When I run this, the below error occurs.
.....
checking in /home/db2inst1/sqllib/lib64...
checking in /home/db2inst1/sqllib/lib32... found
checking for DB2 CLI include files in default path... checking in /home/db2inst1/sqllib... not found
configure: error: Please reinstall the DB2 CLI distribution
ERROR: `/tmp/pear/temp/ibm_db2/configure --with-IBM_DB2=/home/db2inst1/sqllib' failed
Please help.
download ibm_data_server_driver_for_odbc_cli_linuxx64_v97.tar.gz from ibm.com
untar the file into: /opt/ibm/
enter command > pecl install ibm_db2
When prompted for DB2 Installation Directory, use: /opt/ibm/odbc_cli/clidriver/
You need the DB2 headers to build the ibm_db2 PHP extension. They are included in the IBM Data Server Driver for ODBC and CLI.
before install ibm_db2, you have install expc, in the folder uncompress execute the script db2_install with root user: # ./db2_install
It asks for the installation path (e /opt/ibm/db2)
then install ibm_db2
Install a DB2 instance (On Ubuntu due to following instructions: http://www.db2teamblog.com/2010/09/db2-express-c-packages-for-ubuntu-1004.html) This will work also on newer systems.
After that run the following command:
pecl install ibm_db2
When prompted type:
/opt/ibm/dbs/V9.7/
and confirm the installation directory
The error is because in the path /home/db2inst1/sqllib not found the include folder.
you must download db2exc_974_LNX_x86_64.tar.gz, uncompress it (e. /otp/ibm/db2)
then install pecl install ibm_db2
DB2 Installation Directory? use this : /opt/ibm/db2
Check also the first comment on PHP manual by Jean Ferreira.
link
You need the APPLICATION DEVELOPMENT TOOLS when you install the client you should have the option to install them.
Check your /home/db2inst1/sqllib/include folder you'll see that you only have asn.h, a boatload of files is missing when you don't have the development tools installed.
Then use /home/db2inst1/sqllib as your install directory.
I lacked the APPLICATION_DEVELOPMENT_TOOLS in my DB2 installation (confirmed by only having asn.h in my includes folder)
To install the APPLICATION_DEVELOPMENT_TOOLS into an existing DB2 installation, follow these instructions
Check your product information. You will need this information later.
db2ls -p -q -b /opt/ibm/db2/V10.5
Download the appropriate Universal Fix Pack from IBM:
https://www-945.ibm.com/support/fixcentral/swg/selectFixes?parent=ibm~Information%2BManagement&product=ibm/Information+Management/DB2&release=All&platform=Linux+64-bit,x86_64&function=textSearch&text=universal
Be sure to find the matching FixPack version (from the step above) and the correct architecture.
Save the file to /opt/ibm/fixpack
Gunzip/Tar the file
cd /opt/ibm/fixpack
gunzip /opt/ibm/fixpack/downloaded_pack.tar.gz
tar xvf /top/ibm/fixpack/downloaded_pack.tar
Create a response file /opt/ibm/fixpack/devtools.resp like this.
Replace the PROD value with the Product Response File ID
Replace the FILE value with the DB2 installation folder
PROD = DB2_SERVER_EDITION
FILE = /opt/ibm/db2/V10.5
LIC_AGREEMENT = ACCEPT
INSTALL_TYPE = CUSTOM
COMP = APPLICATION_DEVELOPMENT_TOOLS
Stop DB2 with db2stop or db2stop force
Run db2setup with the response code
cd /opt/ibm/fixpack/universal/
./db2setup -r /opt/ibm/fixpack/devtools.resp
Start DB2 with dbstart
When you are done, run pecl install ibm_db2
Use /home/db2inst1/sqllib as your install directory.
Original instructions were found here to install them into an existing DB2 installation (I used the 3rd option):
http://db2commerce.com/2014/02/11/installing-a-db2-component-after-the-rest-of-db2-is-installed/
I got solution for the above issue.
Need to select Custom Install while installing db2. So I just uninstalled and reinstalled DB2.
After that It works fine for me. Thanks everyone :)

Where do I get libpq source?

I want to write application which uses Postgresql as DBMS.
To write client application do I need libpq library and header files?
If yes where I would get libpq library and header files.
Libpq is included in the full PostgreSQL source code. You can use just libpq without the rest of PostgreSQL, but must download the full package.
You can download it from the PostgreSQL Downloads page.
Once you extract the full package it is inside src\interfaces\libpq.
The PostgreSQL installation guide details how to install only the client libraries in the Installation section, under Client-only installation.
Libpq documentation is also available.
In postgresql sources, src\interfaces\libpq.
And yes, it is possible to compile only the libpq.
get the lipq from repo, {for debian} :
sudo apt-get install libpq-dev
I was also facing this issue but didn't got a clear answer:
This issue clearly states that while installing diesel-cli system is not able to locate libpq.lib
First of all you should have a Postgres installed on your machine.
Also diesel require visual c++, thus download and install it if not already, the size of setup will be ~5gb.
Once above installations are done you need to setup environment variables:
In my case path of Postgres installation is C:\Program Files\PostgreSQL thus add 2 environment variable path under User variables add new in Path where your libpq.lib is located in my case it is available in both C:\Program Files\PostgreSQL\12\lib and C:\Program Files\PostgreSQL\12\bin
Once this is added create one more environment variable PQ_LIB_DIR and set path as shown below
Note: Once done re-trigger the installation command in a new cmd window
Source: pq-sys and github-solution
For Windows users, it's in (version may be different)
C:\Program Files\PostgreSQL\11\lib
There you find libpq.lib. Provide this directory to Linker input.
Don't forget to include C:\Program Files\PostgreSQL\11\include directory for include directories.
I fix this problem reccently. This is a solution if you don't want to install Postgres in you windows.
At first, you need download Postgres Binaries. The version I download is 13.6, but it's seems like any version is fine.
Unzip the zip file.Copy libpq.lib from pgsql\lib to shomewhere like C:\Program Files\Postgres\lib.
Execute the following command in cmd window.
setx PQ_LIB_DIR "{where_you_copy_to}"
Open a new cmd windows and install diesel_cli
cargo install diesel_cli --no-default-features --features postgres
In linux vertify you get the libpq.
1st, there is an app: pg_config: https://www.postgresql.org/docs/current/app-pgconfig.html
after you found out the pg_config absolute bin path.(if you installed multi version of postgressql) Then You can get
--includedir
Print the location of C header files of the client interfaces.
--libdir
Print the location of object code libraries.
Then try to compile/build some example code: https://www.postgresql.org/docs/current/libpq-example.html
Some common failure example: https://www.postgresql.org/docs/current/libpq-build.html
You can install Postgres locally from https://www.enterprisedb.com/downloads/postgres-postgresql-downloads but select only "Command line tools" for install.
After that, you can found libpq.dll in C:\Program Files\PostgreSQL\15\bin