I'm following this tutorial: Laravel 5.6 in Docker with PHP 7.2, NGINX 1.10 and MySQL 5.7
Which is basically an update of this: Laravel + Docker Part 1 — setup for Development
But when I ran
docker-compose up
I got this error
E: Unable to locate package mysql-client —-no-install-recommends
ERROR: Service 'app' failed to build: The command '/bin/sh -c apt-get update && apt-get install -y mysql-client —-no-install-recommends && docker-php-ext-install pdo_mysql' returned a non-zero code: 100
A full output
Creating network "pulzu_default" with the default driver
Building app
Step 1/2 : FROM php:7.2.2-fpm
---> 60245f64ed12
Step 2/2 : RUN apt-get update && apt-get install -y mysql-client —-no-install-recommends && docker-php-ext-install pdo_mysql
---> Running in cefd70564b31
Get:1 http://security.debian.org stretch/updates InRelease [94.3 kB]
Ign:2 http://cdn-fastly.deb.debian.org/debian stretch InRelease
Get:3 http://cdn-fastly.deb.debian.org/debian stretch-updates InRelease [91.0 kB]
Get:5 http://security.debian.org stretch/updates/main amd64 Packages [468 kB]
Get:4 http://cdn-fastly.deb.debian.org/debian stretch Release [118 kB]
Get:6 http://cdn-fastly.deb.debian.org/debian stretch Release.gpg [2434 B]
Get:7 http://cdn-fastly.deb.debian.org/debian stretch-updates/main amd64 Packages [12.1 kB]
Get:8 http://cdn-fastly.deb.debian.org/debian stretch/main amd64 Packages [9530 kB]
Fetched 10.3 MB in 2s (4142 kB/s)
Reading package lists...
Reading package lists...
Building dependency tree...
Reading state information...
E: Unable to locate package mysql-client —-no-install-recommends
ERROR: Service 'app' failed to build: The command '/bin/sh -c apt-get update && apt-get install -y mysql-client —-no-install-recommends && docker-php-ext-install pdo_mysql' returned a non-zero code: 100
Does anyone have any idea how to fix it?
The image is missing dependencies to be able to install mysql-client, this is caused by the --no-install-recommends flag. By default, Ubuntu installs recommended but not suggested packages. With --no-install-recommends, only the main dependencies (packages in the Depends field) are installed.
Change the Dockerfile or according to the article app.dockerfile to:
FROM php:7.2.2-fpm
RUN apt-get update && apt-get install -y mysql-client \
&& docker-php-ext-install pdo_mysql
And you should be able to build the image, therefore the docker-compose up command would work.
Related
I've getting started with Docker, using the LAMP repo from GitHub as my starting point. I need to add the libxslt lib. I've tried adding this to my Dockerfile:
RUN apt-get install libxslt-dev
RUN docker-php-ext-enable libxslt-dev
But keep getting error: E: Unable to locate package libxslt-dev
I've tried to search for the lib from the Docker container's command line apt-cache search libxslt but get no results.
Can anybody point me in the right direction to get this lib installed?
Thanks
Followed answer below (#vpalmerini) updating Dockerfile:
RUN apt update && apt-get install -y libxslt-dev
RUN docker-php-ext-enable libxslt-dev
Which I thought was working:
Step 9/13 : RUN apt update && apt-get install -y libxslt-dev
[...]
The following additional packages will be installed:
libxslt1.1
The following NEW packages will be installed:
libxslt1-dev libxslt1.1
0 upgraded, 2 newly installed, 0 to remove and 0 not upgraded.
Need to get 756 kB of archives.
After this operation, 3001 kB of additional disk space will be used.
Get:1 http://deb.debian.org/debian buster/main amd64 libxslt1.1 amd64 1.1.32-2.2~deb10u1 [237 kB]
Get:2 http://deb.debian.org/debian buster/main amd64 libxslt1-dev amd64 1.1.32-2.2~deb10u1 [519 kB]
Fetched 756 kB in 0s (4903 kB/s)
Selecting previously unselected package libxslt1.1:amd64.
(Reading database ... 21271 files and directories currently installed.)
Preparing to unpack .../libxslt1.1_1.1.32-2.2~deb10u1_amd64.deb ...
Unpacking libxslt1.1:amd64 (1.1.32-2.2~deb10u1) ...
Selecting previously unselected package libxslt1-dev:amd64.
Preparing to unpack .../libxslt1-dev_1.1.32-2.2~deb10u1_amd64.deb ...
Unpacking libxslt1-dev:amd64 (1.1.32-2.2~deb10u1) ...
Setting up libxslt1.1:amd64 (1.1.32-2.2~deb10u1) ...
Setting up libxslt1-dev:amd64 (1.1.32-2.2~deb10u1) ...
Processing triggers for libc-bin (2.28-10) ...
Removing intermediate container b62504aca3f9
---> b62b7af34467
Step 10/13 : RUN docker-php-ext-enable libxslt-dev
---> Running in 181191c74fe5
error: 'libxslt-dev' does not exist
Also tried changing RUN command to match package found: libxslt1-dev
RUN docker-php-ext-enable libxslt1-dev
Still unable to enable libxslt
Further info, output from:
dpkg --get-selections
includes:
libxml2-dev:amd64 install
libxrender-dev:amd64 install
libxrender1:amd64 install
libxslt1-dev:amd64 install
libxslt1.1:amd64 install
libxt-dev:amd64 install
But running RUN docker-php-ext-enable libxslt1-dev still gives
error: 'libxslt1-dev' does not exist
You are confusing the php extension called xsl with the system development package for libxslt (present on your base image Debian Linux distribution with the specific name libxslt1-dev) which is required to install that php extension.
Here is a basic Dockerfile to achieve your requirement. Note that, as a good practice, I made the install in a single run instruction with some extra cleanup at the end.
The apt-get remove line is optional but will reduce the layer size a bit more. Installing libxslt1-dev and all its dependencies (icu-devtools, libicu-dev, libicu63, libxml2, libxml2-dev, libxslt1.1) is mandatory for installing the extension. But once it is done, the dev packages can be removed.
FROM php:7.4.2-apache-buster
RUN apt-get update && \
apt-get install -y libxslt1-dev && \
docker-php-ext-install xsl && \
apt-get remove -y libxslt1-dev icu-devtools libicu-dev libxml2-dev && \
rm -rf /var/lib/apt/lists/*
The only thing missing is that you have to update the packages of your image, then you will be able to install libxslt-dev package:
RUN apt update && apt-get install -y libxslt-dev
Summary
I've created a shell script that is uploaded via SFTP using the phpseclib3 library. The shell script is being executed, but all of the apt packages are not being installed when running the script using the below PHP Code. It installs some packages, but hangs up on one somewhere. However, if I use FileZilla to upload the file using the same user, and then login to execute the same script all packages are being installed correctly. The output is not showing any errors either.
It's almost like the packages are all trying to be created once which is locking the packages up and causing an error that I can't find.
Things I've tried
Have the script run silently
Made sure that PHP isn't timing out
Used a different SSH composer package
Splitting the apt install into individual items instead of one long list
Added and removed sudo true to the top of the script
Tried to re-run apt install multiple times
Use apt-get instead of apt
PHP Code
$ssh = new SSH2($ip_address);
if (!$ssh->login('login', $key)) {
// error handling
}
$ssh->setTimeout(0);
$ssh->setKeepAlive(10);
$process[] = $ssh->exec('chmod +x install.sh; sh install.sh;');
Shell Example
#!/bin/bash
sudo true
sudo dpkg --add-architecture i386
sudo apt update
sudo apt -y install curl wget file tar bzip2 gzip unzip bsdmainutils python util-linux ca-certificates binutils bc jq tmux netcat lib32gcc1 lib32stdc++6
echo steam steam/license note '' | sudo debconf-set-selections && echo steam steam/question select 'I AGREE' | sudo debconf-set-selections && sudo apt -y install steamcmd
wget -O linuxgsm.sh https://linuxgsm.sh && chmod +x linuxgsm.sh && bash linuxgsm.sh squadserver
yes Y | ./squadserver install
touch done.txt
Error Log
sudo true
+ sudo dpkg --add-architecture i386
+ sudo apt update
WARNING: apt does not have a stable CLI interface. Use with caution in scripts.
Hit:1 http://security.ubuntu.com/ubuntu bionic-security InRelease
Get:2 http://mirrors.digitalocean.com/ubuntu bionic InRelease [242 kB]
Hit:3 http://mirrors.digitalocean.com/ubuntu bionic-updates InRelease
Hit:4 http://mirrors.digitalocean.com/ubuntu bionic-backports InRelease
Get:5 http://security.ubuntu.com/ubuntu bionic-security/main i386 Packages [902 kB]
Get:6 http://security.ubuntu.com/ubuntu bionic-security/restricted i386 Packages [13.5 kB]
Get:7 http://security.ubuntu.com/ubuntu bionic-security/universe i386 Packages [973 kB]
Get:8 http://security.ubuntu.com/ubuntu bionic-security/multiverse i386 Packages [9208 B]
Get:9 http://mirrors.digitalocean.com/ubuntu bionic/main i386 Packages [1007 kB]
Get:10 http://mirrors.digitalocean.com/ubuntu bionic/restricted i386 Packages [9156 B]
Get:11 http://mirrors.digitalocean.com/ubuntu bionic/universe i386 Packages [8531 kB]
Get:12 http://mirrors.digitalocean.com/ubuntu bionic/multiverse i386 Packages [144 kB]
Get:13 http://mirrors.digitalocean.com/ubuntu bionic-updates/main i386 Packages [1197 kB]
Get:14 http://mirrors.digitalocean.com/ubuntu bionic-updates/restricted i386 Packages [20.2 kB]
Get:15 http://mirrors.digitalocean.com/ubuntu bionic-updates/universe i386 Packages [1555 kB]
Get:16 http://mirrors.digitalocean.com/ubuntu bionic-updates/multiverse i386 Packages [12.7 kB]
Get:17 http://mirrors.digitalocean.com/ubuntu bionic-backports/main i386 Packages [10.0 kB]
Get:18 http://mirrors.digitalocean.com/ubuntu bionic-backports/universe i386 Packages [10.3 kB]
Fetched 14.6 MB in 11s (1370 kB/s)
Reading package lists...
Building dependency tree...
Reading state information...
74 packages can be upgraded. Run 'apt list --upgradable' to see them.
+ sudo apt -y install curl wget file tar bzip2 gzip unzip bsdmainutils python util-linux ca-certificates binutils bc jq tmux netcat lib32gcc1 lib32stdc++6
WARNING: apt does not have a stable CLI interface. Use with caution in scripts.
E: Could not get lock /var/lib/dpkg/lock-frontend - open (11: Resource temporarily unavailable)
E: Unable to acquire the dpkg frontend lock (/var/lib/dpkg/lock-frontend), is another process using it?
+ sudo debconf-set-selections
+ echo steam steam/license note ''
+ sudo debconf-set-selections
+ echo steam steam/question select 'I AGREE'
+ sudo apt -y install steamcmd
WARNING: apt does not have a stable CLI interface. Use with caution in scripts.
E: Could not get lock /var/lib/dpkg/lock-frontend - open (11: Resource temporarily unavailable)
E: Unable to acquire the dpkg frontend lock (/var/lib/dpkg/lock-frontend), is another process using it?
The issue was coming from this portion of the code:
sudo dpkg --add-architecture i386
sudo apt update
For whatever reason it was creating a lock file which was killing the other processes after it. To fix it, I just removed the lock and reconfigured dpkg by adding this portion of code after the update.
sudo rm /var/lib/apt/lists/lock
sudo rm /var/cache/apt/archives/lock
sudo rm /var/lib/dpkg/lock*
sudo dpkg --configure -a
Attempting to install php-xmlrpc on an image with php7.3 installed on it.
As you can see, I tried apt-get update but it does not help. I have tried using php7.3-xmlrpc also.
Dockerfile line:
RUN apt-get update && apt-get install php-xmlrpc -y
Docker build output:
Step 5/8 : RUN apt-get update && apt-get install php-xmlrpc -y
---> Running in 163542fabd8a
Get:1 http://security-cdn.debian.org/debian-security stretch/updates InRelease [94.3 kB]
Get:2 http://security-cdn.debian.org/debian-security buster/updates InRelease [39.1 kB]
Ign:3 http://cdn-fastly.deb.debian.org/debian stretch InRelease
Get:4 http://security-cdn.debian.org/debian-security stretch/updates/main amd64 Packages [500 kB]
Get:5 http://cdn-fastly.deb.debian.org/debian stretch-updates InRelease [91.0 kB]
Hit:6 http://cdn-fastly.deb.debian.org/debian buster InRelease
Get:7 http://security-cdn.debian.org/debian-security buster/updates/main amd64 Packages [112 kB]
Get:8 http://cdn-fastly.deb.debian.org/debian buster-updates InRelease [49.3 kB]
Get:9 http://cdn-fastly.deb.debian.org/debian stretch-updates/main amd64 Packages.diff/Index [12.5 kB]
Get:10 http://cdn-fastly.deb.debian.org/debian stretch-updates/main amd64 Packages 2019-10-27-2015.53.pdiff [398 B]
Get:12 http://cdn-fastly.deb.debian.org/debian stretch-updates/main amd64 Packages 2019-11-06-2017.59.pdiff [903 B]
Get:12 http://cdn-fastly.deb.debian.org/debian stretch-updates/main amd64 Packages 2019-11-06-2017.59.pdiff [903 B]
Hit:11 http://cdn-fastly.deb.debian.org/debian stretch Release
Fetched 900 kB in 1s (634 kB/s)
Reading package lists...
Reading package lists...
Building dependency tree...
Reading state information...
Package php-xmlrpc is a virtual package provided by:
php7.3-xmlrpc 7.3.11-1~deb10u1 [Not candidate version]
php7.3-xmlrpc 7.3.4-2 [Not candidate version]
php7.0-xmlrpc 7.0.33-0+deb9u6 [Not candidate version]
php7.0-xmlrpc 7.0.33-0+deb9u3 [Not candidate version]
E: Package 'php-xmlrpc' has no installation candidate
Docker file:
FROM php:7.3-apache
RUN apt-get update -y && apt-get upgrade -y;
RUN apt-get install -y libxml2-dev
RUN docker-php-ext-install -j$(nproc) xmlrpc
that works.
If you build it this way:
docker build --tag stackoverflow .
then you can check installed extension by runnig command:
docker run -it --entrypoint="" --rm stackoverflow /bin/bash
and type into console
php -m
that gives the output:
[PHP Modules]
Core
ctype
curl
date
dom
fileinfo
filter
ftp
hash
iconv
json
libxml
mbstring
mysqlnd
openssl
pcre
PDO
pdo_sqlite
Phar
posix
readline
Reflection
session
SimpleXML
sodium
SPL
sqlite3
standard
tokenizer
xml
xmlreader
xmlrpc
xmlwriter
zlib
with:
xmlrpc
Today I tried to install some PHP extensions for the default php docker container. My dockerfile looks like this:
FROM php:7.2-cli
#remove apt install restriction
RUN rm /etc/apt/preferences.d/no-debian-php
#Install php-addons
RUN apt-get update \
&& apt-get install -y php-zip php-xml php-json php-mbstring
COPY . /
WORKDIR /
I got 2 errors by default.
Err:1 http://deb.debian.org/debian stretch InRelease
Temporary failure resolving 'deb.debian.org'
Could not resolve 'archive.ubuntu.com'
AND
E: Package 'php-json' has no installation candidate
The Solution to this was:
E: Package 'php-json' has no installation candidate
fixed with this line in dockerfile
RUN rm /etc/apt/preferences.d/no-debian-php
AND
Err:1 http://deb.debian.org/debian stretch InRelease
Temporary failure resolving 'deb.debian.org'
Could not resolve 'archive.ubuntu.com'
Fixed with
Uncomment the following line in /etc/default/docker
DOCKER_OPTS="--dns 8.8.8.8 --dns 8.8.4.4"
Since php7 has been released, I wanted to try it out on my current machine.
I have tried building it from source using this gist yet that fails for me (and I have posted the error message in the thread).
Yet the question is not necessarily solving the compiling issue, but more basic:
How can I install php7?
I am on Ubuntu14.04, yet I would like for the answer to be operating-system-agnostic.
For install php7 in ubuntu 14.04 system please follow mentioned below steps:
sudo add-apt-repository ppa:ondrej/php
sudo apt-get update
sudo apt-get install php7.0
for use mysql
sudo apt-get install php7.0-mysql
sudo service apache2 restart
If you want to remove php5 then after installation of php7 follow the steps mentioned below:
sudo apt-get update
sudo apt-get purge php5-common -y
sudo apt-get install php7.0 php7.0-fpm php7.0-mysql -y
sudo apt-get --purge autoremove -y
I shared at https://jaimemontoya.com/learning-php-7/#20190807165248 the way I installed PHP Version 7.0.33-8 on Ubuntu 18.04.1. I also posted a screenshot of what my <?php phpinfo();?> returned after the successful installation. See below the steps I followed:
root#jaimemontoya:/# pwd
/
root#jaimemontoya:/# apt-add-repository ppa:ondrej/php
Co-installable PHP versions: PHP 5.6, PHP 7.x and most requested extensions are included. Only Supported Versions of PHP (http://php.net/supported-versions.php) for Supported Ubuntu Releases (https://wiki.ubuntu.com/Releases) are provided. Don't ask for end-of-life PHP versions or Ubuntu release, they won't be provided.
Debian oldstable and stable packages are provided as well: https://deb.sury.org/#debian-dpa
You can get more information about the packages at https://deb.sury.org
BUGS&FEATURES: This PPA now has a issue tracker:
https://deb.sury.org/#bug-reporting
CAVEATS:
1. If you are using php-gearman, you need to add ppa:ondrej/pkg-gearman
2. If you are using apache2, you are advised to add ppa:ondrej/apache2
3. If you are using nginx, you are advise to add ppa:ondrej/nginx-mainline
or ppa:ondrej/nginx
PLEASE READ: If you like my work and want to give me a little motivation, please consider donating regularly: https://donate.sury.org/
WARNING: add-apt-repository is broken with non-UTF-8 locales, see
https://github.com/oerdnj/deb.sury.org/issues/56 for workaround:
# LC_ALL=C.UTF-8 add-apt-repository ppa:ondrej/php
More info: https://launchpad.net/~ondrej/+archive/ubuntu/php
Press [ENTER] to continue or Ctrl-c to cancel adding it.
Hit:1 http://ppa.launchpad.net/certbot/certbot/ubuntu bionic InRelease
Hit:2 http://archive.ubuntu.com/ubuntu bionic InRelease
Hit:3 http://us.archive.ubuntu.com/ubuntu bionic InRelease
Get:4 http://us.archive.ubuntu.com/ubuntu bionic-updates InRelease [88.7 kB]
Get:5 http://us.archive.ubuntu.com/ubuntu bionic-security InRelease [88.7 kB]
Get:6 http://ppa.launchpad.net/ondrej/php/ubuntu bionic InRelease [20.8 kB]
Get:7 http://us.archive.ubuntu.com/ubuntu bionic-updates/main amd64 Packages [697 kB]
Get:8 http://us.archive.ubuntu.com/ubuntu bionic-updates/restricted amd64 Packages [7,024 B]
Get:9 http://us.archive.ubuntu.com/ubuntu bionic-updates/universe amd64 Packages [983 kB]
Get:10 http://us.archive.ubuntu.com/ubuntu bionic-updates/universe Translation-en [299 kB]
Get:11 http://us.archive.ubuntu.com/ubuntu bionic-updates/multiverse amd64 Packages [11.9 kB]
Get:12 http://us.archive.ubuntu.com/ubuntu bionic-security/universe amd64 Packages [577 kB]
Get:13 http://us.archive.ubuntu.com/ubuntu bionic-security/universe Translation-en [189 kB]
Get:14 http://ppa.launchpad.net/ondrej/php/ubuntu bionic/main amd64 Packages [45.2 kB]
Get:15 http://ppa.launchpad.net/ondrej/php/ubuntu bionic/main Translation-en [22.1 kB]
Fetched 3,029 kB in 2s (1,515 kB/s)
Reading package lists... Done
root#jaimemontoya:/# apt-get update
Hit:1 http://us.archive.ubuntu.com/ubuntu bionic InRelease
Hit:2 http://ppa.launchpad.net/certbot/certbot/ubuntu bionic InRelease
Hit:3 http://archive.ubuntu.com/ubuntu bionic InRelease
Hit:4 http://us.archive.ubuntu.com/ubuntu bionic-updates InRelease
Hit:5 http://us.archive.ubuntu.com/ubuntu bionic-security InRelease
Hit:6 http://ppa.launchpad.net/ondrej/php/ubuntu bionic InRelease
Reading package lists... Done
root#jaimemontoya:/# apt-get install php7.0 php7.0-fpm php7.0-mysql -y
Reading package lists... Done
Building dependency tree
Reading state information... Done
The following additional packages will be installed:
libpcre3 php-common php7.0-cli php7.0-common php7.0-json php7.0-opcache php7.0-readline
Suggested packages:
php-pear
The following NEW packages will be installed:
php-common php7.0 php7.0-cli php7.0-common php7.0-fpm php7.0-json php7.0-mysql php7.0-opcache php7.0-readline
The following packages will be upgraded:
libpcre3
1 upgraded, 9 newly installed, 0 to remove and 40 not upgraded.
Need to get 4,047 kB of archives.
After this operation, 14.6 MB of additional disk space will be used.
Get:1 http://ppa.launchpad.net/ondrej/php/ubuntu bionic/main amd64 libpcre3 amd64 2:8.43-1+ubuntu18.04.1+deb.sury.org+1 [237 kB]
Get:2 http://ppa.launchpad.net/ondrej/php/ubuntu bionic/main amd64 php-common all 2:69+ubuntu18.04.1+deb.sury.org+2+php7.3 [15.1 kB]
Get:3 http://ppa.launchpad.net/ondrej/php/ubuntu bionic/main amd64 php7.0-common amd64 7.0.33-8+ubuntu18.04.1+deb.sury.org+1 [897 kB]
Get:4 http://ppa.launchpad.net/ondrej/php/ubuntu bionic/main amd64 php7.0-json amd64 7.0.33-8+ubuntu18.04.1+deb.sury.org+1 [17.2 kB]
Get:5 http://ppa.launchpad.net/ondrej/php/ubuntu bionic/main amd64 php7.0-opcache amd64 7.0.33-8+ubuntu18.04.1+deb.sury.org+1 [79.1 kB]
Get:6 http://ppa.launchpad.net/ondrej/php/ubuntu bionic/main amd64 php7.0-readline amd64 7.0.33-8+ubuntu18.04.1+deb.sury.org+1 [12.6 kB]
Get:7 http://ppa.launchpad.net/ondrej/php/ubuntu bionic/main amd64 php7.0-cli amd64 7.0.33-8+ubuntu18.04.1+deb.sury.org+1 [1,300 kB]
Get:8 http://ppa.launchpad.net/ondrej/php/ubuntu bionic/main amd64 php7.0-fpm amd64 7.0.33-8+ubuntu18.04.1+deb.sury.org+1 [1,307 kB]
Get:9 http://ppa.launchpad.net/ondrej/php/ubuntu bionic/main amd64 php7.0 all 7.0.33-8+ubuntu18.04.1+deb.sury.org+1 [56.3 kB]
Get:10 http://ppa.launchpad.net/ondrej/php/ubuntu bionic/main amd64 php7.0-mysql amd64 7.0.33-8+ubuntu18.04.1+deb.sury.org+1 [125 kB]
Fetched 4,047 kB in 4s (916 kB/s)
(Reading database ... 169946 files and directories currently installed.)
Preparing to unpack .../libpcre3_2%3a8.43-1+ubuntu18.04.1+deb.sury.org+1_amd64.deb ...
Unpacking libpcre3:amd64 (2:8.43-1+ubuntu18.04.1+deb.sury.org+1) over (2:8.39-9) ...
Setting up libpcre3:amd64 (2:8.43-1+ubuntu18.04.1+deb.sury.org+1) ...
Selecting previously unselected package php-common.
(Reading database ... 169946 files and directories currently installed.)
Preparing to unpack .../0-php-common_2%3a69+ubuntu18.04.1+deb.sury.org+2+php7.3_all.deb ...
Unpacking php-common (2:69+ubuntu18.04.1+deb.sury.org+2+php7.3) ...
Selecting previously unselected package php7.0-common.
Preparing to unpack .../1-php7.0-common_7.0.33-8+ubuntu18.04.1+deb.sury.org+1_amd64.deb ...
Unpacking php7.0-common (7.0.33-8+ubuntu18.04.1+deb.sury.org+1) ...
Selecting previously unselected package php7.0-json.
Preparing to unpack .../2-php7.0-json_7.0.33-8+ubuntu18.04.1+deb.sury.org+1_amd64.deb ...
Unpacking php7.0-json (7.0.33-8+ubuntu18.04.1+deb.sury.org+1) ...
Selecting previously unselected package php7.0-opcache.
Preparing to unpack .../3-php7.0-opcache_7.0.33-8+ubuntu18.04.1+deb.sury.org+1_amd64.deb ...
Unpacking php7.0-opcache (7.0.33-8+ubuntu18.04.1+deb.sury.org+1) ...
Selecting previously unselected package php7.0-readline.
Preparing to unpack .../4-php7.0-readline_7.0.33-8+ubuntu18.04.1+deb.sury.org+1_amd64.deb ...
Unpacking php7.0-readline (7.0.33-8+ubuntu18.04.1+deb.sury.org+1) ...
Selecting previously unselected package php7.0-cli.
Preparing to unpack .../5-php7.0-cli_7.0.33-8+ubuntu18.04.1+deb.sury.org+1_amd64.deb ...
Unpacking php7.0-cli (7.0.33-8+ubuntu18.04.1+deb.sury.org+1) ...
Selecting previously unselected package php7.0-fpm.
Preparing to unpack .../6-php7.0-fpm_7.0.33-8+ubuntu18.04.1+deb.sury.org+1_amd64.deb ...
Unpacking php7.0-fpm (7.0.33-8+ubuntu18.04.1+deb.sury.org+1) ...
Selecting previously unselected package php7.0.
Preparing to unpack .../7-php7.0_7.0.33-8+ubuntu18.04.1+deb.sury.org+1_all.deb ...
Unpacking php7.0 (7.0.33-8+ubuntu18.04.1+deb.sury.org+1) ...
Selecting previously unselected package php7.0-mysql.
Preparing to unpack .../8-php7.0-mysql_7.0.33-8+ubuntu18.04.1+deb.sury.org+1_amd64.deb ...
Unpacking php7.0-mysql (7.0.33-8+ubuntu18.04.1+deb.sury.org+1) ...
Processing triggers for ureadahead (0.100.0-21) ...
Processing triggers for libc-bin (2.27-3ubuntu1) ...
Setting up php-common (2:69+ubuntu18.04.1+deb.sury.org+2+php7.3) ...
Created symlink /etc/systemd/system/timers.target.wants/phpsessionclean.timer → /lib/systemd/system/phpsessionclean.timer.
Processing triggers for systemd (237-3ubuntu10.22) ...
Processing triggers for man-db (2.8.3-2ubuntu0.1) ...
Setting up php7.0-common (7.0.33-8+ubuntu18.04.1+deb.sury.org+1) ...
Creating config file /etc/php/7.0/mods-available/calendar.ini with new version
Creating config file /etc/php/7.0/mods-available/ctype.ini with new version
Creating config file /etc/php/7.0/mods-available/exif.ini with new version
Creating config file /etc/php/7.0/mods-available/fileinfo.ini with new version
Creating config file /etc/php/7.0/mods-available/ftp.ini with new version
Creating config file /etc/php/7.0/mods-available/gettext.ini with new version
Creating config file /etc/php/7.0/mods-available/iconv.ini with new version
Creating config file /etc/php/7.0/mods-available/pdo.ini with new version
Creating config file /etc/php/7.0/mods-available/phar.ini with new version
Creating config file /etc/php/7.0/mods-available/posix.ini with new version
Creating config file /etc/php/7.0/mods-available/shmop.ini with new version
Creating config file /etc/php/7.0/mods-available/sockets.ini with new version
Creating config file /etc/php/7.0/mods-available/sysvmsg.ini with new version
Creating config file /etc/php/7.0/mods-available/sysvsem.ini with new version
Creating config file /etc/php/7.0/mods-available/sysvshm.ini with new version
Creating config file /etc/php/7.0/mods-available/tokenizer.ini with new version
Setting up php7.0-mysql (7.0.33-8+ubuntu18.04.1+deb.sury.org+1) ...
Creating config file /etc/php/7.0/mods-available/mysqlnd.ini with new version
Creating config file /etc/php/7.0/mods-available/mysqli.ini with new version
Creating config file /etc/php/7.0/mods-available/pdo_mysql.ini with new version
Setting up php7.0-readline (7.0.33-8+ubuntu18.04.1+deb.sury.org+1) ...
Creating config file /etc/php/7.0/mods-available/readline.ini with new version
Setting up php7.0-opcache (7.0.33-8+ubuntu18.04.1+deb.sury.org+1) ...
Creating config file /etc/php/7.0/mods-available/opcache.ini with new version
Setting up php7.0-json (7.0.33-8+ubuntu18.04.1+deb.sury.org+1) ...
Creating config file /etc/php/7.0/mods-available/json.ini with new version
Setting up php7.0-cli (7.0.33-8+ubuntu18.04.1+deb.sury.org+1) ...
update-alternatives: using /usr/bin/php7.0 to provide /usr/bin/php (php) in auto mode
update-alternatives: using /usr/bin/phar7.0 to provide /usr/bin/phar (phar) in auto mode
update-alternatives: using /usr/bin/phar.phar7.0 to provide /usr/bin/phar.phar (phar.phar) in auto mode
Creating config file /etc/php/7.0/cli/php.ini with new version
Setting up php7.0-fpm (7.0.33-8+ubuntu18.04.1+deb.sury.org+1) ...
Creating config file /etc/php/7.0/fpm/php.ini with new version
NOTICE: Not enabling PHP 7.0 FPM by default.
NOTICE: To enable PHP 7.0 FPM in Apache2 do:
NOTICE: a2enmod proxy_fcgi setenvif
NOTICE: a2enconf php7.0-fpm
NOTICE: You are seeing this message because you have apache2 package installed.
Created symlink /etc/systemd/system/multi-user.target.wants/php7.0-fpm.service → /lib/systemd/system/php7.0-fpm.service.
Setting up php7.0 (7.0.33-8+ubuntu18.04.1+deb.sury.org+1) ...
Processing triggers for ureadahead (0.100.0-21) ...
Processing triggers for systemd (237-3ubuntu10.22) ...
root#jaimemontoya:/# apt-get --purge autoremove -y
Reading package lists... Done
Building dependency tree
Reading state information... Done
0 upgraded, 0 newly installed, 0 to remove and 40 not upgraded.
root#jaimemontoya:/# service php7.0-fpm start
root#jaimemontoya:/# php -v
PHP 7.0.33-8+ubuntu18.04.1+deb.sury.org+1 (cli) (built: May 31 2019 11:34:35) ( NTS )
Copyright (c) 1997-2017 The PHP Group
Zend Engine v3.0.0, Copyright (c) 1998-2017 Zend Technologies
with Zend OPcache v7.0.33-8+ubuntu18.04.1+deb.sury.org+1, Copyright (c) 1999-2017, by Zend Technologies
root#jaimemontoya:/# apt purge libapache2-mod-php7.0 libapache2-mod-php
Reading package lists... Done
Building dependency tree
Reading state information... Done
Package 'libapache2-mod-php' is not installed, so not removed
Package 'libapache2-mod-php7.0' is not installed, so not removed
0 upgraded, 0 newly installed, 0 to remove and 40 not upgraded.
root#jaimemontoya:/# apt install libapache2-mod-php7.0 libapache2-mod-php
Reading package lists... Done
Building dependency tree
Reading state information... Done
The following additional packages will be installed:
libapache2-mod-php7.3 libpcre2-8-0 libsodium23 php7.3-cli php7.3-common php7.3-json php7.3-opcache php7.3-readline
Suggested packages:
php-pear
The following NEW packages will be installed:
libapache2-mod-php libapache2-mod-php7.0 libapache2-mod-php7.3 libpcre2-8-0 libsodium23 php7.3-cli php7.3-common php7.3-json php7.3-opcache php7.3-readline
0 upgraded, 10 newly installed, 0 to remove and 40 not upgraded.
Need to get 5,439 kB of archives.
After this operation, 22.3 MB of additional disk space will be used.
Do you want to continue? [Y/n] Y
Get:1 http://ppa.launchpad.net/ondrej/php/ubuntu bionic/main amd64 php7.3-common amd64 7.3.7-2+ubuntu18.04.1+deb.sury.org+1 [938 kB]
Get:2 http://ppa.launchpad.net/ondrej/php/ubuntu bionic/main amd64 php7.3-json amd64 7.3.7-2+ubuntu18.04.1+deb.sury.org+1 [18.4 kB]
Get:3 http://ppa.launchpad.net/ondrej/php/ubuntu bionic/main amd64 php7.3-opcache amd64 7.3.7-2+ubuntu18.04.1+deb.sury.org+1 [182 kB]
Get:4 http://ppa.launchpad.net/ondrej/php/ubuntu bionic/main amd64 php7.3-readline amd64 7.3.7-2+ubuntu18.04.1+deb.sury.org+1 [12.0 kB]
Get:5 http://ppa.launchpad.net/ondrej/php/ubuntu bionic/main amd64 libpcre2-8-0 amd64 10.33-1+ubuntu18.04.1+deb.sury.org+1 [191 kB]
Get:6 http://ppa.launchpad.net/ondrej/php/ubuntu bionic/main amd64 libsodium23 amd64 1.0.17-0.1+ubuntu18.04.1+deb.sury.org+1 [147 kB]
Get:7 http://ppa.launchpad.net/ondrej/php/ubuntu bionic/main amd64 php7.3-cli amd64 7.3.7-2+ubuntu18.04.1+deb.sury.org+1 [1,378 kB]
Get:8 http://ppa.launchpad.net/ondrej/php/ubuntu bionic/main amd64 libapache2-mod-php7.3 amd64 7.3.7-2+ubuntu18.04.1+deb.sury.org+1 [1,324 kB]
Get:9 http://ppa.launchpad.net/ondrej/php/ubuntu bionic/main amd64 libapache2-mod-php all 2:7.3+69+ubuntu18.04.1+deb.sury.org+2+php7.3 [6,244 B]
Get:10 http://ppa.launchpad.net/ondrej/php/ubuntu bionic/main amd64 libapache2-mod-php7.0 amd64 7.0.33-8+ubuntu18.04.1+deb.sury.org+1 [1,242 kB]
Fetched 5,439 kB in 5s (1,094 kB/s)
Selecting previously unselected package php7.3-common.
(Reading database ... 170110 files and directories currently installed.)
Preparing to unpack .../0-php7.3-common_7.3.7-2+ubuntu18.04.1+deb.sury.org+1_amd64.deb ...
Unpacking php7.3-common (7.3.7-2+ubuntu18.04.1+deb.sury.org+1) ...
Selecting previously unselected package php7.3-json.
Preparing to unpack .../1-php7.3-json_7.3.7-2+ubuntu18.04.1+deb.sury.org+1_amd64.deb ...
Unpacking php7.3-json (7.3.7-2+ubuntu18.04.1+deb.sury.org+1) ...
Selecting previously unselected package php7.3-opcache.
Preparing to unpack .../2-php7.3-opcache_7.3.7-2+ubuntu18.04.1+deb.sury.org+1_amd64.deb ...
Unpacking php7.3-opcache (7.3.7-2+ubuntu18.04.1+deb.sury.org+1) ...
Selecting previously unselected package php7.3-readline.
Preparing to unpack .../3-php7.3-readline_7.3.7-2+ubuntu18.04.1+deb.sury.org+1_amd64.deb ...
Unpacking php7.3-readline (7.3.7-2+ubuntu18.04.1+deb.sury.org+1) ...
Selecting previously unselected package libpcre2-8-0:amd64.
Preparing to unpack .../4-libpcre2-8-0_10.33-1+ubuntu18.04.1+deb.sury.org+1_amd64.deb ...
Unpacking libpcre2-8-0:amd64 (10.33-1+ubuntu18.04.1+deb.sury.org+1) ...
Selecting previously unselected package libsodium23:amd64.
Preparing to unpack .../5-libsodium23_1.0.17-0.1+ubuntu18.04.1+deb.sury.org+1_amd64.deb ...
Unpacking libsodium23:amd64 (1.0.17-0.1+ubuntu18.04.1+deb.sury.org+1) ...
Selecting previously unselected package php7.3-cli.
Preparing to unpack .../6-php7.3-cli_7.3.7-2+ubuntu18.04.1+deb.sury.org+1_amd64.deb ...
Unpacking php7.3-cli (7.3.7-2+ubuntu18.04.1+deb.sury.org+1) ...
Selecting previously unselected package libapache2-mod-php7.3.
Preparing to unpack .../7-libapache2-mod-php7.3_7.3.7-2+ubuntu18.04.1+deb.sury.org+1_amd64.deb ...
Unpacking libapache2-mod-php7.3 (7.3.7-2+ubuntu18.04.1+deb.sury.org+1) ...
Selecting previously unselected package libapache2-mod-php.
Preparing to unpack .../8-libapache2-mod-php_2%3a7.3+69+ubuntu18.04.1+deb.sury.org+2+php7.3_all.deb ...
Unpacking libapache2-mod-php (2:7.3+69+ubuntu18.04.1+deb.sury.org+2+php7.3) ...
Selecting previously unselected package libapache2-mod-php7.0.
Preparing to unpack .../9-libapache2-mod-php7.0_7.0.33-8+ubuntu18.04.1+deb.sury.org+1_amd64.deb ...
Unpacking libapache2-mod-php7.0 (7.0.33-8+ubuntu18.04.1+deb.sury.org+1) ...
Setting up php7.3-common (7.3.7-2+ubuntu18.04.1+deb.sury.org+1) ...
Creating config file /etc/php/7.3/mods-available/calendar.ini with new version
Creating config file /etc/php/7.3/mods-available/ctype.ini with new version
Creating config file /etc/php/7.3/mods-available/exif.ini with new version
Creating config file /etc/php/7.3/mods-available/fileinfo.ini with new version
Creating config file /etc/php/7.3/mods-available/ftp.ini with new version
Creating config file /etc/php/7.3/mods-available/gettext.ini with new version
Creating config file /etc/php/7.3/mods-available/iconv.ini with new version
Creating config file /etc/php/7.3/mods-available/pdo.ini with new version
Creating config file /etc/php/7.3/mods-available/phar.ini with new version
Creating config file /etc/php/7.3/mods-available/posix.ini with new version
Creating config file /etc/php/7.3/mods-available/shmop.ini with new version
Creating config file /etc/php/7.3/mods-available/sockets.ini with new version
Creating config file /etc/php/7.3/mods-available/sysvmsg.ini with new version
Creating config file /etc/php/7.3/mods-available/sysvsem.ini with new version
Creating config file /etc/php/7.3/mods-available/sysvshm.ini with new version
Creating config file /etc/php/7.3/mods-available/tokenizer.ini with new version
Setting up libapache2-mod-php7.0 (7.0.33-8+ubuntu18.04.1+deb.sury.org+1) ...
Creating config file /etc/php/7.0/apache2/php.ini with new version
Module mpm_event disabled.
Enabling module mpm_prefork.
apache2_switch_mpm Switch to prefork
apache2_invoke: Enable module php7.0
Setting up php7.3-opcache (7.3.7-2+ubuntu18.04.1+deb.sury.org+1) ...
Creating config file /etc/php/7.3/mods-available/opcache.ini with new version
Setting up libsodium23:amd64 (1.0.17-0.1+ubuntu18.04.1+deb.sury.org+1) ...
Processing triggers for libc-bin (2.27-3ubuntu1) ...
Processing triggers for man-db (2.8.3-2ubuntu0.1) ...
Setting up php7.3-readline (7.3.7-2+ubuntu18.04.1+deb.sury.org+1) ...
Creating config file /etc/php/7.3/mods-available/readline.ini with new version
Setting up libpcre2-8-0:amd64 (10.33-1+ubuntu18.04.1+deb.sury.org+1) ...
Setting up php7.3-json (7.3.7-2+ubuntu18.04.1+deb.sury.org+1) ...
Creating config file /etc/php/7.3/mods-available/json.ini with new version
Setting up php7.3-cli (7.3.7-2+ubuntu18.04.1+deb.sury.org+1) ...
update-alternatives: using /usr/bin/php7.3 to provide /usr/bin/php (php) in auto mode
update-alternatives: using /usr/bin/phar7.3 to provide /usr/bin/phar (phar) in auto mode
update-alternatives: using /usr/bin/phar.phar7.3 to provide /usr/bin/phar.phar (phar.phar) in auto mode
Creating config file /etc/php/7.3/cli/php.ini with new version
Setting up libapache2-mod-php7.3 (7.3.7-2+ubuntu18.04.1+deb.sury.org+1) ...
Creating config file /etc/php/7.3/apache2/php.ini with new version
libapache2-mod-php7.3: php7.0 module already enabled, not enabling PHP 7.3
Setting up libapache2-mod-php (2:7.3+69+ubuntu18.04.1+deb.sury.org+2+php7.3) ...
Processing triggers for libc-bin (2.27-3ubuntu1) ...
root#jaimemontoya:/#
UPDATE 1:
As you requested it k0pernikus, literally how it was published in Chapter 1 of Learning PHP 7, by Antonio Lopez, published by Packt Publishing:
Installing PHP
The only thing to consider in this section is to remove any previous
PHP versions on your system. To do so, you can run the following
command:
$ sudo apt-get -y purge php.*
The next step is to add the necessary repositories in order to fetch
the correct PHP version. The commands to add and update them are:
$ sudo apt-get install python-software-properties
$ sudo LC_ALL=en_US.UTF-8 add-apt-repository ppa:ondrej/php -y
$ sudo apt-get update
Finally, we need to install PHP 7 together with the driver for MySQL.
For this, just execute the following three commands:
$ sudo apt-get install php7.0 php7.0-fpm php7.0-mysql -y
$ sudo apt-get --purge autoremove -y
$ sudo apt-get --purge autoremove -y
$ sudo service php7.0-fpm start