ubuntu安装PHP环境

  1. 1. 安装软件源拓展
  2. 2. 安装软件
  3. 3. php-fpm管理
  4. 4. 其他php组件

适用系统:Ubuntu 16.04/14.04/18.04 LTS

1. 安装软件源拓展

安装软件源拓展工具:

apt -y install software-properties-common

添加 PHP PPA 源,需要按一次回车:

add-apt-repository ppa:ondrej/php  

更新软件源缓存:

apt update

2. 安装软件

安装 PHP7.1:

apt install php7.1-fpm php7.1-mysql php7.1-curl php7.1-gd php7.1-mbstring php7.1-mcrypt php7.1-xml php7.1-xmlrpc php7.1-zip php7.1-opcache -y

安装 PHP7.0:

apt install php7.0-fpm php7.0-mysql php7.0-curl php7.0-gd php7.0-mbstring php7.0-mcrypt php7.0-xml php7.0-xmlrpc php7.0-zip php7.0-opcache -y

安装 PHP5.6:

apt install php5.6-fpm php5.6-mysql php5.6-curl php5.6-gd php5.6-mbstring php5.6-mcrypt php5.6-xml php5.6-xmlrpc php5.6-zip php5.6-opcache -y

3. php-fpm管理

systemctl restart php7.1-fpm #重启
systemctl start php7.1-fpm #启动
systemctl stop php7.1-fpm #关闭
systemctl status php7.1-fpm #检查状态
#或者
service php7.1-fpm start
service php7.1-fpm stop
service php7.1-fpm restart
service php7.1-fpm status

查看当前 PHP 版本:

# php -v
PHP 7.1.33-1+ubuntu18.04.1+deb.sury.org+1 (cli) (built: Oct 26 2019 19:29:18) ( NTS )
Copyright (c) 1997-2018 The PHP Group
Zend Engine v3.1.0, Copyright (c) 1998-2018 Zend Technologies
    with Zend OPcache v7.1.33-1+ubuntu18.04.1+deb.sury.org+1, Copyright (c) 1999-2018, by Zend Technologies

4. 其他php组件

上面的一条命令安装 PHP 只是安装了部分 PHP 拓展,更多的软件可见:

# apt-cache search php7.1

libapache2-mod-php7.1 - server-side, HTML-embedded scripting language (Apache 2 module)
php-all-dev - package depending on all supported PHP development packages
php7.1 - server-side, HTML-embedded scripting language (metapackage)
php7.1-cgi - server-side, HTML-embedded scripting language (CGI binary)
php7.1-cli - command-line interpreter for the PHP scripting language
php7.1-common - documentation, examples and common module for PHP
php7.1-curl - CURL module for PHP
php7.1-dev - Files for php7.1 module development
php7.1-gd - GD module for PHP
php7.1-gmp - GMP module for PHP
php7.1-json - JSON module for PHP
php7.1-ldap - LDAP module for PHP
php7.1-mysql - MySQL module for PHP
php7.1-odbc - ODBC module for PHP
php7.1-opcache - Zend OpCache module for PHP
php7.1-pgsql - PostgreSQL module for PHP
php7.1-pspell - pspell module for PHP
php7.1-readline - readline module for PHP
php7.1-recode - recode module for PHP
php7.1-snmp - SNMP module for PHP
php7.1-sqlite3 - SQLite3 module for PHP
php7.1-tidy - tidy module for PHP
php7.1-xml - DOM, SimpleXML, WDDX, XML, and XSL module for PHP
php7.1-xmlrpc - XMLRPC-EPI module for PHP
libphp7.1-embed - HTML-embedded scripting language (Embedded SAPI library)
php7.1-bcmath - Bcmath module for PHP
php7.1-bz2 - bzip2 module for PHP
php7.1-enchant - Enchant module for PHP
php7.1-fpm - server-side, HTML-embedded scripting language (FPM-CGI binary)
php7.1-imap - IMAP module for PHP
php7.1-interbase - Interbase module for PHP
php7.1-intl - Internationalisation module for PHP
php7.1-mbstring - MBSTRING module for PHP
php7.1-mcrypt - libmcrypt module for PHP
php7.1-phpdbg - server-side, HTML-embedded scripting language (PHPDBG binary)
php7.1-soap - SOAP module for PHP
php7.1-sybase - Sybase module for PHP
php7.1-xsl - XSL module for PHP (dummy)
php7.1-zip - Zip module for PHP
php7.1-dba - DBA module for PHP

转载请注明来源,欢迎对文章中的引用来源进行考证,欢迎指出任何有错误或不够清晰的表达。可以在下面评论区评论,也可以邮件至 irvin.em@live.com

文章标题:ubuntu安装PHP环境

文章字数:666

本文作者:dino

发布时间:2019-11-08, 14:20:46

最后更新:2019-11-18, 23:33:07

原始链接:https://blog.walkbc.com/2019/11/08/PHPInstall/

版权声明: "署名-非商用-相同方式共享 4.0" 转载请保留原文链接及作者。

目录