Ubuntu 16.04/18.04/19.04 以上版本安裝 PHP7.4 配置 nginx

ubuntu下默認安裝爲7.2,若要想安裝其它版本,用以下方法

Step 1: Add PHP PPA Repository

We’ll add ppa:ondrej/php PPA repository which has the latest build packages of PHP.

sudo apt-get update
sudo apt -y install software-properties-common
sudo add-apt-repository ppa:ondrej/php
sudo apt-get update

 

Step 2: Install PHP 7.4 on Ubuntu 16.04/18.04/19.04

sudo apt -y install php7.4

查看版本

$ php -v
PHP 7.4.0beta4 (cli) (built: Aug 28 2019 11:41:49) ( NTS )
Copyright (c) The PHP Group
Zend Engine v3.4.0-dev, Copyright (c) Zend Technologies
    with Zend OPcache v7.4.0beta4, Copyright (c), by Zend Technologies

用以下命令安裝必要的組件

sudo apt-get install php7.4-xxx

例如:

sudo apt-get install -y php7.4-{bcmath,bz2,intl,gd,mbstring,mysql,zip}

 

 

nginx中配置php7.4

爲nginx安裝php-fpm擴展包

sudo apt-get install nginx php7.4-fpm

Nginx 和 fpm services 應該已經開始運行

$ systemctl status php7.4-fpm nginx
● php7.4-fpm.service - The PHP 7.4 FastCGI Process Manager
   Loaded: loaded (/lib/systemd/system/php7.4-fpm.service; enabled; vendor preset: enabled)
   Active: active (running) since Mon 2019-09-16 17:09:41 UTC; 27s ago
     Docs: man:php-fpm7.4(8)
 Main PID: 25321 (php-fpm7.4)
   Status: "Processes active: 0, idle: 2, Requests: 0, slow: 0, Traffic: 0req/sec"
    Tasks: 3 (limit: 2362)
   CGroup: /system.slice/php7.4-fpm.service
           ├─25321 php-fpm: master process (/etc/php/7.4/fpm/php-fpm.conf)
           ├─25339 php-fpm: pool www
           └─25340 php-fpm: pool www

Sep 16 17:09:41 ubuntu18 systemd[1]: Starting The PHP 7.4 FastCGI Process Manager...
Sep 16 17:09:41 ubuntu18 systemd[1]: Started The PHP 7.4 FastCGI Process Manager.

● nginx.service - A high performance web server and a reverse proxy server
    Loaded: loaded (/lib/systemd/system/nginx.service; enabled; vendor preset: enabled)
    Active: active (running) since Mon 2019-09-16 17:09:42 UTC; 6min ago
      Docs: man:nginx(8)
  Main PID: 25441 (nginx)
     Tasks: 2 (limit: 2362)
    CGroup: /system.slice/nginx.service
            ├─25441 nginx: master process /usr/sbin/nginx -g daemon on; master_process on;
            └─25442 nginx: worker process
 Sep 16 17:09:42 ubuntu18 systemd[1]: Starting A high performance web server and a reverse proxy server…
 Sep 16 17:09:42 ubuntu18 systemd[1]: nginx.service: Failed to parse PID from file /run/nginx.pid: Invalid argument
 Sep 16 17:09:42 ubuntu18 systemd[1]: Started A high performance web server and a reverse proxy server.

 

PHP FPM configuration 文件路徑 /etc/php/7.4/fpm/pool.d/www.conf.

原文鏈接:https://computingforgeeks.com/how-to-install-php-on-ubuntu/

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章