Dan
Dan

Reputation: 16236

Installing PHP in my home directory

I need to install PHP in my home directory, without polluting any directory outside my home [very important requirement!]. In the system there is already an older version of PHP running.

I found instructions here: http://blog.thecybershadow.net/2013/01/25/installing-php-and-apache-module-under-home/

I am running these commands in my home directory, as normal user dan

$ ./configure --prefix=/home/dan/php
$ make
$ INSTALL_ROOT=/home/dan/php make install

The author of the article states that you need to use both --prefix and INSTALL_ROOT to make sure nothing gets installed outside your home dir.

PHP gets installed (yeah!), however unfortunately it gets installed here:

/home/dan/php/php55/home/dan/php/php55/bin

whilst I was hoping to get it installed here:

/home/dan/php/php55/bin

What should I do? Should I use just one the directives? What's the neatest and conventional way to do this?

Upvotes: 12

Views: 4700

Answers (3)

ospahiu
ospahiu

Reputation: 3525

In order to install php in your home directory (Example: If you don't have root access but need a php executable), run the following commands in your php download folder:

$ ./configure --prefix=/my/path/
$ make install

As @Michael Tsang stated, you do not need to specify your install folder a second time as that will lead to the install creating the duplicate folder hierarchy in your install destination. I would also recommend compiling php with the --with-openssl if you're going to be working on a remote server, or using composer for example (simply add the flag to the end of the first command).

Upvotes: 3

user2284570
user2284570

Reputation: 3060

This is all simply:

INSTALL_ROOT=/ DESTDIR=/ make install

I think this because of this, but I am probably wrong:

You use both $PWD/configure --prefix= and the the INSTALL_ROOT variable with make. Those two options are mutually exclusive.
When you use --prefix, you ask to add a path before each path of files to be installed in the make files. Then you use INSTALL_ROOT variable.

Configure create static make rules; so make couldn't have a way to make some difference:
It add the path you specified with configure a second time.

Upvotes: 5

Michael Tsang
Michael Tsang

Reputation: 781

Just use

make install

since you have already configured it to be installed in your home. (Better to try it out on a non-root account first)

Upvotes: 0

Related Questions