ubuntu安装php,以及一些依赖
2022-11-13 23:49:30 / 1378 / 编程代码我的ubuntu版本是20.04.05
这里以安装php7.4为标准
如果是root权限不需要加sudo
sudo apt-get update
sudo apt -y install software-properties-common
sudo add-apt-repository ppa:ondrej/php
sudo apt-get update
安装php包格式,多个加到后面 sudo apt-get install php7.4-PACKAGE_NAME:
sudo apt-get install -y php7.4-cli php7.4-fpm php7.4-json
php7.4-common php7.4-mysql php7.4-zip php7.4-gd php7.4-mbstring
php7.4-curl php7.4-xml php7.4-bcmath php7.4-redis
需要phpize就安装sudo apt-get install php7.4-dev
需要eventsudo apt-get install libevent-dev gcc php7.4-pear php7.4-dev -y
pecl install event
这一步如果提示你:No releases available for package "pecl.php.net/event"
那么就去 https://pecl.php.net/package/event 网站手动下载包
比如 wget https://pecl.php.net/get/event-3.0.8.tgz
然后执行
pecl install event-3.0.8.tgz
遇到 Include libevent OpenSSL support [yes] :
时输入no
回车,
遇到 PHP Namespace for all Event classes :
时输入yes
,其它直接敲回车就行
安装成功后在php.ini中加上extension=event.so