debian安装apache和PHP
时间: 2024-09-22 16:01:38 浏览: 70
Debian 安装Testlink.pdf
在Debian系统上安装Apache服务器和PHP,可以按照以下步骤操作:
1. 更新包列表并安装基本工具:
```bash
sudo apt update
sudo apt install apt-transport-https ca-certificates curl gnupg lsb-release
```
2. 添加官方Debian PHP和Apache GPG密钥:
```bash
curl -fsSL https://packages.apache.org/debian-keyring.gpg | sudo gpg --dearmor -o /usr/share/keyrings/apache-archive-keyring.gpg
echo "deb [signed-by=/usr/share/keyrings/apache-archive-keyring.gpg] https://apache.kitware.com/debian $(lsb_release -cs) apache" | sudo tee /etc/apt/sources.list.d/apache.list > /dev/null
```
3. 安装Apache:
```bash
sudo apt-get install apache2
```
启动并启用Apache服务:
```bash
sudo systemctl start apache2
sudo systemctl enable apache2
```
4. 安装PHP:
```bash
sudo apt-get install php-fpm libapache2-mod-php php-mysql
```
5. 配置Apache以支持PHP:
编辑`/etc/apache2/mods-available/php.conf`文件,取消注释`LoadModule php_module modules/libphp8.so`行,并重启Apache确认配置更改:
```bash
sudo a2enmod php
sudo systemctl restart apache2
```
检查是否成功:
访问`http://your_server_ip/server_name/info.php`(替换实际的IP和域名),如果看到PHP信息,则说明安装配置已完成。
阅读全文