他是寂寥岁月里的一盏暖灯 發表於 2021-4-3 21:49:00

在 Ubuntu/Debian 下安装 PHP7.3 教程

<h3>Ubuntu</h3>
<p>安装软件源拓展工具:</p>
<pre name="code" class="has"><code class="hljs sql">apt -y <span class="hljs-keyword">install software-properties-common apt-transport-https lsb-<span class="hljs-keyword">release ca-certificates</span></span></code></pre>
<p>添加 Ondřej Surý 的 PHP PPA 源,需要按一次回车:</p>
<pre name="code" class="has"><code class="hljs groovy">add-apt-repository <span class="hljs-attr">ppa:ondrej/php</span></code></pre>
<p>更新软件源缓存:</p>
<pre name="code" class="has"><code class="hljs sql">apt <span class="hljs-keyword">update</span></code></pre>
<h3>Debian</h3>
<p>安装软件源拓展工具:</p>
<pre name="code" class="has"><code class="hljs sql">apt -y <span class="hljs-keyword">install software-properties-common apt-transport-https lsb-<span class="hljs-keyword">release ca-certificates</span></span></code></pre>
<p>添加 GPG</p>
<pre name="code" class="has"><code class="hljs groovy">wget -O <span class="hljs-regexp">/etc/apt<span class="hljs-regexp">/trusted.gpg.d/php.gpg <span class="hljs-attr">https:<span class="hljs-comment">//mirror.xtom.com.hk/sury/php/apt.gpg</span></span></span></span></code></pre>
<p>添加 sury 软件源</p>
<pre name="code" class="has"><code class="hljs nginx"><span class="hljs-attribute">sh -c <span class="hljs-string">'echo "deb https://mirror.xtom.com.hk/sury/php/ $(lsb_release -sc) main" &gt; /etc/apt/sources.list.d/php.list'   </span></span></code></pre>
<p>更新软件源缓存:</p>
<pre name="code" class="has"><code class="hljs sql">apt-get <span class="hljs-keyword">update</span></code></pre>
<h2>安装软件</h2>
<p>安装 PHP7.3:</p>
<pre name="code" class="has"><code class="hljs apache"><span class="hljs-attribute">apt install php<span class="hljs-number">7.<span class="hljs-number">3-fpm php<span class="hljs-number">7.<span class="hljs-number">3-mysql php<span class="hljs-number">7.<span class="hljs-number">3-curl php<span class="hljs-number">7.<span class="hljs-number">3-gd php<span class="hljs-number">7.<span class="hljs-number">3-mbstring php<span class="hljs-number">7.<span class="hljs-number">3-xml php<span class="hljs-number">7.<span class="hljs-number">3-xmlrpc php<span class="hljs-number">7.<span class="hljs-number">3-zip php<span class="hljs-number">7.<span class="hljs-number">3-opcache -y
</span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></code></pre>
<h2>设置 PHP</h2>
<p>安装完成后,编辑&nbsp;<code>/etc/php/7.3/fpm/php.ini</code>&nbsp;替换换&nbsp;<code>;cgi.fix_pathinfo=1</code>&nbsp;为&nbsp;<code>cgi.fix_pathinfo=0</code>&nbsp;快捷命令:</p>
<pre name="code" class="has"><code class="hljs apache"><span class="hljs-attribute">sed -i 's/;cgi.fix_pathinfo=<span class="hljs-number">1/cgi.fix_pathinfo=<span class="hljs-number">0/' /etc/php/<span class="hljs-number">7.<span class="hljs-number">3/fpm/php.ini </span></span></span></span></span></code></pre>
<h2>管理 PHP</h2>
<p>安装好了先重启一下!</p>
<pre name="code" class="has"><code class="hljs apache"><span class="hljs-attribute">systemctl restart php<span class="hljs-number">7.<span class="hljs-number">3-fpm</span></span></span></code></pre>
<p>更多操作:</p>
<pre>&nbsp;</pre>
<div class="table-box">
<table>
<tbody>
<tr>
<td>&nbsp;</td>
<td>
<p><code>systemctl restart php7.3-fpm #重启</code></p>
</td>
</tr>
<tr>
<td>&nbsp;</td>
<td>
<p><code>systemctl start php7.3-fpm #启动</code></p>
</td>
</tr>
<tr>
<td>&nbsp;</td>
<td>
<p><code>systemctl stop php7.3-fpm #关闭</code></p>
</td>
</tr>
<tr>
<td>&nbsp;</td>
<td>
<p><code>systemctl status php7.3-fpm #检查状态</code></p>
</td>
</tr>
</tbody>
</table>
</div>
<h1>查看 PHP</h1>
<p>验证一下是否安装成功:</p>
<pre>&nbsp;</pre>
<div class="table-box">
<table>
<tbody>
<tr>
<td>&nbsp;</td>
<td>
<p><code>root@mf88.biz-service:~# php -v</code></p>
</td>
</tr>
<tr>
<td>&nbsp;</td>
<td>
<p><code>PHP 7.3.0-1+ubuntu18.04.1+deb.sury.org+1 (cli) (built: Dec 6 2018 20:24:55) ( NTS )</code></p>
</td>
</tr>
<tr>
<td>&nbsp;</td>
<td>
<p><code>Copyright (c) 1997-2018 The PHP Group</code></p>
</td>
</tr>
<tr>
<td>&nbsp;</td>
<td>
<p><code>Zend Engine v3.3.0-dev, Copyright (c) 1998-2018 Zend Technologies</code></p>
</td>
</tr>
<tr>
<td>&nbsp;</td>
<td>
<p><code>with Zend OPcache v7.3.0-1+ubuntu18.04.1+deb.sury.org+1, Copyright (c) 1999-2018, by Zend Technologies</code></p>
</td>
</tr>
</tbody>
</table>
</div>
<h2>更新 PHP</h2>
<p>运行下面的命令系统就会更新所有可以更新的软件包括 PHP</p>
<pre>&nbsp;</pre>
<div class="table-box">
<table>
<tbody>
<tr>
<td>&nbsp;</td>
<td>
<p><code>apt update</code></p>
</td>
</tr>
<tr>
<td>&nbsp;</td>
<td>
<p><code>apt upgrade -y</code></p>
</td>
</tr>
</tbody>
</table>
</div>
<h2>安装更多组件</h2>
<p>上面的一条命令安装 PHP 只是安装了部分 PHP 拓展,更多的软件可见:</p>
<pre>&nbsp;</pre>
<div class="table-box">
<table>
<tbody>
<tr>
<td>&nbsp;</td>
<td>
<p><code>root@mf88.biz-service:~# apt-cache search php7.3</code></p>
</td>
</tr>
<tr>
<td>&nbsp;</td>
<td>
<p><code>php-amqp - AMQP extension for PHP</code></p>
</td>
</tr>
<tr>
<td>&nbsp;</td>
<td>
<p><code>php-apcu - APC User Cache for PHP</code></p>
</td>
</tr>
<tr>
<td>&nbsp;</td>
<td>
<p><code>php-apcu-bc - APCu Backwards Compatibility Module</code></p>
</td>
</tr>
<tr>
<td>&nbsp;</td>
<td>
<p><code>php-ds - PHP extension providing efficient data structures for PHP 7</code></p>
</td>
</tr>
<tr>
<td>&nbsp;</td>
<td>
<p><code>php-gearman - PHP wrapper to libgearman</code></p>
</td>
</tr>
<tr>
<td>&nbsp;</td>
<td>
<p><code>php-geoip - GeoIP module for PHP</code></p>
</td>
</tr>
<tr>
<td>&nbsp;</td>
<td>
<p><code>php-gmagick - Provides a wrapper to the GraphicsMagick library</code></p>
</td>
</tr>
<tr>
<td>&nbsp;</td>
<td>
<p><code>php-gnupg - PHP wrapper around the gpgme library</code></p>
</td>
</tr>
<tr>
<td>&nbsp;</td>
<td>
<p><code>php-http - PECL HTTP module for PHP Extended HTTP Support</code></p>
</td>
</tr>
<tr>
<td>&nbsp;</td>
<td>
<p><code>php-igbinary - igbinary PHP serializer</code></p>
</td>
</tr>
<tr>
<td>&nbsp;</td>
<td>
<p><code>php-imagick - Provides a wrapper to the ImageMagick library</code></p>
</td>
</tr>
<tr>
<td>&nbsp;</td>
<td>
<p><code>php-mailparse - Email message manipulation for PHP</code></p>
</td>
</tr>
<tr>
<td>&nbsp;</td>
<td>
<p><code>php-memcache - memcache extension module for PHP</code></p>
</td>
</tr>
<tr>
<td>&nbsp;</td>
<td>
<p><code>php-memcached - memcached extension module for PHP, uses libmemcached</code></p>
</td>
</tr>
<tr>
<td>&nbsp;</td>
<td>
<p><code>php-mongodb - MongoDB driver for PHP</code></p>
</td>
</tr>
<tr>
<td>&nbsp;</td>
<td>
<p><code>php-msgpack - PHP extension for interfacing with MessagePack</code></p>
</td>
</tr>
<tr>
<td>&nbsp;</td>
<td>
<p><code>php-oauth - OAuth 1.0 consumer and provider extension</code></p>
</td>
</tr>
<tr>
<td>&nbsp;</td>
<td>
<p><code>php-propro - propro module for PHP</code></p>
</td>
</tr>
<tr>
<td>&nbsp;</td>
<td>
<p><code>php-radius - radius client library for PHP</code></p>
</td>
</tr>
<tr>
<td>&nbsp;</td>
<td>
<p><code>php-raphf - raphf module for PHP</code></p>
</td>
</tr>
<tr>
<td>&nbsp;</td>
<td>
<p><code>php-redis - PHP extension for interfacing with Redis</code></p>
</td>
</tr>
<tr>
<td>&nbsp;</td>
<td>
<p><code>php-rrd - PHP bindings to rrd tool system</code></p>
</td>
</tr>
<tr>
<td>&nbsp;</td>
<td>
<p><code>php-smbclient - PHP wrapper for libsmbclient</code></p>
</td>
</tr>
<tr>
<td>&nbsp;</td>
<td>
<p><code>php-solr - PHP extension for communicating with Apache Solr server</code></p>
</td>
</tr>
<tr>
<td>&nbsp;</td>
<td>
<p><code>php-ssh2 - Bindings for the libssh2 library</code></p>
</td>
</tr>
<tr>
<td>&nbsp;</td>
<td>
<p><code>php-stomp - Streaming Text Oriented Messaging Protocol (STOMP) client module for PHP</code></p>
</td>
</tr>
<tr>
<td>&nbsp;</td>
<td>
<p><code>php-tideways - Tideways PHP Profiler Extension</code></p>
</td>
</tr>
<tr>
<td>&nbsp;</td>
<td>
<p><code>php-uploadprogress - file upload progress tracking extension for PHP</code></p>
</td>
</tr>
<tr>
<td>&nbsp;</td>
<td>
<p><code>php-uuid - PHP UUID extension</code></p>
</td>
</tr>
<tr>
<td>&nbsp;</td>
<td>
<p><code>php-yac - YAC (Yet Another Cache) for PHP</code></p>
</td>
</tr>
<tr>
<td>&nbsp;</td>
<td>
<p><code>php-yaml - YAML-1.1 parser and emitter for PHP</code></p>
</td>
</tr>
<tr>
<td>&nbsp;</td>
<td>
<p><code>php-zmq - ZeroMQ messaging bindings for PHP</code></p>
</td>
</tr>
<tr>
<td>&nbsp;</td>
<td>
<p><code>php-xdebug - Xdebug Module for PHP</code></p>
</td>
</tr>
<tr>
<td>&nbsp;</td>
<td>
<p><code>php-lua - PHP Embedded lua interpreter</code></p>
</td>
</tr>
<tr>
<td>&nbsp;</td>
<td>
<p><code>libapache2-mod-php7.3 - server-side, HTML-embedded scripting language (Apache 2 module)</code></p>
</td>
</tr>
<tr>
<td>&nbsp;</td>
<td>
<p><code>libphp7.3-embed - HTML-embedded scripting language (Embedded SAPI library)</code></p>
</td>
</tr>
<tr>
<td>&nbsp;</td>
<td>
<p><code>php7.3-bcmath - Bcmath module for PHP</code></p>
</td>
</tr>
<tr>
<td>&nbsp;</td>
<td>
<p><code>php7.3-bz2 - bzip2 module for PHP</code></p>
</td>
</tr>
<tr>
<td>&nbsp;</td>
<td>
<p><code>php7.3-cgi - server-side, HTML-embedded scripting language (CGI binary)</code></p>
</td>
</tr>
<tr>
<td>&nbsp;</td>
<td>
<p><code>php7.3-cli - command-line interpreter for the PHP scripting language</code></p>
</td>
</tr>
<tr>
<td>&nbsp;</td>
<td>
<p><code>php7.3-common - documentation, examples and common module for PHP</code></p>
</td>
</tr>
<tr>
<td>&nbsp;</td>
<td>
<p><code>php7.3-curl - CURL module for PHP</code></p>
</td>
</tr>
<tr>
<td>&nbsp;</td>
<td>
<p><code>php7.3-dba - DBA module for PHP</code></p>
</td>
</tr>
<tr>
<td>&nbsp;</td>
<td>
<p><code>php7.3-dev - Files for PHP7.3 module development</code></p>
</td>
</tr>
<tr>
<td>&nbsp;</td>
<td>
<p><code>php7.3-enchant - Enchant module for PHP</code></p>
</td>
</tr>
<tr>
<td>&nbsp;</td>
<td>
<p><code>php7.3-fpm - server-side, HTML-embedded scripting language (FPM-CGI binary)</code></p>
</td>
</tr>
<tr>
<td>&nbsp;</td>
<td>
<p><code>php7.3-gd - GD module for PHP</code></p>
</td>
</tr>
<tr>
<td>&nbsp;</td>
<td>
<p><code>php7.3-gmp - GMP module for PHP</code></p>
</td>
</tr>
<tr>
<td>&nbsp;</td>
<td>
<p><code>php7.3-imap - IMAP module for PHP</code></p>
</td>
</tr>
<tr>
<td>&nbsp;</td>
<td>
<p><code>php7.3-interbase - Interbase module for PHP</code></p>
</td>
</tr>
<tr>
<td>&nbsp;</td>
<td>
<p><code>php7.3-intl - Internationalisation module for PHP</code></p>
</td>
</tr>
<tr>
<td>&nbsp;</td>
<td>
<p><code>php7.3-json - JSON module for PHP</code></p>
</td>
</tr>
<tr>
<td>&nbsp;</td>
<td>
<p><code>php7.3-ldap - LDAP module for PHP</code></p>
</td>
</tr>
<tr>
<td>&nbsp;</td>
<td>
<p><code>php7.3-mbstring - MBSTRING module for PHP</code></p>
</td>
</tr>
<tr>
<td>&nbsp;</td>
<td>
<p><code>php7.3-mysql - MySQL module for PHP</code></p>
</td>
</tr>
<tr>
<td>&nbsp;</td>
<td>
<p><code>php7.3-odbc - ODBC module for PHP</code></p>
</td>
</tr>
<tr>
<td>&nbsp;</td>
<td>
<p><code>php7.3-opcache - Zend OpCache module for PHP</code></p>
</td>
</tr>
<tr>
<td>&nbsp;</td>
<td>
<p><code>php7.3-pgsql - PostgreSQL module for PHP</code></p>
</td>
</tr>
<tr>
<td>&nbsp;</td>
<td>
<p><code>php7.3-phpdbg - server-side, HTML-embedded scripting language (PHPDBG binary)</code></p>
</td>
</tr>
<tr>
<td>&nbsp;</td>
<td>
<p><code>php7.3-pspell - pspell module for PHP</code></p>
</td>
</tr>
<tr>
<td>&nbsp;</td>
<td>
<p><code>php7.3-readline - readline module for PHP</code></p>
</td>
</tr>
<tr>
<td>&nbsp;</td>
<td>
<p><code>php7.3-recode - recode module for PHP</code></p>
</td>
</tr>
<tr>
<td>&nbsp;</td>
<td>
<p><code>php7.3-snmp - SNMP module for PHP</code></p>
</td>
</tr>
<tr>
<td>&nbsp;</td>
<td>
<p><code>php7.3-soap - SOAP module for PHP</code></p>
</td>
</tr>
<tr>
<td>&nbsp;</td>
<td>
<p><code>php7.3-sqlite3 - SQLite3 module for PHP</code></p>
</td>
</tr>
<tr>
<td>&nbsp;</td>
<td>
<p><code>php7.3-sybase - Sybase module for PHP</code></p>
</td>
</tr>
<tr>
<td>&nbsp;</td>
<td>
<p><code>php7.3-tidy - tidy module for PHP</code></p>
</td>
</tr>
<tr>
<td>&nbsp;</td>
<td>
<p><code>php7.3-xml - DOM, SimpleXML, WDDX, XML, and XSL module for PHP</code></p>
</td>
</tr>
<tr>
<td>&nbsp;</td>
<td>
<p><code>php7.3-xmlrpc - XMLRPC-EPI module for PHP</code></p>
</td>
</tr>
<tr>
<td>&nbsp;</td>
<td>
<p><code>php7.3-zip - Zip module for PHP</code></p>
</td>
</tr>
<tr>
<td>&nbsp;</td>
<td>
<p><code>php7.3-xsl - XSL module for PHP (dummy)</code></p>
</td>
</tr>
<tr>
<td>&nbsp;</td>
<td>
<p><code>php7.3 - server-side, HTML-embedded scripting language (metapackage)</code></p>
</td>
</tr>
</tbody>
</table>
</div><br><br>
来源:https://www.cnblogs.com/surplus/p/14615094.html
頁: [1]
查看完整版本: 在 Ubuntu/Debian 下安装 PHP7.3 教程