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
  • Ubuntu
    • Ubuntu 20.04.2 LTS
      • cat /etc/issue
  • 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
      • 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

          • To start Apache
        • PHP-FPM
          • apt update
          • apt install php8.0-fpm libapache2-mod-fcgid
          • a2enmod proxy_fcgi setenvif
          • a2enconf php8.0-fpm
          • service apache2 restart
      • 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 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
  • Visual Studio Code
⚠️ **GitHub.com Fallback** ⚠️