可以先
apt-get update
安装 Apache2
apt-get install apache2
我的环境
Ubuntu 16.04.2 LTS (GNU/Linux 4.4.0-82-generic x86_64)
# apache2 -v
Server version: Apache/2.4.18 (Ubuntu)
Server built: 2017-06-26T11:58:04
配置 Apache2 根目录
# vi /etc/apache2/sites-available/000-default.conf
把这一行改成你喜欢的目录,当然我也修改了同目录下面的 default-ssl.conf 文件的这一行
DocumentRoot /var/www/html
之后修改 apache2.conf 文件
# vi /etc/apache2/apache2.conf
添加下面一段
<Directory [想要的目录]>
Options Indexes FollowSymLinks
AllowOverride None
Require all granted
</Directory>
其实这一段在这个文件里是有很多重复的,复制一段改改就好。
然后
service apache2 restart
应该是好用了。