阡陌 发表于 2024-1-31 20:53:15

Ubuntu 安装 PHP


安装:
```
sudo apt-get install php
Reading package lists... Done
Building dependency tree      
Reading state information... Done
The following additional packages will be installed:
php-common php7.0 php7.0-cli php7.0-common php7.0-fpm php7.0-json php7.0-opcache php7.0-readline
Suggested packages:
php-pear
The following NEW packages will be installed:
php php-common php7.0 php7.0-cli php7.0-common php7.0-fpm php7.0-json php7.0-opcache php7.0-readline
0 upgraded, 9 newly installed, 0 to remove and 0 not upgraded.
Need to get 3,532 kB of archives.
After this operation, 14.1 MB of additional disk space will be used.
Do you want to continue?
```

除了自动安装的 php7.0-cli php7.0-common php7.0-fpm 等,再安装一些模块:
```
sudo apt-get install php7.0-mysql php7.0-curl php7.0-mcrypt php7.0-mbstring php7.0-xml
```

测试:
```
php -v
PHP 7.0.32-0ubuntu0.16.04.1 (cli) ( NTS )
Copyright (c) 1997-2017 The PHP Group
Zend Engine v3.0.0, Copyright (c) 1998-2017 Zend Technologies
    with Zend OPcache v7.0.32-0ubuntu0.16.04.1, Copyright (c) 1999-2017, by Zend Technologies
```

php7.0-fpm 服务控制:
```
sudo service php7.0-fpm stop
sudo service php7.0-fpm start
sudo service php7.0-fpm restart
sudo service php7.0-fpm status
```


页: [1]
查看完整版本: Ubuntu 安装 PHP