Apache2安装与启动
- 安装Apache2
sudo apt-get install apache2
- 启动Apache2
sudo systemctl start apache2
- 停止
sudo systemctl stop apache2
- 重启
sudo systemctl restart apache2
配置php环境
- 更新依赖
sudo apt-get update
- 安装php
sudo apt-get install libapache2-mod-php
- 重启Apache
sudo systemctl restart apache2
- 创建hello.php 放到/var/www/html
<!DOCTYPE html>
<html lang="en">
<head>
<title>Example</title>
</head>
<body>
<?php
echo "Hi, I'm a PHP script!";
?>
</body>
</html>
- localhost/hello.php 显示
libapache2-mod-php让apache支持php,也就是说能够解析php