Files
chill_notes/Linux/AliYun/阿里云管理PHP.md
2026-04-21 20:33:24 +08:00

99 lines
1.4 KiB
Markdown
Executable File
Raw Permalink Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
# 阿里云管理 PHP
> PHP 7.0 安装和配置
## 安装 PHP 组件
```bash
sudo apt-get install php7.0 \
php7.0-curl \
php7.0-gd \
php7.0-json \
php7.0-opcache \
php7.0-xml \
php7.0-mbstring \
php7.0-mcrypt \
php7.0-cgi \
php7.0-xmlrpc \
php-pear
```
---
## 重启服务
```bash
sudo systemctl restart apache2
sudo systemctl restart mysql
```
---
## 测试 PHP
### 创建测试文件
```bash
sudo vim /var/www/html/info.php
```
写入:
```php
<?php
phpinfo();
?>
```
### 访问
浏览器打开:`http://服务器IP/info.php`
能看到 PHP 版本信息页面说明安装成功。
---
## 常用 PHP 配置
### php.ini 位置
```bash
# Apache 模块方式
/etc/php/7.0/apache2/php.ini
# CLI 方式
/etc/php/7.0/cli/php.ini
```
### 常用配置项
```ini
display_errors = On # 显示错误
error_reporting = E_ALL # 错误级别
upload_max_filesize = 20M # 上传文件大小限制
post_max_size = 25M # POST 大小限制
max_execution_time = 300 # 最大执行时间
memory_limit = 256M # 内存限制
```
---
## PHP-FPM可选
如果使用 Nginx
```bash
sudo apt-get install php7.0-fpm
sudo systemctl start php7.0-fpm
```
---
## 常用命令
| 命令 | 说明 |
|------|------|
| `php -v` | 查看 PHP 版本 |
| `php -m` | 查看已加载模块 |
| `php -i` | 详细 PHP 信息 |
| `systemctl restart apache2` | 重启 Apache |