I have a problem with building the package for PHP 7.3 from git. At the moment I am using Ubuntu 16.04 with utdatet php 7.0.x. (It's impossible to upgrade Ubuntu 16.04 to 18.04 at my VPS, because it crashes at boot. I only have Virtuozzo to debug and I can't find the point where it crashes, so upgrading to 18.04 isn't an option yet.)

My steps so far:

I have installed all programs for build, (git, build essential, libtool, bison and re2c).

I cloned the git from GitHub with:

git clone https://github.com/php/php-src.git 

Then I selected the branch I want:

git checkout PHP-7.3 

Then I ran:

./buildconf

What is the next step?

I need the following packages:

  php7.3
  libapache2-mod-php7.3
  php7.3-mysql
  mysql-server

I didn't search for a PPA, because I wanted to do it on my own in order to learn by doing it.


  1. Install dependencies.

    Ubuntu 16.04:

    sudo apt install autoconf automake bison build-essential curl flex \
      libtool libssl-dev libcurl4-openssl-dev libxml2-dev libreadline7 \
      libreadline-dev libsqlite3-dev libzip-dev libzip4 nginx openssl \
      pkg-config re2c sqlite3 zlib1g-dev libonig2 libonig-dev
    

    Ubuntu 18.04

    sudo apt install autoconf automake bison build-essential curl flex \
      libtool libssl-dev libcurl4-openssl-dev libxml2-dev libreadline7 \
      libreadline-dev libsqlite3-dev libzip-dev libzip4 nginx openssl \
      pkg-config re2c sqlite3 zlib1g-dev libonig4 libonig-dev
    

    Ubuntu 20.04

    sudo apt install autoconf automake bison build-essential curl flex \
      libtool libssl-dev libcurl4-openssl-dev libxml2-dev libreadline8 \
      libreadline-dev libsqlite3-dev libzip-dev libzip5 nginx openssl \
      pkg-config re2c sqlite3 zlib1g-dev libonig5 libonig-dev
    

    So you don't overwrite any existing PHP installs on your system, install PHP in your home directory. Create a directory for the PHP binaries.

     mkdir -p ~/bin/php7-latest/
    
  2. Download the PHP 7.3 from GitHub, decompress it, then change directories using cd to the new directory. You can also download PHP 7.3 from php.net/downloads.php and the installation instructions are exactly the same. Ordinarily this would be the preferred way of downloading PHP 7.3, but I'm using PHP 7.3 from https://github.com/php/ in this answer instead in order to match the PHP 7.3 archive that is asked about in the question.

  3. Configure PHP. Remove any options you don't need (like MySQL or Postgres (--with-pdo-pgsql))

     ./configure --prefix=$HOME/bin/php-latest \
         --enable-mysqlnd \
         --with-pdo-mysql \
         --with-pdo-mysql=mysqlnd \
         --with-pdo-pgsql=/usr/bin/pg_config \
         --enable-bcmath \
         --enable-fpm \
         --with-fpm-user=www-data \
         --with-fpm-group=www-data \
         --enable-mbstring \
         --enable-phpdbg \
         --enable-shmop \
         --enable-sockets \
         --enable-sysvmsg \
         --enable-sysvsem \
         --enable-sysvshm \
         --enable-zip \
         --with-libzip=/usr/lib/x86_64-linux-gnu \
         --with-zlib \
         --with-curl \
         --with-pear \
         --with-openssl \
         --enable-pcntl \
         --with-readline
    

    Probably you won't need to remove any of the options except for --with-pdo-pgsql=/usr/bin/pg_config if PostgreSQL isn't installed. If you don't remove an option that is specific to a package that isn't installed, then this command will return an error message that tells you what option must be removed so that the command will run successfully.

  4. Compile the binaries:

    make # wait until make is finished
    

    When make is finished you will see the following message:

    Build complete.
    Don't forget to run 'make test'.
    

    Warning: make test takes a long time to finish, so don't run it when the computer is busy.

    make install
    
  5. Copy the PHP.ini file to the install directory

    cp php.ini-development ~/bin/php-latest/lib/
    
  6. Rename two files.

    cd ~/bin/php-latest/etc/  
    mv php-fpm.conf.default php-fpm.conf
    mv php-fpm.d/www.conf.default php-fpm.d/www.conf
    
  7. Create symbolic links for your for your binary file.

    cd ~/bin
    ln -s php-latest/bin/php php
    ln -s php-latest/bin/php-cgi php-cgi
    ln -s php-latest/bin/php-config php-config
    ln -s php-latest/bin/phpize phpize
    ln -s php-latest/bin/phar.phar phar
    ln -s php-latest/bin/pear pear
    ln -s php-latest/bin/phpdbg phpdbg
    ln -s php-latest/sbin/php-fpm php-fpm
    
  8. Link your local PHP to the php command. You will need to logout then log back in for php to switch to the local version instead of the installed version from the default Ubuntu repositories.

    # add this to .bashrc
    if [ -d "$HOME/bin" ] ; then
      PATH="$HOME/bin:$PATH"
    fi
    
  9. Start PHP-FPM

    sudo ~/bin/php-latest/sbin/php-fpm  
    

    If you run the above command as normal user without sudo, it will show the following notices:

    NOTICE: [pool www] 'user' directive is ignored when FPM is not running as root.    
    NOTICE: [pool www] 'group' directive is ignored when FPM is not running as root.    
    

Source: The Install file in php-src-master directory from https://github.com/php/php-src.git contains a link to https://php.net/install from which source these instructions were revised. In addition to several small revisions I added information about how to install PHP 7.3 locally in your home directory without requiring root permissions.