怎样在Ubuntu上使用源安装PHP

2020年1月7日 | 分类: 未分类

参考:https://blog.csdn.net/lbp0408/article/details/80242795

直接用官方PPA源:

add-apt-repository -y ppa:ondrej/php
apt-get update

显示软件安装包列表,是否已经有了PHP 7.3,可选

apt-cache pkgnames | grep php7.3

安装:

apt-get install php7.3 php7.3-fpm

版本:

php -v

输出:

PHP 7.3.13-1+ubuntu18.04.1+deb.sury.org+1 (cli) (built: Dec 18 2019 14:48:49) ( NTS )
Copyright (c) 1997-2018 The PHP Group
Zend Engine v3.3.13, Copyright (c) 1998-2018 Zend Technologies
    with Zend OPcache v7.3.13-1+ubuntu18.04.1+deb.sury.org+1, Copyright (c) 1999-2018, by Zend Technologies

包括:

php7.3-common:
/etc/php/7.3/mods-available/calendar.ini
/etc/php/7.3/mods-available/ctype.ini
/etc/php/7.3/mods-available/exif.ini
/etc/php/7.3/mods-available/fileinfo.ini
/etc/php/7.3/mods-available/ftp.ini
/etc/php/7.3/mods-available/gettext.ini
/etc/php/7.3/mods-available/iconv.ini
/etc/php/7.3/mods-available/pdo.ini
/etc/php/7.3/mods-available/phar.ini
/etc/php/7.3/mods-available/posix.ini
/etc/php/7.3/mods-available/shmop.ini
/etc/php/7.3/mods-available/sockets.ini
/etc/php/7.3/mods-available/sysvmsg.ini
/etc/php/7.3/mods-available/sysvsem.ini
/etc/php/7.3/mods-available/sysvshm.ini
/etc/php/7.3/mods-available/tokenizer.ini
php7.3-opcache:
/etc/php/7.3/mods-available/opcache.ini
php7.3-readline:
/etc/php/7.3/mods-available/readline.ini
php7.3-json:
/etc/php/7.3/mods-available/json.ini

路径:

/usr/bin/php7.3 => /usr/bin/php mode
/usr/bin/phar7.3 => /usr/bin/phar uto mode
/usr/bin/phar.phar7.3 => /usr/bin/phar.phar

/etc/php/7.3/cli/php.ini
php7.3-fpm:/etc/php/7.3/fpm/php.ini

权限:

chown -R root:root /usr/local/apache2/htdocs

启动 MySQL:

service mysql start

启动 Apache2:

/usr/local/apache2/bin/apachectl start

apt-get install php7.3-curl
apt-get install php7.3-imap
apt-get install php7.3-ldap
apt-get install php7.3-xml
apt-get install php7.3-xsl
apt-get install php7.3-xmlrpc
apt-get install php7.3-zip
apt-get install php7.3-mbstring
apt-get install php7.3-json
apt-get install php7.3-mysql
apt-get install php7.3-gd
apt-get install php7.3-intl
apt-get install php7.3-opcache
apt-get install php7.3-bz2

确保 extension_dir存在,并且包含curl.so,

查找extension_dir:

php -i | grep extension_dir

输出:

extension_dir => /usr/lib/php/20180731 => /usr/lib/php/20180731

让apache能识别php文件

apt-get install libapache2-mod-php7.3

apt-get install libapache2-mod-auth-mysql

参考:https://www.jianshu.com/p/100ce912e36f

设置开机自启

sudo systemctl enable php73-php-fpm.service

常用 php-fpm 命令

开启服务

service php7.3-fpm start

停止服务

service php7.3-fpm stop

查看状态

service php7.3-fpm status

cp /root/php-7.3.13/php.ini-production /usr/local/php/etc/php.ini

php -v

PHP 7.3.13 (cli) (built: Jan 6 2020 11:20:20) ( ZTS )
Copyright (c) 1997-2018 The PHP Group
Zend Engine v3.3.13, Copyright (c) 1998-2018 Zend Technologies

imap
参考:https://www.cnblogs.com/helloworld899/p/7813089.html

apt-get install libc-client-dev
apt-get install libkrb5-dev

安装 ionCube :

wget https://downloads.ioncube.com/loader_downloads/ioncube_loaders_lin_x86-64.tar.gz && tar xvfz ioncube_loaders_lin_x86-64.tar.gz && mv ioncube /usr/local/ioncube