Files
chill_notes/Linux/AliYun/阿里云PHP配置.md
2026-04-21 20:31:40 +08:00

82 lines
1.4 KiB
Markdown
Executable File
Raw 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 配置
> Ubuntu 16.04 配置 PHP + phpMyAdmin
## 安装 PHP 和 MySQL
```bash
sudo apt-get update
sudo apt-get install mysql-server mysql-client
sudo apt-get install php
```
---
## 安装 phpMyAdmin
```bash
sudo apt-get install phpmyadmin
sudo apt-get install php-mbstring
sudo apt-get install php-gettext
```
> ⚠️ **重要**php7.0 默认不带 `php-mbstring` 和 `php-gettext`,不安装会报白屏错误。
安装时选择 **自动配置数据库**,输入 MySQL root 密码。
---
## 配置 Apache
### 建立软链接
```bash
sudo ln -s /usr/share/phpmyadmin /var/www/html/phpmyadmin
```
### 修改 PHP 配置
```bash
sudo vim /etc/php/7.0/apache2/php.ini
```
修改以下配置:
```ini
display_errors = On
extension=php_mbstring.dll
```
> ⚠️ `display_errors` 出现两次都要改,否则无效。
---
## 重启 Apache
```bash
sudo systemctl restart apache2
# 或
sudo /etc/init.d/apache2 restart
```
---
## 访问
浏览器打开:`http://服务器IP/phpmyadmin`
输入 MySQL root 账号密码登录。
---
## 常见问题
| 问题 | 解决方案 |
|------|----------|
| 白屏/报错 | 安装 `php-mbstring``php-gettext` |
| 找不到文件 | 检查软链接是否正确创建 |
| 权限错误 | `chmod 755 /var/www/html/phpmyadmin` |
---
> 参考:[CSDN - Ubuntu PHP 配置](http://blog.csdn.net/l6807718/article/details/51374915)