Crawling with PHP8 and Ubuntu 20.04 - kylessukaichang/kylessukaichang.github.io GitHub Wiki
- Reference
- Host OS
- Ubuntu 20.04.2 LTS
- Docker
- Server Version: 20.10.8
docker info
- Server Version: 20.10.8
- Ubuntu
- Ubuntu 20.04.2 LTS
cat /etc/issue
- Ubuntu 20.04.2 LTS
- PHP
-
How to Install PHP 8 on Ubuntu 20.04
- Ubuntu 20.04
apt update
apt upgrade
-
apt-get install -y [package-name]
- unzip
- curl
- apt-transport-https
- apt-utils
- git-core
- libcurl3-openssl-dev
- PHP 8
-
ondrej/php PPA repository
-
Fix ‘add-apt-repository command not found’ Error on Ubuntu and Debian
-
apt-get install software-properties-common
-
E: Unable to locate package software-properties-common
apt-get update
-
add-apt-repository ppa:ondrej/php
-
-
Fix ‘add-apt-repository command not found’ Error on Ubuntu and Debian
-
ondrej/php PPA repository
- Apache
- PHP as an Apache module
- To install PHP
apt update
apt upgrade
apt install php8.0 libapache2-mod-php8.0
- To install Apache
-
apt install apache2
-
apache2 set to manually installed.
-
E: Unable to locate package apache2
-
How to install apache2 in Ubuntu
apt-get update
apt-get upgrade
apt-get install apache2
-
How to install apache2 in Ubuntu
-
-
- To start Apache
- Differences between SysVinit, Upstart and Systemd
-
systemctl enable apache2
-
Synchronizing state of apache2.service with SysV service script with /lib/systemd/systemd-sysv-install.
Executing: /lib/systemd/systemd-sysv-install enable apache2-
systemctl start apache2
-
System has not been booted with systemd as init system (PID 1). Can't operate. Failed to connect to bus: Host is down
- Ubuntu – systemctl failed to connect to bus – docker ubuntu:16.04 container
-
The problem now is that your init process PID 1 is /bin/bash, not systemd. Confirm with
ps aux
.
-
-
-
bash: systemctl: command not found
-
Fix: Systemctl Command not Found
- outdated versions of Linux operating systems
- not support Systemd
- using
- SysV init
- Upstart
-
service apache2 start
-
AH00558: apache2: Could not reliably determine the server's fully qualified domain name, using 172.17.0.2. Set the 'ServerName' directive globally to suppress this message
echo "ServerName localhost" >> /etc/apache2/apache2.conf
- Docker PHP-APACHE container set the ServerName directive globally
FROM php:7.0-apache
COPY . /var/www/html/
EXPOSE 80
RUN echo "ServerName localhost" >> /etc/apache2/apache2.conf
CMD ["/usr/sbin/apache2ctl", "-D", "FOREGROUND"]
- Dockerfile reference
- outdated versions of Linux operating systems
-
Fix: Systemctl Command not Found
-
- To install PHP
- PHP-FPM
apt update
apt install php8.0-fpm libapache2-mod-fcgid
a2enmod proxy_fcgi setenvif
a2enconf php8.0-fpm
service apache2 restart
- PHP as an Apache module
- Nginx
-
Installing PHP 8.0 with Nginx
apt update
apt install php8.0-fpm
service php8.0-fpm status
-
Installing Nginx
apt update
apt install nginx
-
Creating a Server Block
-
On Ubuntu systems, Nginx server block configuration files are located in /etc/nginx/sites-available directory.
server {
# . . . other code
location ~ .php$ {
include snippets/fastcgi-php.conf;
fastcgi_pass unix:/var/run/php/php8.0-fpm.sock;
}
}
-
They can be enabled by creating symbolic links to the /etc/nginx/sites-enabled directory, which Nginx read during the startup.
-
-
Installing PHP 8.0 with Nginx
-
Installing PHP extensions
-
apt install php8.0-[extname]
- php8.0-common
- php8.0-cli
- php8.0-curl
- php8.0-xml
- php8.0-dom
- php8.0-xsl
- php8.0-json
-
Package php8.0-json is a virtual package provided by:
-
php8.0-phpdbg 8.0.9-1+ubuntu20.04.1+deb.sury.org+1
-
php8.0-fpm 8.0.9-1+ubuntu20.04.1+deb.sury.org+1
-
php8.0-cli 8.0.9-1+ubuntu20.04.1+deb.sury.org+1
-
php8.0-cgi 8.0.9-1+ubuntu20.04.1+deb.sury.org+1
-
libphp8.0-embed 8.0.9-1+ubuntu20.04.1+deb.sury.org+1
-
libapache2-mod-php8.0 8.0.9-1+ubuntu20.04.1+deb.sury.org+1
-
-
You should explicitly select one to install.
-
E: Package 'php8.0-json' has no installation candidate
-
- php8.0-mbstring
- php8.0-zip
- » Ubuntu » Packages » php8.0
-
-
Composer
- A Dependency Manager for PHP
-
pwd
- /root/
-
curl -sS https://getcomposer.org/installer | php
php ~/composer.phar require guzzlehttp/guzzle:^6.2
php ~/composer.phar require symfony/dom-crawler:^4.3
php ~/composer.phar require symfony/css-selector:^4.3
-
- /root/
- Ubuntu 20.04
-
How to Install PHP 8 on Ubuntu 20.04
- Visual Studio Code
-
Visual Studio Code Insiders
- With the upcoming January 2016 release, we are introducing a new Insiders build that installs side by side with the monthly, stable VS Code release.
-
Developing inside a Container
-
System Requirements
- Local:
- Linux:
-
Docker CE/EE 18.06+
- Docker Community Edition
- Docker Enterprise Edition
-
Docker Compose 1.21+.
- Compose is a tool for defining and running multi-container Docker applications.
- The Ubuntu snap package is not supported
-
Docker CE/EE 18.06+
- Linux:
- Containers:
- x86_64 / ARMv7l (AArch32) / ARMv8l (AArch64)
- Ubuntu 16.04+
- x86_64 / ARMv7l (AArch32) / ARMv8l (AArch64)
- Local:
-
Installation
- Install and configure Docker
- Linux:
-
- official install instructions for Docker CE/EE for your distribution
-
Install Docker Engine on Ubuntu
- OS requirements
- Uninstall old versions
- Supported storage drivers
- Installation methods
- Install using the repository
- Set up the repository
- Install Docker Engine
- Upgrade Docker Engine
- Install using the repository
-
Install Docker Engine on Ubuntu
- Docker Compose directions
- Introduction
- a tool for defining and running multi-container Docker applications.
- to use a YAML file to configure your application’s services.
- with a single command, you create and start all the services from your configuration.
-
Install Docker Compose
- Prerequisites
- On Linux systems, to install Docker Compose after installing Docker.
- Install Compose
- Install Compose on Linux systems
- Docker Compose binary
-
Compose repository release page on GitHub
-
sudo curl -L "https://github.com/docker/compose/releases/download/1.29.2/docker-compose-$(uname -s)-$(uname -m)" -o /usr/local/bin/docker-compose
- substitute 1.29.2 with the version of Compose you want to use.
sudo chmod +x /usr/local/bin/docker-compose
-
docker-compose --version
-
docker-compose version 1.29.2, build 5becea4c
-
-
Compose repository release page on GitHub
- Docker Compose binary
- Install Compose on Linux systems
-
Alternative install options
- pip Python package manager
- installing Compose as a container.
- Upgrading
- as of version 1.3, Compose uses Docker labels to keep track of containers, and your containers need to be recreated to add the labels.
docker-compose migrate-to-labels
- as of version 1.3, Compose uses Docker labels to keep track of containers, and your containers need to be recreated to add the labels.
- Uninstallation
sudo rm /usr/local/bin/docker-compose
- Prerequisites
- Introduction
- official install instructions for Docker CE/EE for your distribution
sudo usermod -aG docker $USER
- Sign out and back in again so your changes take effect.
-
- Linux:
- Install Visual Studio Code
- Install the Remote Development extension pack.
- Install and configure Docker
-
Working with Git
- to set up consistent line endings
- tips and tricks
- Sharing Git credentials with your container
- Git credential manager
- SSH keys
- to set up consistent line endings
-
Working with Containers
- Remote - Containers extension
- full-time development environment
- attach to a running container
- Remote - Containers extension
-
System Requirements
- Remote development in Containers
-
Visual Studio Code Insiders