User Tools

Site Tools

Compiling Git and PHP on CentOS 7

CentOS 7 is a quite usable operating system. With its focus on stability, it doesn't come with latest tools, though. Git is version 1.8.3.1, while the newest version as of this writing is v2.22.1. PHP is v5.4.16, unsupported since four years.

Author is used to the Debian/Ubuntu packaging system, some procedures here might be a bit more complicated than necessary. Nevertheless it worked out.

Compile Git

This is the slow version, which takes several hours, but results in a slightly faster binary. There isn't much to configure, so it goes like this:

sudo yum-builddep git # <== Copy the list of installed packages to a file!
wget https://mirrors.edge.kernel.org/pub/software/scm/git/git-2.22.1.tar.gz
tar -xvzf git-2.22.1.tar.gz
cd git-2.22.1/
make prefix=$HOME/local profile
make prefix=$HOME/local PROFILE=BUILD install

Cleanup

There is probably a much more convenient way. Debian/Ubuntu's package manager recognizes packages installed solely to fulfill dependencies and recommends to uninstall them after uninstalling the actually handled package. Which means, if one installs three packages and uninstalls them later, system is back to the same state. On CentOS with Yum however, all dependency packages are left behind. Lack of knowledge and unwillingness to learn Yum details led to undoing all the package installations kind of manually, with a command assembled in a code editor from the list output by yum-builddep:

sudo yum remove asciidoc desktop-file-utils emacs expat-devel ...

On the particular server, this was a list of 74 packages.

Compile PHP

Other than Git, PHP compiles pretty sparse with defaults. The following is just enough PHP to run Composer in a thirty bees installation on the command line:

sudo yum-builddep php-cli # <== Copy the list of installed packages to a file!
wget https://www.php.net/distributions/php-7.3.8.tar.gz
tar -xvzf php-7.3.8.tar.gz
cd php-7.3.8/
./configure --prefix=$HOME/local --disable-cgi  --enable-libgcc --with-openssl
make
make install

Cleanup

sudo yum remove MariaDB-devel aspell-devel bzip2-devel ...

Adjusting PATH

Above binaries were installed into $HOME/local/, so the shell has to learn where to find them. Add this line to $HOME/.profile:

export PATH="${HOME}/local/bin:${PATH}"

If there is no such file, create it with just this content.

compiling_git_and_php_on_centos_7.txt ยท Last modified: 2019/08/17 14:17 by Traumflug